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