2008-02-12 Jeff Johnston <jjohnstn@redhat.com>

* libc/machine/powerpc/vfprintf.c (_VFPRINTF_R): Prepare
        for user specifying --disable-newlib-io-long-long on configure.
        Call _fflush_r instead of fflush.  For _mbtowc_r, pass the
        reentrant pointer passed in rather than _REENT.
This commit is contained in:
Jeff Johnston 2008-02-12 18:07:55 +00:00
parent f46f40b54e
commit de20111eba
2 changed files with 22 additions and 16 deletions

View File

@ -1,3 +1,10 @@
2008-02-12 Jeff Johnston <jjohnstn@redhat.com>
* libc/machine/powerpc/vfprintf.c (_VFPRINTF_R): Prepare
for user specifying --disable-newlib-io-long-long on configure.
Call _fflush_r instead of fflush. For _mbtowc_r, pass the
reentrant pointer passed in rather than _REENT.
2008-02-12 Peter Rosin <peda@lysator.liu.se> 2008-02-12 Peter Rosin <peda@lysator.liu.se>
* libc/stdlib/getopt.c (getopt_internal): Handle optional * libc/stdlib/getopt.c (getopt_internal): Handle optional

View File

@ -253,7 +253,7 @@ __sbprintf_r(rptr, fp, fmt, ap)
/* do the work, then copy any error status */ /* do the work, then copy any error status */
ret = _VFPRINTF_R(rptr, &fake, fmt, ap); ret = _VFPRINTF_R(rptr, &fake, fmt, ap);
if (ret >= 0 && fflush(&fake)) if (ret >= 0 && _fflush_r(rptr, &fake))
ret = EOF; ret = EOF;
if (fake._flags & __SERR) if (fake._flags & __SERR)
fp->_flags |= __SERR; fp->_flags |= __SERR;
@ -368,13 +368,12 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
#ifndef _NO_LONGLONG #ifndef _NO_LONGLONG
#define quad_t long long #define quad_t long long
#define u_quad_t unsigned long long #define u_quad_t unsigned long long
#else
#define quad_t long
#define u_quad_t u_long
#endif #endif
#ifndef _NO_LONGLONG
u_quad_t _uquad; /* integer arguments %[diouxX] */ u_quad_t _uquad; /* integer arguments %[diouxX] */
#else
u_long _uquad;
#endif
enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */ int dprec; /* a copy of prec if [diouxX], 0 otherwise */
int realsz; /* field size expanded by dprec */ int realsz; /* field size expanded by dprec */
@ -541,9 +540,10 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
/* /*
* Scan the format for conversions (`%' character). * Scan the format for conversions (`%' character).
*/ */
for (;;) { for (;;) {
cp = fmt; cp = fmt;
while ((n = _mbtowc_r(_REENT, &wc, fmt, MB_CUR_MAX, &state)) > 0) { while ((n = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &state)) > 0) {
fmt += n; fmt += n;
if (wc == '%') { if (wc == '%') {
fmt--; fmt--;
@ -754,14 +754,9 @@ reswitch: switch (ch) {
} }
#endif /* __ALTIVEC__ */ #endif /* __ALTIVEC__ */
_uquad = SARG(); _uquad = SARG();
#ifndef _NO_LONGLONG
if ((quad_t)_uquad < 0) if ((quad_t)_uquad < 0)
#else
if ((long) _uquad < 0)
#endif
{ {
_uquad = -(quad_t)_uquad;
_uquad = -_uquad;
old_sign = sign; old_sign = sign;
sign = '-'; sign = '-';
} }
@ -907,11 +902,11 @@ reswitch: switch (ch) {
_uquad = -(quad_t)_uquad; _uquad = -(quad_t)_uquad;
} }
if (flags & SHORTINT) if (flags & SHORTINT)
_uquad <<= 49; _uquad <<= (sizeof(quad_t) - sizeof(short)) * 8 + 1;
else if (flags & LONGINT) else if (flags & LONGINT)
_uquad <<= 1; _uquad <<= 1;
else else
_uquad <<= 33; _uquad <<= (sizeof(quad_t) - sizeof(long)) * 8 + 1;
if (_uquad == 0 && sign) if (_uquad == 0 && sign)
{ {
@ -927,15 +922,19 @@ reswitch: switch (ch) {
flags |= FIXEDPOINT; flags |= FIXEDPOINT;
_uquad = UFPARG(); _uquad = UFPARG();
if (flags & SHORTINT) if (flags & SHORTINT)
_uquad <<= 48; _uquad <<= (sizeof(quad_t) - sizeof(short)) * 8;
else if (!(flags & LONGINT)) else if (!(flags & LONGINT))
_uquad <<= 32; _uquad <<= (sizeof(quad_t) - sizeof(long)) * 8;
fixed_nosign: fixed_nosign:
if (prec == -1) if (prec == -1)
prec = DEFPREC; prec = DEFPREC;
#ifndef _NO_LONGLONG
cp = cvt_ufix64 (data, _uquad, prec, &expt, &ndig); cp = cvt_ufix64 (data, _uquad, prec, &expt, &ndig);
#else
cp = cvs_ufix32 (data, _uquad, prec, &expt, &ndig);
#endif
/* act like %f of format "0.X" */ /* act like %f of format "0.X" */
size = prec + 2; size = prec + 2;