? fix-clip-bug.diff ? newlib-sscanf-nan-bug-patch.diff Index: newlib/libc/stdio/vfscanf.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdio/vfscanf.c,v retrieving revision 1.28 diff -p -u -r1.28 vfscanf.c --- newlib/libc/stdio/vfscanf.c 8 Feb 2005 01:33:17 -0000 1.28 +++ newlib/libc/stdio/vfscanf.c 4 Apr 2005 18:31:32 -0000 @@ -1111,7 +1111,23 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap } if (zeroes) flags &= ~NDIGITS; - /* + /* We may have a 'N' or possibly even a 'Na' as the start of 'NaN', only + to run out of chars before it was complete (or having encountered a non- + matching char). So check here if we have an outstanding nancount, and if + so put back the chars we did swallow and treat as a failed match. */ + if (nancount && nancount != 3) + { + /* Ok... what are we supposed to do in the event that the + __srefill call above was triggered in the middle of the partial + 'NaN' and so we can't put it all back? */ + while (nancount-- && (p > buf)) + { + ungetc (*(u_char *)--p, fp); + --nread; + } + goto match_failure; + } + /* * If no digits, might be missing exponent digits * (just give back the exponent) or might be missing * regular digits, but had sign and/or decimal point.