diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-09-22 16:03:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-09-22 16:03:46 +0000 |
commit | 9df541684a60a94d94cc0c08de119eec718f2318 (patch) | |
tree | 2867818d5fcba8d0cbf7547e319f0646534798b1 /stdio-common/vfscanf.c | |
parent | 5b5255f197c7b6355010d781370a3331ab5b68c3 (diff) | |
download | glibc-9df541684a60a94d94cc0c08de119eec718f2318.zip glibc-9df541684a60a94d94cc0c08de119eec718f2318.tar.gz glibc-9df541684a60a94d94cc0c08de119eec718f2318.tar.bz2 |
Update.
1999-09-22 Andreas Jaeger <aj@suse.de>
* stdio-common/tstscanf.c (main): Add test case from PR libc/1313
reported by Ben Caradoc-Davies <bmcd@physics.otago.ac.nz>.
1999-09-22 Andreas Schwab <schwab@suse.de>
* stdio-common/vfscanf.c: Fix width handling when scanning floats.
1999-04-02 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* elf/Makefile (CFLAGS-multiload.c): Change to allow building in
the source directory. Fixes PR libc/1059.
Diffstat (limited to 'stdio-common/vfscanf.c')
-rw-r--r-- | stdio-common/vfscanf.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index a6e3bb2..b50e7b8 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -1300,7 +1300,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr) if (c == L_('-') || c == L_('+')) { negative = c == L_('-'); - if (inchar () == EOF) + if (width == 0 || inchar () == EOF) /* EOF is only an input error before we read any chars. */ conv_error (); if (! ISDIGIT (c) && c != decimal) @@ -1320,11 +1320,15 @@ __vfscanf (FILE *s, const char *format, va_list argptr) { /* Maybe "nan". */ ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('a')) + if (width == 0 || inchar () == EOF || TOLOWER (c) != L_('a')) input_error (); + if (width > 0) + --width; ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('n')) + if (width == 0 || inchar () == EOF || TOLOWER (c) != L_('n')) input_error (); + if (width > 0) + --width; ADDW (c); /* It is "nan". */ goto scan_float; @@ -1333,30 +1337,48 @@ __vfscanf (FILE *s, const char *format, va_list argptr) { /* Maybe "inf" or "infinity". */ ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('n')) + if (width == 0 || inchar () == EOF || TOLOWER (c) != L_('n')) input_error (); + if (width > 0) + --width; ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('f')) + if (width == 0 || inchar () == EOF || TOLOWER (c) != L_('f')) input_error (); + if (width > 0) + --width; ADDW (c); /* It is as least "inf". */ - if (inchar () != EOF) + if (width != 0 && inchar () != EOF) { if (TOLOWER (c) == L_('i')) { + if (width > 0) + --width; /* Now we have to read the rest as well. */ ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('n')) + if (width == 0 || inchar () == EOF + || TOLOWER (c) != L_('n')) input_error (); + if (width > 0) + --width; ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('i')) + if (width == 0 || inchar () == EOF + || TOLOWER (c) != L_('i')) input_error (); + if (width > 0) + --width; ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('t')) + if (width == 0 || inchar () == EOF + || TOLOWER (c) != L_('t')) input_error (); + if (width > 0) + --width; ADDW (c); - if (inchar () == EOF || TOLOWER (c) != L_('y')) + if (width == 0 || inchar () == EOF + || TOLOWER (c) != L_('y')) input_error (); + if (width > 0) + --width; ADDW (c); } else @@ -1368,11 +1390,13 @@ __vfscanf (FILE *s, const char *format, va_list argptr) is_hexa = 0; exp_char = L_('e'); - if (c == L_('0')) + if (width != 0 && c == L_('0')) { ADDW (c); c = inchar (); - if (TOLOWER (c) == L_('x')) + if (width > 0) + --width; + if (width != 0 && TOLOWER (c) == L_('x')) { /* It is a number in hexadecimal format. */ ADDW (c); @@ -1383,6 +1407,8 @@ __vfscanf (FILE *s, const char *format, va_list argptr) /* Grouping is not allowed. */ flags &= ~GROUP; c = inchar (); + if (width > 0) + --width; } } |