diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-04-17 22:05:51 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-04-17 22:05:51 -0400 |
commit | dad40407705801c8bb597d5bc9a4eda562cae890 (patch) | |
tree | e3c30fb09d43a2d5005ea43adbc6ebbab0e4104b /src/internal/floatscan.c | |
parent | bb477f9fd4a69bac77c70d2099272ee1ac17e62c (diff) | |
download | musl-dad40407705801c8bb597d5bc9a4eda562cae890.tar.gz musl-dad40407705801c8bb597d5bc9a4eda562cae890.tar.xz musl-dad40407705801c8bb597d5bc9a4eda562cae890.zip |
fix failure to read infinity in scanf
this code worked in strtod, but not in scanf. more evidence that i should design a better interface for discarding multiple tail characters than just calling unget repeatedly...
Diffstat (limited to 'src/internal/floatscan.c')
-rw-r--r-- | src/internal/floatscan.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index 377a008b..da209e27 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -428,9 +428,10 @@ long double __floatscan(FILE *f, int c, int prec, int pok) for (i=0; i<8 && (c|32)=="infinity"[i]; i++) if (i<7) c = shgetc(f); if (i==3 || i==8 || (i>3 && pok)) { - if (i==3) shunget(f); - if (pok) for (; i>3; i--) shunget(f); - else shlim(f, 0); + if (i!=8) { + shunget(f); + if (pok) for (; i>3; i--) shunget(f); + } return sign * INFINITY; } if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++) |