diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-02-12 18:07:55 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-02-12 18:07:55 +0000 |
commit | de20111eba5768f4ebb7dcf1d59b1528302a0043 (patch) | |
tree | 74a0d902afcf1663b6b2c62373dcea036fc36443 /newlib/libc/machine/powerpc | |
parent | f46f40b54e6993356a87a258abca4cb570cbed59 (diff) | |
download | newlib-de20111eba5768f4ebb7dcf1d59b1528302a0043.zip newlib-de20111eba5768f4ebb7dcf1d59b1528302a0043.tar.gz newlib-de20111eba5768f4ebb7dcf1d59b1528302a0043.tar.bz2 |
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.
Diffstat (limited to 'newlib/libc/machine/powerpc')
-rw-r--r-- | newlib/libc/machine/powerpc/vfprintf.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/newlib/libc/machine/powerpc/vfprintf.c b/newlib/libc/machine/powerpc/vfprintf.c index 2b2cec3..d264e26 100644 --- a/newlib/libc/machine/powerpc/vfprintf.c +++ b/newlib/libc/machine/powerpc/vfprintf.c @@ -253,7 +253,7 @@ __sbprintf_r(rptr, fp, fmt, ap) /* do the work, then copy any error status */ ret = _VFPRINTF_R(rptr, &fake, fmt, ap); - if (ret >= 0 && fflush(&fake)) + if (ret >= 0 && _fflush_r(rptr, &fake)) ret = EOF; if (fake._flags & __SERR) fp->_flags |= __SERR; @@ -368,13 +368,12 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), #ifndef _NO_LONGLONG #define quad_t long long #define u_quad_t unsigned long long +#else +#define quad_t long +#define u_quad_t u_long #endif -#ifndef _NO_LONGLONG u_quad_t _uquad; /* integer arguments %[diouxX] */ -#else - u_long _uquad; -#endif enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ int dprec; /* a copy of prec if [diouxX], 0 otherwise */ int realsz; /* field size expanded by dprec */ @@ -541,9 +540,10 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), /* * Scan the format for conversions (`%' character). */ + for (;;) { 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; if (wc == '%') { fmt--; @@ -754,14 +754,9 @@ reswitch: switch (ch) { } #endif /* __ALTIVEC__ */ _uquad = SARG(); -#ifndef _NO_LONGLONG if ((quad_t)_uquad < 0) -#else - if ((long) _uquad < 0) -#endif { - - _uquad = -_uquad; + _uquad = -(quad_t)_uquad; old_sign = sign; sign = '-'; } @@ -907,11 +902,11 @@ reswitch: switch (ch) { _uquad = -(quad_t)_uquad; } if (flags & SHORTINT) - _uquad <<= 49; + _uquad <<= (sizeof(quad_t) - sizeof(short)) * 8 + 1; else if (flags & LONGINT) _uquad <<= 1; else - _uquad <<= 33; + _uquad <<= (sizeof(quad_t) - sizeof(long)) * 8 + 1; if (_uquad == 0 && sign) { @@ -927,15 +922,19 @@ reswitch: switch (ch) { flags |= FIXEDPOINT; _uquad = UFPARG(); if (flags & SHORTINT) - _uquad <<= 48; + _uquad <<= (sizeof(quad_t) - sizeof(short)) * 8; else if (!(flags & LONGINT)) - _uquad <<= 32; + _uquad <<= (sizeof(quad_t) - sizeof(long)) * 8; fixed_nosign: if (prec == -1) prec = DEFPREC; +#ifndef _NO_LONGLONG 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" */ size = prec + 2; |