Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2005-04-05 22:38:09 +0400
committerJeff Johnston <jjohnstn@redhat.com>2005-04-05 22:38:09 +0400
commit85da703991c1706e8db919732d77cdfc3cd7ecfe (patch)
tree2a59ad46b49416cf28260018ec94ce142561f123 /newlib/libc
parent42aa06a575402b64d1d3657863f67f9bc74417be (diff)
2005-04-05 Dave Korn <dave.korn@artimi.com>
* libc/stdio/vfscanf.c (__svfscanf_r): If an error occurs processing something that looks like a "NaN", put back the characters processed.
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/stdio/vfscanf.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 621ea23aa..80c652aba 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -1111,7 +1111,24 @@ _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.
@@ -1123,7 +1140,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
/* no digits at all */
while (p > buf)
{
- ungetc (*(u_char *)-- p, fp);
+ ungetc (*(u_char *)--p, fp);
--nread;
}
goto match_failure;