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-01-07 02:31:56 +0300
committerJeff Johnston <jjohnstn@redhat.com>2005-01-07 02:31:56 +0300
commit8fa6cb9a5d5c6e380985cb12b1a799ed3acc8f25 (patch)
treea9fdbccd90a418b7db29c7952343ad0c011f87b3 /newlib/libc/stdio/vfscanf.c
parent69008322efa3e4b0b844cb552719801bef3be583 (diff)
2005-01-06 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/strtod.c (_strtod_r): Add NaN support. * (strtof): Ditto. * libc/stdio/vfscanf.c (__svfscanf_r): Ditto. * Makefile.am (MATHOBJS_IN_LIBC): Add s_nan and sf_nan functions for use by strtod and strtof. * Makefile.in: Regenerated.
Diffstat (limited to 'newlib/libc/stdio/vfscanf.c')
-rw-r--r--newlib/libc/stdio/vfscanf.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 9e04e2b71..00dfb9523 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -135,6 +135,7 @@ Supporting OS subroutines required:
#endif
#ifdef FLOATING_POINT
+#include <math.h>
#include <float.h>
/* Currently a test is made to see if long double processing is warranted.
@@ -985,6 +986,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
long zeroes, exp_adjust;
char *exp_start = NULL;
unsigned width_left = 0;
+ int nancount = 0;
#ifdef hardway
if (width == 0 || width > sizeof (buf) - 1)
#else
@@ -1007,7 +1009,6 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
*/
switch (c)
{
-
case '0':
if (flags & NDIGITS)
{
@@ -1030,8 +1031,12 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
case '7':
case '8':
case '9':
- flags &= ~(SIGNOK | NDIGITS);
- goto fok;
+ if (nancount == 0)
+ {
+ flags &= ~(SIGNOK | NDIGITS);
+ goto fok;
+ }
+ break;
case '+':
case '-':
@@ -1041,6 +1046,29 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
goto fok;
}
break;
+ case 'n':
+ case 'N':
+ if (nancount == 0
+ && (flags & (SIGNOK | NDIGITS | DPTOK | EXPOK)))
+ {
+ flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS);
+ nancount = 1;
+ goto fok;
+ }
+ else if (nancount == 2)
+ {
+ nancount = 3;
+ goto fok;
+ }
+ break;
+ case 'a':
+ case 'A':
+ if (nancount == 1)
+ {
+ nancount = 2;
+ goto fok;
+ }
+ break;
case '.':
if (flags & DPTOK)
{
@@ -1163,7 +1191,10 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
else
{
flp = va_arg (ap, float *);
- *flp = res;
+ if (isnan (res))
+ *flp = nanf (NULL);
+ else
+ *flp = res;
}
nassigned++;
}