Back to index

glibc  2.9
strtod.c
Go to the documentation of this file.
00001 /* Read decimal floating point numbers.
00002    This file is part of the GNU C Library.
00003    Copyright (C) 1995-2002,2003,2004,2006,2007 Free Software Foundation, Inc.
00004    Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <stdlib.h>
00022 #include <wchar.h>
00023 #include <locale/localeinfo.h>
00024 
00025 
00026 #ifndef FLOAT
00027 # include <math_ldbl_opt.h>
00028 # define FLOAT double
00029 # ifdef USE_WIDE_CHAR
00030 #  define STRTOF wcstod
00031 #  define STRTOF_L __wcstod_l
00032 # else
00033 #  define STRTOF strtod
00034 #  define STRTOF_L __strtod_l
00035 # endif
00036 #endif
00037 
00038 #ifdef USE_WIDE_CHAR
00039 # include <wctype.h>
00040 # define STRING_TYPE wchar_t
00041 #else
00042 # define STRING_TYPE char
00043 #endif
00044 
00045 #define INTERNAL(x) INTERNAL1(x)
00046 #define INTERNAL1(x) __##x##_internal
00047 
00048 
00049 FLOAT
00050 INTERNAL (STRTOF) (nptr, endptr, group)
00051      const STRING_TYPE *nptr;
00052      STRING_TYPE **endptr;
00053      int group;
00054 {
00055   return INTERNAL(STRTOF_L) (nptr, endptr, group, _NL_CURRENT_LOCALE);
00056 }
00057 #if defined _LIBC
00058 libc_hidden_def (INTERNAL (STRTOF))
00059 #endif
00060 
00061 
00062 FLOAT
00063 #ifdef weak_function
00064 weak_function
00065 #endif
00066 STRTOF (nptr, endptr)
00067      const STRING_TYPE *nptr;
00068      STRING_TYPE **endptr;
00069 {
00070   return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
00071 }
00072 #if defined _LIBC
00073 libc_hidden_def (STRTOF)
00074 #endif
00075 
00076 #ifdef LONG_DOUBLE_COMPAT
00077 # if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
00078 #  ifdef USE_WIDE_CHAR
00079 compat_symbol (libc, wcstod, wcstold, GLIBC_2_0);
00080 compat_symbol (libc, __wcstod_internal, __wcstold_internal, GLIBC_2_0);
00081 #  else
00082 compat_symbol (libc, strtod, strtold, GLIBC_2_0);
00083 compat_symbol (libc, __strtod_internal, __strtold_internal, GLIBC_2_0);
00084 #  endif
00085 # endif
00086 #endif