diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 7dc10fe2a..965f986e5 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2009-01-28 Jeff Johnston + + * libc/stdio/vfscanf.c (__SVFSCANF_R): Add additional check for + inf and nan processing to not proceed if we have already collected + zeroes. + 2009-01-26 DJ Delorie * configure.host (m32c-*-*): Add long long I/O support by default. diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 98c3db696..8546088a8 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -489,6 +489,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), # define GET_ARG(n, ap, type) (va_arg (ap, type)) #endif + __sfp_lock_acquire (); _flockfile (fp); ORIENT (fp, -1); @@ -779,6 +780,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), */ case '\0': /* compat */ _funlockfile (fp); + __sfp_lock_release (); return EOF; default: /* compat */ @@ -1329,7 +1331,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), break; case 'n': case 'N': - if (nancount == 0 + if (nancount == 0 && zeroes == 0 && (flags & (NDIGITS | DPTOK | EXPOK)) == (NDIGITS | DPTOK | EXPOK)) { @@ -1358,7 +1360,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), break; case 'i': case 'I': - if (infcount == 0 + if (infcount == 0 && zeroes == 0 && (flags & (NDIGITS | DPTOK | EXPOK)) == (NDIGITS | DPTOK | EXPOK)) { @@ -1577,11 +1579,13 @@ input_failure: invalid format string), return EOF if no matches yet, else number of matches made prior to failure. */ _funlockfile (fp); + __sfp_lock_release (); return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF; match_failure: all_done: /* Return number of matches, which can be 0 on match failure. */ _funlockfile (fp); + __sfp_lock_release (); return nassigned; }