From 024739eb2b2cde8d2e8c6509f90f5dad196dbd16 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Mon, 13 May 2002 19:52:17 +0000 Subject: 2002-05-13 Jeff Johnston * 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. --- newlib/libc/machine/powerpc/vfscanf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'newlib/libc/machine/powerpc/vfscanf.c') 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: -- cgit v1.2.3