@@ -20,22 +20,21 @@ static locale_t c_locale;
20
20
21
21
locale_t get_c_locale (void )
22
22
{
23
- if (!c_locale_initialized )
24
- {
25
- c_locale_initialized = 1 ;
26
- c_locale = newlocale (LC_ALL_MASK , "C" , NULL );
27
- }
28
- return c_locale ;
23
+ if (!c_locale_initialized ) {
24
+ c_locale_initialized = 1 ;
25
+ c_locale = newlocale (LC_ALL_MASK , "C" , NULL );
26
+ }
27
+ return c_locale ;
29
28
}
30
29
31
30
JL_DLLEXPORT double jl_strtod_c (const char * nptr , char * * endptr )
32
31
{
33
- return strtod_l (nptr , endptr , get_c_locale ());
32
+ return strtod_l (nptr , endptr , get_c_locale ());
34
33
}
35
34
36
35
JL_DLLEXPORT float jl_strtof_c (const char * nptr , char * * endptr )
37
36
{
38
- return strtof_l (nptr , endptr , get_c_locale ());
37
+ return strtof_l (nptr , endptr , get_c_locale ());
39
38
}
40
39
41
40
@@ -58,7 +57,7 @@ JL_DLLEXPORT float jl_strtof_c(const char *nptr, char **endptr)
58
57
59
58
int case_insensitive_match (const char * s , const char * t )
60
59
{
61
- while (* t && tolower (* s ) == * t ) {
60
+ while (* t && tolower (* s ) == * t ) {
62
61
s ++ ;
63
62
t ++ ;
64
63
}
@@ -147,84 +146,75 @@ JL_DLLEXPORT double jl_strtod_c(const char *nptr, char **endptr)
147
146
}
148
147
149
148
/* This code path is used for hex floats */
150
- if (* p == '0' && (* (p + 1 ) == 'x' || * (p + 1 ) == 'X' ))
151
- {
152
- digits_pos = p ;
153
- p += 2 ;
154
- /* Check that what's left begins with a digit or decimal point */
155
- if (!isxdigit (* p ) && * p != '.' )
156
- goto invalid_string ;
157
-
158
-
159
- if (decimal_point [0 ] != '.' ||
160
- decimal_point [1 ] != 0 )
161
- {
162
- /* Look for a '.' in the input; if present, it'll need to be
163
- swapped for the current locale's decimal point before we
164
- call strtod. On the other hand, if we find the current
165
- locale's decimal point then the input is invalid. */
166
- while (isxdigit (* p ))
167
- p ++ ;
168
-
169
- if (* p == '.' )
170
- {
171
- decimal_point_pos = p ++ ;
172
-
173
- /* locate end of number */
174
- while (isxdigit (* p ))
175
- p ++ ;
176
-
177
- if (* p == 'p' || * p == 'P' )
178
- p ++ ;
179
- if (* p == '+' || * p == '-' )
180
- p ++ ;
181
- while (isdigit (* p ))
182
- p ++ ;
183
- end = p ;
184
- }
185
- else if (strncmp (p , decimal_point , decimal_point_len ) == 0 )
186
- goto invalid_string ;
187
- /* For the other cases, we need not convert the decimal
188
- point */
189
- }
190
- } else
191
- {
192
- /* Check that what's left begins with a digit or decimal point */
193
- if (!isdigit (* p ) && * p != '.' )
194
- goto invalid_string ;
195
-
196
- digits_pos = p ;
197
- if (decimal_point [0 ] != '.' ||
198
- decimal_point [1 ] != 0 )
199
- {
200
- /* Look for a '.' in the input; if present, it'll need to be
201
- swapped for the current locale's decimal point before we
202
- call strtod. On the other hand, if we find the current
203
- locale's decimal point then the input is invalid. */
204
- while (isdigit (* p ))
205
- p ++ ;
206
-
207
- if (* p == '.' )
208
- {
209
- decimal_point_pos = p ++ ;
210
-
211
- /* locate end of number */
212
- while (isdigit (* p ))
213
- p ++ ;
214
-
215
- if (* p == 'e' || * p == 'E' )
216
- p ++ ;
217
- if (* p == '+' || * p == '-' )
218
- p ++ ;
219
- while (isdigit (* p ))
220
- p ++ ;
221
- end = p ;
222
- }
223
- else if (strncmp (p , decimal_point , decimal_point_len ) == 0 )
149
+ if (* p == '0' && (* (p + 1 ) == 'x' || * (p + 1 ) == 'X' )) {
150
+ digits_pos = p ;
151
+ p += 2 ;
152
+ /* Check that what's left begins with a digit or decimal point */
153
+ if (!isxdigit (* p ) && * p != '.' )
154
+ goto invalid_string ;
155
+
156
+
157
+ if (decimal_point [0 ] != '.' || decimal_point [1 ] != 0 ) {
158
+ /* Look for a '.' in the input; if present, it'll need to be
159
+ swapped for the current locale's decimal point before we
160
+ call strtod. On the other hand, if we find the current
161
+ locale's decimal point then the input is invalid. */
162
+ while (isxdigit (* p ))
163
+ p ++ ;
164
+
165
+ if (* p == '.' ) {
166
+ decimal_point_pos = p ++ ;
167
+
168
+ /* locate end of number */
169
+ while (isxdigit (* p ))
170
+ p ++ ;
171
+
172
+ if (* p == 'p' || * p == 'P' )
173
+ p ++ ;
174
+ if (* p == '+' || * p == '-' )
175
+ p ++ ;
176
+ while (isdigit (* p ))
177
+ p ++ ;
178
+ end = p ;
179
+ }
180
+ else if (strncmp (p , decimal_point , decimal_point_len ) == 0 )
181
+ goto invalid_string ;
182
+ /* For the other cases, we need not convert the decimal point */
183
+ }
184
+ }
185
+ else {
186
+ /* Check that what's left begins with a digit or decimal point */
187
+ if (!isdigit (* p ) && * p != '.' )
224
188
goto invalid_string ;
225
- /* For the other cases, we need not convert the decimal
226
- point */
227
- }
189
+
190
+ digits_pos = p ;
191
+ if (decimal_point [0 ] != '.' || decimal_point [1 ] != 0 ) {
192
+ /* Look for a '.' in the input; if present, it'll need to be
193
+ swapped for the current locale's decimal point before we
194
+ call strtod. On the other hand, if we find the current
195
+ locale's decimal point then the input is invalid. */
196
+ while (isdigit (* p ))
197
+ p ++ ;
198
+
199
+ if (* p == '.' ) {
200
+ decimal_point_pos = p ++ ;
201
+
202
+ /* locate end of number */
203
+ while (isdigit (* p ))
204
+ p ++ ;
205
+
206
+ if (* p == 'e' || * p == 'E' )
207
+ p ++ ;
208
+ if (* p == '+' || * p == '-' )
209
+ p ++ ;
210
+ while (isdigit (* p ))
211
+ p ++ ;
212
+ end = p ;
213
+ }
214
+ else if (strncmp (p , decimal_point , decimal_point_len ) == 0 )
215
+ goto invalid_string ;
216
+ /* For the other cases, we need not convert the decimal point */
217
+ }
228
218
}
229
219
230
220
if (decimal_point_pos ) {
@@ -263,7 +253,6 @@ JL_DLLEXPORT double jl_strtod_c(const char *nptr, char **endptr)
263
253
}
264
254
265
255
free (copy );
266
-
267
256
}
268
257
else {
269
258
val = strtod (digits_pos , & fail_pos );
@@ -278,7 +267,7 @@ JL_DLLEXPORT double jl_strtod_c(const char *nptr, char **endptr)
278
267
279
268
return val ;
280
269
281
- invalid_string :
270
+ invalid_string :
282
271
* endptr = (char * )nptr ;
283
272
errno = EINVAL ;
284
273
return -1.0 ;
@@ -287,7 +276,7 @@ JL_DLLEXPORT double jl_strtod_c(const char *nptr, char **endptr)
287
276
288
277
JL_DLLEXPORT float jl_strtof_c (const char * nptr , char * * endptr )
289
278
{
290
- return (float ) jl_strtod_c (nptr , endptr );
279
+ return (float ) jl_strtod_c (nptr , endptr );
291
280
}
292
281
293
282
#endif
0 commit comments