is defined. Raise conversion buffer size to make sure it has enough
room for numbers plus grouping character. Define GROUPING flag.
(_VFPRINTF_R): Add PRINTANDPAD macro. Handle grouping flag character.
Handle grouping for decimal integer and float values.
* libc/stdio/vfwprintf.c: Ditto.
_mbtowc_r with direct call to __mbtowc.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdlib/btowc.c: Include local.h. Replace call to _mbtowc_r
with direct call to __mbtowc.
* libc/stdlib/mblen.c: Ditto.
* libc/stdlib/mblen_r.c: Ditto.
* libc/stdlib/mbrtowc.c: Ditto.
* libc/stdlib/mbstowcs_r.c: Ditto.
* libc/stdlib/mbtowc.c: Ditto.
* libc/stdlib/wcrtomb.c: Include local.h. Replace call to _wctomb_r
with direct call to __wctomb.
* libc/stdlib/wcsnrtombs.c: Ditto.
(_wcsnrtombs_r): Ditto.
* libc/stdlib/wcstombs_r.c: Ditto.
* libc/stdlib/wctob.c: Ditto.
* libc/stdlib/wctomb.c: Ditto.
* libc/stdlib/mbrtowc.c (mbrtowc): Implement independently from
_mbrtowc_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
defined.
* libc/stdlib/wcrtomb.c (wcrtomb): Implement independently from
_wcrtomb_r, unless PREFER_SIZE_OVER_SPEED or __OPTIMIZE_SIZE__ are
defined.
* libc/stdlib/mbtowc_r.c (__utf8_mbtowc): Drop unnecessary test for
ch >= 0.
radix char instead of assuming length 1.
* libc/stdlib/gdtoa-gethex.c: Remove use of USE_LOCALE.
(gethex): Allow multibyte decimal point.
Fix compiler warnings due to different signedness of pointer types.
* libc/stdlib/strtod.c: Remove use of USE_LOCALE.
(_strtod_r): Allow multibyte decimal point.
* libc/stdlib/wcstod.c (_wcstod_r): Evaluate correct wide char
endptr position if the decimal point is a multibyte char.
* libc/include/wchar.h: Include stdarg.h.
(__VALIST): Define conditionally.
(fwprintf, swprintf, vfwprintf, vswprintf, vwprintf, wprintf: Declare.
(_fwprintf_r, _swprintf_r, _vfwprintf_r, _vswprintf_r, _vwprintf_r,
_wprintf_r): Declare.
* libc/stdio/Makefile.am: Add new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwprintf.c: New file.
* libc/stdio/local.h (_svfwprintf_r, _svfiwprintf_r): Declare.
(__CH_CLASS, __STATE, __ACTION): Move definition from vfprintf.c here
and move to the __ namespace.
(__chclass, __state_table, __action_table): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swprintf.c: New file.
* libc/stdio/vfprintf.c (__SPRINT): New macro to call the right
__sprint_r function according to compilation unit. Use throughout.
(__ssprint_r): Rename STRING_ONLY variant from __sprint_r.
Make externaly available. Only define if INTEGER_ONLY is defined.
(__sprint_r): Make externaly available. Only define if INTEGER_ONLY
is defined. Handle stream orientation.
(__sbprintf): Copy FILE's _flags2 member as well.
(__chclass, __state_table, __action_table): Prepend __ to name and
make externally available.
* libc/stdio/vfwprintf.c: New file.
* libc/stdio/vswprintf.c: New file.
* libc/stdio/vwprintf.c: New file.
* libc/stdio/wprintf.c: New file.
* libc/stdio/Makefile.am: Build vfprintf.c and vfscanf.c with
-DSTRING_ONLY defined with and without -DINTEGER_ONLY defined
to build special versions for sprintf/sscanf family functions.
* libc/stdio/Makefile.in: Regenerated.
* libc/stdio/vfprintf.c[STRING_ONLY][INTEGER_ONLY](_VFPRINTF_R):
Redefine to be _svfiprintf_r which is optimized to work with siprintf
family of functions (i.e. no I/O) and does not support floating-point.
[STRING_ONLY][!INTEGER_ONLY](_VFPRINTF_R): Redefine to be
_svfprintf_r which is optimized to work with sprintf family of
functions and not use I/O.
[STRING_ONLY](__sprint_r): New string only version of static function.
designed to work with sprintf family of functions.
* libc/stdio/vfscanf.c[STRING_ONLY][INTEGER_ONLY](_SVFSCANF_R):
Redefine to be _ssvfiscanf_r which is optimized to work with siscanf
family of functions (i.e. no I/O) and no float-point support.
[STRING_ONLY][!INTEGER_ONLY](_SVFSCANF_R): Redefine to be
__ssvfscanf_r which is optimized to work with sscanf family of
functions and does not require I/O functions.
* libc/stdio/asprintf.c: Call _svfprintf_r instead of _vfprintf_r.
* libc/stdio/snprintf.c: Ditto.
* libc/stdio/sprintf.c: Ditto.
* libc/stdio/vasnprintf.c: Ditto.
* libc/stdio/vasprintf.c: Ditto.
* libc/stdio/siprintf.c: Call _svfiprintf_r instead of _vfiprintf_r.
* libc/stdio/sniprintf.c: Ditto.
* libc/stdio/vasiprintf.c: Ditto.
* libc/stdio/vsiprintf.c: Ditto.
* libc/stdio/vsniprintf.c: Ditto.
* libc/stdio/vsprintf.c: Ditto.
* libc/stdio/local.h: Add prototypes for _svfprintf_r, _svfiprintf_r,
_ssvfscanf_r, and _ssvfiscanf_r.
* libc/stdio/sscanf.c: Call _ssvfscanf_r instead of _svfscanf_r.
* libc/stdio/vsscanf.c: Ditto.
* libc/stdio/siscanf.c: Call _ssvfiscanf_r instead of _svfiscanf_r.
* libc/stdio/vsiscanf.c: Ditto.
sizeof(void*) is 8 but sizeof(long) is 4.
* libc/stdio/vfscanf.c (__SVFSCANF_R): Likewise. Fix %i scanning
of "-0x". Support "-nan" and "inf" for %e. Audit usage of ungetc
to fix reentrancy and bug on encoding error in multibyte locales.
Always return EOF on read error.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Fix use of decimal point
in %f. Avoid malloc when possible for %S.
(BUF): Improve stack locality by using smaller size.
(MAXEXPLEN, _PRINTF_FLOAT_TYPE): Define.
(exponent): Use smaller stack size.
* libc/stdio/vfprintf.c (_vfprintf_r): When the alternate-form flag
has been specified with types 'f', 'F', 'g', or 'G', ensure the
trailing decimal is printed.
* libc/include/stdio.h: Add new reentrant I/O prototypes for
read/write functions. Change getc/putc macros to have reentrant underlying
macros/functions. This includes __sgetc_raw_r, __sgetc_r, and __sputc_r.
* libc/stdio/fgetc.c: Fix and/or add reentrant version to call
new reentrant I/O functions/macros for reading/writing.
* libc/stdio/fgets.c: Ditto.
* libc/stdio/fputc.c: Ditto.
* libc/stdio/fputs.c: Ditto.
* libc/stdio/fread.c: Ditto.
* libc/stdio/fseek.c: Ditto.
* libc/stdio64/fseeko64.c: Ditto.
* libc/stdio/fwrite.c: Ditto.
* libc/stdio/getc.c: Ditto.
* libc/stdio/getc_u.c: Ditto.
* libc/stdio/getchar.c: Ditto.
* libc/stdio/getchar_u.c: Ditto.
* libc/stdio/putc.c: Ditto.
* libc/stdio/putc_u.c: Ditto.
* libc/stdio/putchar.c: Ditto.
* libc/stdio/puts.c: Ditto.
* libc/stdio/vfprintf.c: Ditto.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdio/fvwrite.c: Change __sfvwrite into reentrant __sfvwrite_r.
Change all previous callers of __sfvwrite. Set errno to EBADF and
set error flag on if attempt is made to write to file that does not
allow writing.
* libc/stdio/fvwrite.h: Fix new reentrant prototypes.
* libc/stdio/local.h: Ditto.
* libc/stdio/refill.c: Turn __srefill into reentrant __srefill_r.
Set errno to EBADF and the error flag on if attempt is made to
read unreadable file. Change all previous callers of __srefill.
* libc/stdio/rget.c
* libc/stdio/wbuf.c: Turn __swbuf into reentrant __swbuf_r. Change
all previous callers of __swbuf.
* libc/sys/linux/machine/i386/huge_val.h: Ifdef out file contents since
huge value macros are already defined correctly for i386 by <math.h>.
* libc/stdio/vfprintf.c (cvt): Don't rely on pointer aliasing to
determine characteristics of long double. Use a union instead.
* ldtoa.c (_ldtoa_r): Ditto.
(_ldcheck): Ditto.
(_strtold): Ditto.
(union uconv): New union.
* libc/stdio/vfprintf.c: Move newlib.h before _WANT_IO_POS_ARGS test,
since _WANT_IO_POS_ARGS is now defined in there. Remove duplicate
reent.h include.
* libc/include/sys/_types.h: Include <sys/lock.h> and change
_flock_t to be of type _LOCK_RECURSIVE_T.
* libc/include/sys/reent.h: (_REENT_INIT): Reformat.
(_REENT_INIT_PTR): Ditto. Use memset where appropriate.
(_global_impure_ptr): New declaration.
(_GLOBAL_REENT): Change to be _global_impure_ptr.
* libc/include/sys/stdio.h: Include <sys/lock.h> and
<sys/reent.h>.
(_flockfile)[!_SINGLE_THREAD]: Add code for lock call.
(_funlockfile)[!SINGLE_THREAD]: Ditto.
* libc/reent/impure.c: Set _global_impure_ptr to _impure_ptr.
* libc/stdio/fclose.c: Remove casting of fp lock to
_LOCK_RECURSIVE_T.
* libc/stdio/findfp.c: Ditto.
* libc/stdio/fopen.c: Ditto.
* libc/stdio/freopen.c: Ditto.
* libc/stdio/vfprintf.c: Ditto.
* libc/stdio64/fopen64.c: Ditto.
* libc/stdlib/envlock.c: Add default stubs that use generic
locking code.
* libc/stdlib/mlock.c: Ditto.
Jeff Johnston <jjohnstn@redhat.com>
* libc/sys/linux/sys/_types.h (__flock_mutex_t): New subtype.
(_flock_t): Change to be a struct containing a single member
named mutex which is of type __flock_mutex_t.
* newlib.hin: (_WANT_IO_POS_ARGS): New define.
(_WANT_IO_LONG_LONG): Ditto.
(_WANT_IO_LONG_DOUBLE): Ditto.
* configure.in: Add new configuration options
--enable-newlib-io-long-long and --enable-newlib-io-long-double
which tie to new defines in newlib.hin.
* configure: Regenerated.
* configure.host: Add checks for new configuration options. Also
fix up check for --enable-newlib-io-pos-args so configuration
option will override any default for a given platform.
Remove defining compiler flags for the _WANT_IO* options.
* libc/stdio/vfprintf.c: Change to use new newlib.hin defines
instead of looking for old compiler flags.
* libc/stdio/vfscanf.c: Ditto.
* libc/stdio/vfieeefp.h: Ditto.
* libc/machine/powerpc/vfprintf.c: Ditto.
* libc/machine/powerpc/vfscanf.c: Ditto.