Mercurial > gnulib
comparison lib/strtod.c @ 13545:1531149632e8
strtod: fix const diagnostic
* lib/strtod.c (strtod): Don't assign const char * to char *,
as this elicits a warning from GCC when warnings are enabled.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 10 Aug 2010 10:39:30 -0700 |
parents | be8a41115d44 |
children | d813f5516d9a |
comparison
equal
deleted
inserted
replaced
13544:e123501bb47c | 13545:1531149632e8 |
---|---|
198 | 198 |
199 /* The number so far. */ | 199 /* The number so far. */ |
200 double num; | 200 double num; |
201 | 201 |
202 const char *s = nptr; | 202 const char *s = nptr; |
203 char *end; | 203 const char *end; |
204 char *endbuf; | |
204 | 205 |
205 /* Eat whitespace. */ | 206 /* Eat whitespace. */ |
206 while (locale_isspace (*s)) | 207 while (locale_isspace (*s)) |
207 ++s; | 208 ++s; |
208 | 209 |
209 /* Get the sign. */ | 210 /* Get the sign. */ |
210 negative = *s == '-'; | 211 negative = *s == '-'; |
211 if (*s == '-' || *s == '+') | 212 if (*s == '-' || *s == '+') |
212 ++s; | 213 ++s; |
213 | 214 |
214 num = underlying_strtod (s, &end); | 215 num = underlying_strtod (s, &endbuf); |
216 end = endbuf; | |
215 | 217 |
216 if (c_isdigit (s[*s == '.'])) | 218 if (c_isdigit (s[*s == '.'])) |
217 { | 219 { |
218 /* If a hex float was converted incorrectly, do it ourselves. | 220 /* If a hex float was converted incorrectly, do it ourselves. |
219 If the string starts with "0x" but does not contain digits, | 221 If the string starts with "0x" but does not contain digits, |
222 if (*s == '0' && c_tolower (s[1]) == 'x') | 224 if (*s == '0' && c_tolower (s[1]) == 'x') |
223 { | 225 { |
224 if (! c_isxdigit (s[2 + (s[2] == '.')])) | 226 if (! c_isxdigit (s[2 + (s[2] == '.')])) |
225 end = s + 1; | 227 end = s + 1; |
226 else if (end <= s + 2) | 228 else if (end <= s + 2) |
227 num = parse_number (s + 2, 16, 2, 4, 'p', &end); | 229 { |
230 num = parse_number (s + 2, 16, 2, 4, 'p', &endbuf); | |
231 end = endbuf; | |
232 } | |
228 else | 233 else |
229 { | 234 { |
230 const char *p = s + 2; | 235 const char *p = s + 2; |
231 while (p < end && c_tolower (*p) != 'p') | 236 while (p < end && c_tolower (*p) != 'p') |
232 p++; | 237 p++; |