]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdlib/strtod.c
assert: Do not use stderr in libc-internal assert
[thirdparty/glibc.git] / stdlib / strtod.c
CommitLineData
28f540f4 1/* Read decimal floating point numbers.
7cc27f44 2 This file is part of the GNU C Library.
581c785b 3 Copyright (C) 1995-2022 Free Software Foundation, Inc.
28f540f4 4
7cc27f44 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
28f540f4 9
7cc27f44
UD
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
28f540f4 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
28f540f4 18
a5a2a76b
JM
19#include <bits/floatn.h>
20
21#ifdef FLOAT
22# define BUILD_DOUBLE 0
23#else
24# define BUILD_DOUBLE 1
25#endif
26
27#if BUILD_DOUBLE
28# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
29# define strtof64 __hide_strtof64
30# define wcstof64 __hide_wcstof64
31# endif
32# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
33# define strtof32x __hide_strtof32x
34# define wcstof32x __hide_wcstof32x
35# endif
36#endif
37
ccadf7b5
UD
38#include <stdlib.h>
39#include <wchar.h>
40#include <locale/localeinfo.h>
41
42
28f540f4 43#ifndef FLOAT
c6251f03 44# include <math_ldbl_opt.h>
ccadf7b5 45# define FLOAT double
75cd5204 46# ifdef USE_WIDE_CHAR
ccadf7b5
UD
47# define STRTOF wcstod
48# define STRTOF_L __wcstod_l
75cd5204 49# else
ccadf7b5
UD
50# define STRTOF strtod
51# define STRTOF_L __strtod_l
75cd5204 52# endif
27a5bb33 53#endif
0501d603
UD
54
55#ifdef USE_WIDE_CHAR
56# include <wctype.h>
0501d603 57# define STRING_TYPE wchar_t
0501d603
UD
58#else
59# define STRING_TYPE char
28f540f4
RM
60#endif
61
f0bf9cb9
RM
62#define INTERNAL(x) INTERNAL1(x)
63#define INTERNAL1(x) __##x##_internal
64
f0bf9cb9 65
28f540f4 66FLOAT
80d9be81 67INTERNAL (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group)
28f540f4 68{
ccadf7b5 69 return INTERNAL(STRTOF_L) (nptr, endptr, group, _NL_CURRENT_LOCALE);
28f540f4 70}
ccadf7b5 71#if defined _LIBC
509d1b68
RM
72libc_hidden_def (INTERNAL (STRTOF))
73#endif
ccadf7b5 74
f0bf9cb9 75
f0bf9cb9 76FLOAT
7702f9b5
RM
77#ifdef weak_function
78weak_function
79#endif
80d9be81 80STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
f0bf9cb9 81{
ccadf7b5 82 return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
f0bf9cb9 83}
773e305e
RM
84#if defined _LIBC
85libc_hidden_def (STRTOF)
86#endif
c6251f03
RM
87
88#ifdef LONG_DOUBLE_COMPAT
89# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
90# ifdef USE_WIDE_CHAR
91compat_symbol (libc, wcstod, wcstold, GLIBC_2_0);
92compat_symbol (libc, __wcstod_internal, __wcstold_internal, GLIBC_2_0);
93# else
94compat_symbol (libc, strtod, strtold, GLIBC_2_0);
95compat_symbol (libc, __strtod_internal, __strtold_internal, GLIBC_2_0);
96# endif
97# endif
98#endif
a5a2a76b
JM
99
100#if BUILD_DOUBLE
101# if __HAVE_FLOAT64 && !__HAVE_DISTINCT_FLOAT64
102# undef strtof64
103# undef wcstof64
104# ifdef USE_WIDE_CHAR
105weak_alias (wcstod, wcstof64)
106# else
107weak_alias (strtod, strtof64)
108# endif
109# endif
110# if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X
111# undef strtof32x
112# undef wcstof32x
113# ifdef USE_WIDE_CHAR
114weak_alias (wcstod, wcstof32x)
115# else
116weak_alias (strtod, strtof32x)
117# endif
118# endif
119#endif