diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-10-21 18:28:20 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-10-21 18:28:20 -0400 |
commit | 8489897e01b8a27c365c9c98b200ee25dc124cb4 (patch) | |
tree | b39e46aef7e25f19da240951bb45c4b03f22f245 /src/internal | |
parent | f1b23d41cff432a8d0939af427fa005b4a4f95d7 (diff) | |
download | musl-8489897e01b8a27c365c9c98b200ee25dc124cb4.tar.gz musl-8489897e01b8a27c365c9c98b200ee25dc124cb4.tar.bz2 musl-8489897e01b8a27c365c9c98b200ee25dc124cb4.tar.xz musl-8489897e01b8a27c365c9c98b200ee25dc124cb4.zip |
accept "nan(n-char-sequence)" in strtod/scanf functions
this will prevent gnulib from wrapping our strtod to handle this
useless feature.
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/floatscan.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index bba5753b..08251213 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -414,7 +414,7 @@ static long double hexfloat(FILE *f, int bits, int emin, int sign, int pok) long double __floatscan(FILE *f, int prec, int pok) { int sign = 1; - int i; + size_t i; int bits; int emin; int c; @@ -455,6 +455,24 @@ long double __floatscan(FILE *f, int prec, int pok) if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++) if (i<2) c = shgetc(f); if (i==3) { + if (shgetc(f) != '(') { + shunget(f); + return NAN; + } + for (i=1; ; i++) { + c = shgetc(f); + if (c-'0'<10U || c-'A'<26U || c-'a'<26U || c=='_') + continue; + if (c==')') return NAN; + shunget(f); + if (!pok) { + errno = EINVAL; + shlim(f, 0); + return 0; + } + while (i--) shunget(f); + return NAN; + } return NAN; } |