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.
This commit is contained in:
parent
bebd8a6c2e
commit
024739eb2b
@ -1,3 +1,15 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2002-05-10 Mark Bradshaw <bradshaw@staff.crosswalk.com>
|
2002-05-10 Mark Bradshaw <bradshaw@staff.crosswalk.com>
|
||||||
|
|
||||||
* libc/include/string.h (!__STRICT_ANSI__): Add strlcat and strlcpy.
|
* libc/include/string.h (!__STRICT_ANSI__): Add strlcat and strlcpy.
|
||||||
|
@ -337,6 +337,8 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
|
|||||||
int prec; /* precision from format (%.3d), or -1 */
|
int prec; /* precision from format (%.3d), or -1 */
|
||||||
char sign; /* sign prefix (' ', '+', '-', or \0) */
|
char sign; /* sign prefix (' ', '+', '-', or \0) */
|
||||||
char old_sign; /* saved value of sign when looping for vectors */
|
char old_sign; /* saved value of sign when looping for vectors */
|
||||||
|
int old_ch; /* saved value of ch when looping for vectors */
|
||||||
|
char *format_anchor; /* start of format to process */
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
#ifdef FLOATING_POINT
|
#ifdef FLOATING_POINT
|
||||||
char *decimal_point = localeconv()->decimal_point;
|
char *decimal_point = localeconv()->decimal_point;
|
||||||
@ -535,7 +537,9 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
|
|||||||
vec_sep = ' ';
|
vec_sep = ' ';
|
||||||
#endif /* __ALTIVEC__ */
|
#endif /* __ALTIVEC__ */
|
||||||
|
|
||||||
|
format_anchor = fmt;
|
||||||
rflag: ch = *fmt++;
|
rflag: ch = *fmt++;
|
||||||
|
old_ch = ch;
|
||||||
reswitch: switch (ch) {
|
reswitch: switch (ch) {
|
||||||
case ' ':
|
case ' ':
|
||||||
/*
|
/*
|
||||||
@ -571,6 +575,11 @@ reswitch: switch (ch) {
|
|||||||
case ';':
|
case ';':
|
||||||
case ':':
|
case ':':
|
||||||
case '_':
|
case '_':
|
||||||
|
if (vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
vec_sep = ch;
|
vec_sep = ch;
|
||||||
goto rflag;
|
goto rflag;
|
||||||
#endif /* __ALTIVEC__ */
|
#endif /* __ALTIVEC__ */
|
||||||
@ -611,6 +620,11 @@ reswitch: switch (ch) {
|
|||||||
goto rflag;
|
goto rflag;
|
||||||
#endif
|
#endif
|
||||||
case 'h':
|
case 'h':
|
||||||
|
if (flags & LONGINT)
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
flags |= SHORTINT;
|
flags |= SHORTINT;
|
||||||
#ifdef __ALTIVEC__
|
#ifdef __ALTIVEC__
|
||||||
if (flags & VECTOR)
|
if (flags & VECTOR)
|
||||||
@ -618,6 +632,11 @@ reswitch: switch (ch) {
|
|||||||
#endif
|
#endif
|
||||||
goto rflag;
|
goto rflag;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
if (flags & SHORTINT)
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (*fmt == 'l') {
|
if (*fmt == 'l') {
|
||||||
fmt++;
|
fmt++;
|
||||||
flags |= QUADINT;
|
flags |= QUADINT;
|
||||||
@ -632,13 +651,24 @@ reswitch: switch (ch) {
|
|||||||
goto rflag;
|
goto rflag;
|
||||||
#ifdef __ALTIVEC__
|
#ifdef __ALTIVEC__
|
||||||
case 'v':
|
case 'v':
|
||||||
|
if (flags & VECTOR)
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
flags |= VECTOR;
|
flags |= VECTOR;
|
||||||
vec_print_count = (flags & SHORTINT) ? 8 :
|
vec_print_count = (flags & SHORTINT) ? 8 :
|
||||||
((flags & LONGINT) ? 4 : 16);
|
((flags & LONGINT) ? 4 : 16);
|
||||||
goto rflag;
|
goto rflag;
|
||||||
#endif
|
#endif
|
||||||
case 'q':
|
case 'q':
|
||||||
flags &= ~VECTOR;
|
#ifdef __ALTIVEC__
|
||||||
|
if (flags & VECTOR)
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
flags |= QUADINT;
|
flags |= QUADINT;
|
||||||
goto rflag;
|
goto rflag;
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -646,6 +676,11 @@ reswitch: switch (ch) {
|
|||||||
if (flags & VECTOR)
|
if (flags & VECTOR)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
|
if (flags & (SHORTINT | LONGINT))
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
vec_16_byte_union tmp;
|
vec_16_byte_union tmp;
|
||||||
tmp.v = va_arg(ap, vector int);
|
tmp.v = va_arg(ap, vector int);
|
||||||
cp = buf;
|
cp = buf;
|
||||||
@ -673,6 +708,13 @@ reswitch: switch (ch) {
|
|||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
|
#ifdef __ALTIVEC__
|
||||||
|
if (!(flags & VECTOR) && vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
_uquad = SARG();
|
_uquad = SARG();
|
||||||
#ifndef _NO_LONGLONG
|
#ifndef _NO_LONGLONG
|
||||||
if ((quad_t)_uquad < 0)
|
if ((quad_t)_uquad < 0)
|
||||||
@ -710,6 +752,10 @@ reswitch: switch (ch) {
|
|||||||
vec_tmp.v = va_arg(ap, vector int);
|
vec_tmp.v = va_arg(ap, vector int);
|
||||||
}
|
}
|
||||||
_fpvalue = (double)vec_tmp.f[4 - vec_print_count];
|
_fpvalue = (double)vec_tmp.f[4 - vec_print_count];
|
||||||
|
} else if (vec_sep != ' ') {
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
|
||||||
#endif /* __ALTIVEC__ */
|
#endif /* __ALTIVEC__ */
|
||||||
} else {
|
} else {
|
||||||
_fpvalue = va_arg(ap, double);
|
_fpvalue = va_arg(ap, double);
|
||||||
@ -776,7 +822,10 @@ reswitch: switch (ch) {
|
|||||||
|
|
||||||
if (ch == 'g' || ch == 'G') {
|
if (ch == 'g' || ch == 'G') {
|
||||||
if (expt <= -4 || expt > prec)
|
if (expt <= -4 || expt > prec)
|
||||||
|
{
|
||||||
|
old_ch = ch;
|
||||||
ch = (ch == 'g') ? 'e' : 'E';
|
ch = (ch == 'g') ? 'e' : 'E';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ch = 'g';
|
ch = 'g';
|
||||||
}
|
}
|
||||||
@ -826,6 +875,13 @@ reswitch: switch (ch) {
|
|||||||
flags |= LONGINT;
|
flags |= LONGINT;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
case 'o':
|
case 'o':
|
||||||
|
#ifdef __ALTIVEC__
|
||||||
|
if (!(flags & VECTOR) && vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
_uquad = UARG();
|
_uquad = UARG();
|
||||||
base = OCT;
|
base = OCT;
|
||||||
goto nosign;
|
goto nosign;
|
||||||
@ -841,6 +897,11 @@ reswitch: switch (ch) {
|
|||||||
#ifdef __ALTIVEC__
|
#ifdef __ALTIVEC__
|
||||||
if (flags & VECTOR)
|
if (flags & VECTOR)
|
||||||
_uquad = UARG();
|
_uquad = UARG();
|
||||||
|
else if (vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif /* __ALTIVEC__ */
|
#endif /* __ALTIVEC__ */
|
||||||
_uquad = (u_long)(unsigned _POINTER_INT)va_arg(ap, void *);
|
_uquad = (u_long)(unsigned _POINTER_INT)va_arg(ap, void *);
|
||||||
@ -850,7 +911,13 @@ reswitch: switch (ch) {
|
|||||||
ch = 'x';
|
ch = 'x';
|
||||||
goto nosign;
|
goto nosign;
|
||||||
case 's':
|
case 's':
|
||||||
flags &= ~VECTOR;
|
#ifdef __ALTIVEC__
|
||||||
|
if (flags & VECTOR)
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
if ((cp = va_arg(ap, char *)) == NULL)
|
if ((cp = va_arg(ap, char *)) == NULL)
|
||||||
cp = "(null)";
|
cp = "(null)";
|
||||||
if (prec >= 0) {
|
if (prec >= 0) {
|
||||||
@ -875,6 +942,13 @@ reswitch: switch (ch) {
|
|||||||
flags |= LONGINT;
|
flags |= LONGINT;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
case 'u':
|
case 'u':
|
||||||
|
#ifdef __ALTIVEC__
|
||||||
|
if (!(flags & VECTOR) && vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
_uquad = UARG();
|
_uquad = UARG();
|
||||||
base = DEC;
|
base = DEC;
|
||||||
goto nosign;
|
goto nosign;
|
||||||
@ -883,6 +957,13 @@ reswitch: switch (ch) {
|
|||||||
goto hex;
|
goto hex;
|
||||||
case 'x':
|
case 'x':
|
||||||
xdigs = "0123456789abcdef";
|
xdigs = "0123456789abcdef";
|
||||||
|
#ifdef __ALTIVEC__
|
||||||
|
if (!(flags & VECTOR) && vec_sep != ' ')
|
||||||
|
{
|
||||||
|
fmt = format_anchor;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* __ALTIVEC__ */
|
||||||
hex: _uquad = UARG();
|
hex: _uquad = UARG();
|
||||||
base = HEX;
|
base = HEX;
|
||||||
/* leading 0x/X only if non-zero */
|
/* leading 0x/X only if non-zero */
|
||||||
@ -1078,6 +1159,7 @@ number: if ((dprec = prec) >= 0)
|
|||||||
}
|
}
|
||||||
FLUSH();
|
FLUSH();
|
||||||
sign = old_sign;
|
sign = old_sign;
|
||||||
|
ch = old_ch;
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
}
|
}
|
||||||
#endif /* __ALTIVEC__ */
|
#endif /* __ALTIVEC__ */
|
||||||
|
@ -363,6 +363,8 @@ __svfscanf_r (rptr, fp, fmt0, ap)
|
|||||||
vec_sep = c;
|
vec_sep = c;
|
||||||
goto again;
|
goto again;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
if (flags & SHORT)
|
||||||
|
continue; /* invalid format, don't process any further */
|
||||||
if (flags & LONG)
|
if (flags & LONG)
|
||||||
{
|
{
|
||||||
flags &= ~LONG;
|
flags &= ~LONG;
|
||||||
@ -382,6 +384,8 @@ __svfscanf_r (rptr, fp, fmt0, ap)
|
|||||||
goto again;
|
goto again;
|
||||||
case 'h':
|
case 'h':
|
||||||
flags |= SHORT;
|
flags |= SHORT;
|
||||||
|
if (flags & LONG)
|
||||||
|
continue; /* invalid format, don't process any further */
|
||||||
if (flags & VECTOR)
|
if (flags & VECTOR)
|
||||||
vec_read_count = 8;
|
vec_read_count = 8;
|
||||||
goto again;
|
goto again;
|
||||||
@ -482,6 +486,9 @@ __svfscanf_r (rptr, fp, fmt0, ap)
|
|||||||
type = CT_CHAR;
|
type = CT_CHAR;
|
||||||
if (flags & VECTOR)
|
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;
|
width = 0;
|
||||||
vec_read_count = 16;
|
vec_read_count = 16;
|
||||||
}
|
}
|
||||||
@ -580,7 +587,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
|
|||||||
{
|
{
|
||||||
if (vec_sep == ' ' && last_space_char != ' ' ||
|
if (vec_sep == ' ' && last_space_char != ' ' ||
|
||||||
vec_sep != ' ' && *fp->_p != vec_sep)
|
vec_sep != ' ' && *fp->_p != vec_sep)
|
||||||
goto input_failure;
|
goto match_failure;
|
||||||
if (vec_sep != ' ')
|
if (vec_sep != ' ')
|
||||||
{
|
{
|
||||||
nread++;
|
nread++;
|
||||||
@ -1172,6 +1179,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
|
|||||||
unsigned long *vp = va_arg (ap, unsigned long *);
|
unsigned long *vp = va_arg (ap, unsigned long *);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
*vp++ = vec_buf.l[i];
|
*vp++ = vec_buf.l[i];
|
||||||
|
nassigned++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_failure:
|
input_failure:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user