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...
This commit is contained in:
parent
bb477f9fd4
commit
dad4040770
1 changed files with 4 additions and 3 deletions
|
|
@ -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++)
|
for (i=0; i<8 && (c|32)=="infinity"[i]; i++)
|
||||||
if (i<7) c = shgetc(f);
|
if (i<7) c = shgetc(f);
|
||||||
if (i==3 || i==8 || (i>3 && pok)) {
|
if (i==3 || i==8 || (i>3 && pok)) {
|
||||||
if (i==3) shunget(f);
|
if (i!=8) {
|
||||||
if (pok) for (; i>3; i--) shunget(f);
|
shunget(f);
|
||||||
else shlim(f, 0);
|
if (pok) for (; i>3; i--) shunget(f);
|
||||||
|
}
|
||||||
return sign * INFINITY;
|
return sign * INFINITY;
|
||||||
}
|
}
|
||||||
if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++)
|
if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue