1995-02-18 01:27:10 +00:00
|
|
|
/* Read decimal floating point numbers.
|
1997-02-10 03:19:57 +00:00
|
|
|
This file is part of the GNU C Library.
|
2018-01-01 00:32:25 +00:00
|
|
|
Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
1999-04-28 23:13:52 +00:00
|
|
|
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1997-02-10 03:19:57 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1997-02-10 03:19:57 +00:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2017-12-05 18:31:53 +00:00
|
|
|
#include <bits/floatn.h>
|
|
|
|
|
|
|
|
|
|
#ifdef FLOAT
|
|
|
|
|
# define BUILD_DOUBLE 0
|
|
|
|
|
#else
|
|
|
|
|
# define BUILD_DOUBLE 1
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if BUILD_DOUBLE
|
|
|
|
|
# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
|
|
|
|
|
# define strtof64 __hide_strtof64
|
|
|
|
|
# define wcstof64 __hide_wcstof64
|
|
|
|
|
# endif
|
|
|
|
|
# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
|
|
|
|
|
# define strtof32x __hide_strtof32x
|
|
|
|
|
# define wcstof32x __hide_wcstof32x
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
#include <stdlib.h>
|
2004-03-14 21:12:06 +00:00
|
|
|
#include <wchar.h>
|
|
|
|
|
#include <locale/localeinfo.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
|
|
2004-03-14 21:12:06 +00:00
|
|
|
#ifndef FLOAT
|
2006-01-14 12:10:44 +00:00
|
|
|
# include <math_ldbl_opt.h>
|
2004-03-14 21:12:06 +00:00
|
|
|
# define FLOAT double
|
|
|
|
|
# ifdef USE_WIDE_CHAR
|
|
|
|
|
# define STRTOF wcstod
|
|
|
|
|
# define STRTOF_L __wcstod_l
|
|
|
|
|
# else
|
|
|
|
|
# define STRTOF strtod
|
|
|
|
|
# define STRTOF_L __strtod_l
|
|
|
|
|
# endif
|
1998-04-07 16:28:09 +00:00
|
|
|
#endif
|
1997-05-24 02:30:09 +00:00
|
|
|
|
|
|
|
|
#ifdef USE_WIDE_CHAR
|
|
|
|
|
# include <wctype.h>
|
|
|
|
|
# define STRING_TYPE wchar_t
|
|
|
|
|
#else
|
|
|
|
|
# define STRING_TYPE char
|
|
|
|
|
#endif
|
|
|
|
|
|
1995-03-16 05:32:45 +00:00
|
|
|
#define INTERNAL(x) INTERNAL1(x)
|
|
|
|
|
#define INTERNAL1(x) __##x##_internal
|
|
|
|
|
|
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
FLOAT
|
2015-10-20 21:27:22 +00:00
|
|
|
INTERNAL (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
2004-03-14 21:12:06 +00:00
|
|
|
return INTERNAL(STRTOF_L) (nptr, endptr, group, _NL_CURRENT_LOCALE);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
2004-03-14 21:12:06 +00:00
|
|
|
#if defined _LIBC
|
2002-08-04 01:29:29 +00:00
|
|
|
libc_hidden_def (INTERNAL (STRTOF))
|
|
|
|
|
#endif
|
2004-03-14 21:12:06 +00:00
|
|
|
|
1995-03-16 05:32:45 +00:00
|
|
|
|
|
|
|
|
FLOAT
|
1996-07-08 10:21:07 +00:00
|
|
|
#ifdef weak_function
|
|
|
|
|
weak_function
|
|
|
|
|
#endif
|
2015-10-20 21:27:22 +00:00
|
|
|
STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
|
1995-03-16 05:32:45 +00:00
|
|
|
{
|
2004-03-14 21:12:06 +00:00
|
|
|
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
|
1995-03-16 05:32:45 +00:00
|
|
|
}
|
2007-08-07 05:36:32 +00:00
|
|
|
#if defined _LIBC
|
|
|
|
|
libc_hidden_def (STRTOF)
|
|
|
|
|
#endif
|
2006-01-14 12:10:44 +00:00
|
|
|
|
|
|
|
|
#ifdef LONG_DOUBLE_COMPAT
|
|
|
|
|
# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
|
|
|
|
|
# ifdef USE_WIDE_CHAR
|
|
|
|
|
compat_symbol (libc, wcstod, wcstold, GLIBC_2_0);
|
|
|
|
|
compat_symbol (libc, __wcstod_internal, __wcstold_internal, GLIBC_2_0);
|
|
|
|
|
# else
|
|
|
|
|
compat_symbol (libc, strtod, strtold, GLIBC_2_0);
|
|
|
|
|
compat_symbol (libc, __strtod_internal, __strtold_internal, GLIBC_2_0);
|
|
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
2017-12-05 18:31:53 +00:00
|
|
|
|
|
|
|
|
#if BUILD_DOUBLE
|
|
|
|
|
# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
|
|
|
|
|
# undef strtof64
|
|
|
|
|
# undef wcstof64
|
|
|
|
|
# ifdef USE_WIDE_CHAR
|
|
|
|
|
weak_alias (wcstod, wcstof64)
|
|
|
|
|
# else
|
|
|
|
|
weak_alias (strtod, strtof64)
|
|
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
|
|
|
|
|
# undef strtof32x
|
|
|
|
|
# undef wcstof32x
|
|
|
|
|
# ifdef USE_WIDE_CHAR
|
|
|
|
|
weak_alias (wcstod, wcstof32x)
|
|
|
|
|
# else
|
|
|
|
|
weak_alias (strtod, strtof32x)
|
|
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|