summaryrefslogtreecommitdiffstats
path: root/newlib/libc/machine/powerpc/vfscanf.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-05-13 19:52:17 +0000
committerJeff Johnston <jjohnstn@redhat.com>2002-05-13 19:52:17 +0000
commit024739eb2b2cde8d2e8c6509f90f5dad196dbd16 (patch)
treeee673459d8beb0684e638d1f69c5ae7b61644a1a /newlib/libc/machine/powerpc/vfscanf.c
parentbebd8a6c2efec5ea3d2f63ff541a55e4b2e40d93 (diff)
downloadcygnal-024739eb2b2cde8d2e8c6509f90f5dad196dbd16.tar.gz
cygnal-024739eb2b2cde8d2e8c6509f90f5dad196dbd16.tar.bz2
cygnal-024739eb2b2cde8d2e8c6509f90f5dad196dbd16.zip
2002-05-13 Jeff Johnston <jjohnstn@redhat.com>
* libc/machine/powerpc/vfprintf.c(__VFPRINTF_R)[__ALTIVEC__]: Restore the original format specifier when looping for vectors to compensate for any changes made in vector %g format processing. Also add syntax checking for various invalid scenarios involving vector format extensions. * libc/machine/powerpc/vfscanf.c(__VFSCANF_R)[__ALTIVEC__]: Fix return code setting for vector formats. Also treat vector separator mismatch as a match error instead of an input error. Perform some syntax checking for vector formats.
Diffstat (limited to 'newlib/libc/machine/powerpc/vfscanf.c')
-rw-r--r--newlib/libc/machine/powerpc/vfscanf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/newlib/libc/machine/powerpc/vfscanf.c b/newlib/libc/machine/powerpc/vfscanf.c
index c0bd0e526..919147c3a 100644
--- a/newlib/libc/machine/powerpc/vfscanf.c
+++ b/newlib/libc/machine/powerpc/vfscanf.c
@@ -363,6 +363,8 @@ __svfscanf_r (rptr, fp, fmt0, ap)
vec_sep = c;
goto again;
case 'l':
+ if (flags & SHORT)
+ continue; /* invalid format, don't process any further */
if (flags & LONG)
{
flags &= ~LONG;
@@ -382,6 +384,8 @@ __svfscanf_r (rptr, fp, fmt0, ap)
goto again;
case 'h':
flags |= SHORT;
+ if (flags & LONG)
+ continue; /* invalid format, don't process any further */
if (flags & VECTOR)
vec_read_count = 8;
goto again;
@@ -482,6 +486,9 @@ __svfscanf_r (rptr, fp, fmt0, ap)
type = CT_CHAR;
if (flags & VECTOR)
{
+ /* not allowed to have h or l with c specifier */
+ if (flags & (LONG | SHORT))
+ continue; /* invalid format don't process any further */
width = 0;
vec_read_count = 16;
}
@@ -580,7 +587,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
{
if (vec_sep == ' ' && last_space_char != ' ' ||
vec_sep != ' ' && *fp->_p != vec_sep)
- goto input_failure;
+ goto match_failure;
if (vec_sep != ' ')
{
nread++;
@@ -958,7 +965,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
ip = va_arg (ap, int *);
*ip++ = res;
}
- else
+ else
{
if (!looped)
ch_dest = vec_buf.c;
@@ -1172,6 +1179,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
unsigned long *vp = va_arg (ap, unsigned long *);
for (i = 0; i < 4; ++i)
*vp++ = vec_buf.l[i];
+ nassigned++;
}
}
input_failure: