Commit Graph

74 Commits

Author SHA1 Message Date
Yaakov Selkowitz 70ee6b17df ansification: remove _EXFUN, _EXFUN_NOTHROW
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:29 -06:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Yaakov Selkowitz 670b01da7f ansification: remove _CAST_VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:17 -06:00
Yaakov Selkowitz e6321aa6a6 ansification: remove _PTR
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:16 -06:00
Yaakov Selkowitz eea249da3b ansification: remove _PARAMS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:13 -06:00
Yaakov Selkowitz 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -06:00
Yaakov Selkowitz 6783860a2e ansification: remove _AND
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:05 -06:00
Corinna Vinschen b7b6b42cd4 newlib: vfscanf: Implement %l[
Just as %lc and %ls, this is only enabled on ELIX_LEVEL >= 2.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01 17:53:59 +01:00
Corinna Vinschen a49209d2bc newlib: vf[w]scanf: Fix conversion multibyte <-> wchar_t
* vfscanf: per POSIX, if the target type is wchar_t, the width is
  counted in (multibyte) characters, not in bytes.

* vfscanf: Handle UTF-8 multibyte sequences converted to surrogate
  pairs on UTF-16 systems.

* vfwscanf: Don't count high surrogates in input against field width
  counting.  Per POSIX, input is

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01 17:18:26 +01:00
Corinna Vinschen 9638c07527 newlib: vf[w]scanf: Drop width computation mixup
The width value keeps the maximum field width.  This is the maximum
field width of the *input*.  It's *never* to be used in conjunction
with the number of bytes or characters written to the output argument.

However, especially in vfwscanf, the code is partially taken from
NetBSD which erroneously subtracts the number of multibyte chars
written to the argument from the width variable, thus potentially
subtracting up to MB_CUR_MAX from width for a single character in
the input stream.

To make matters worse, the previous patch adding %m added basically
the same mistake for 'c' type input.

Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01 13:47:26 +01:00
Yaakov Selkowitz c7ef9668cf stdio: remove TRAD_SYNOPSIS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-12-01 03:41:51 -06:00
Corinna Vinschen d43863f569 newlib: vf[w]scanf: Implement POSIX %m modifier
* The new code is guarded with _WANT_IO_POSIX_EXTENSIONS, but
  this is automatically enabled with _WANT_IO_C99_FORMATS for now.

* vfscanf neglects to implement %l[, so %ml[ is not implemented yet
  either.

* Sidenote: vfwscanf doesn't allow ranges in %[ yet.  Strictly this
  is allowed per POSIX, but it differes from vfscanf as well as from
  glibc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 21:50:23 +01:00
Corinna Vinschen 0fd2c9bd12 newlib: vf[w]scanf: add validity checks
POSIX requires that directive characters appear in a certain sequence:

1. '%' or '%<n>$'
2. optional '*'
3. optional field width digits
4. optional 'm' (not yet implemented)
5. optional length modifier ('l', 'L', 'll', 'h', 'hh', 'j', 't', 'z')
6. conversion specifier ('d', 's', etc)

Add a few basic validity checks to that effect, otherwise reject
directive as match failure.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 11:55:27 +01:00
Corinna Vinschen 31f11d0572 newlib: vf[w]scanf: Use SIZE_MAX rather than ~0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 11:41:36 +01:00
Corinna Vinschen 5e4a1c9c97 newlib: vfscanf: fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 11:41:36 +01:00
Corinna Vinschen 2e328edee4 newlib: vf[w]scanf: Only return from a single point to simplify cleanup
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 11:41:36 +01:00
Corinna Vinschen 1bbdb3c953 newlib: [w]scanf: Fix behaviour on matching failure
The special handling of %\0 in [w]scanf is flawed.  It's just a
matching failure and should be handled as such.  scanf also
fakes an int input value on %X with X being an invalid conversion
char.  This is also just a matching failure and should be handled
the same way as %\0.

There's no indication of the reason for this "disgusting
backwards compatibility hacks" in the logs, given this
code made it into newlib before setting up the CVS repo.

Just handle these cases identically as matching failures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-29 15:01:30 +01:00
Corinna Vinschen d16a56306d Consolidate wctomb/mbtowc calls for POSIX-1.2008
- Remove charset parameter from low level __foo_wctomb/__foo_mbtowc calls.
- Instead, create array of function for ISO and Windows codepages to point
  to function which does not require to evaluate the charset string on
  each call.  Create matching helper functions.  I.e., __iso_wctomb,
  __iso_mbtowc, __cp_wctomb and __cp_mbtowc are functions returning the
  right function pointer now.
- Create __WCTOMB/__MBTOWC macros utilizing per-reent locale and replace
  calls to __wctomb/__mbtowc with calls to __WCTOMB/__MBTOWC.
- Drop global __wctomb/__mbtowc vars.
- Utilize aforementioned changes in Cygwin to get rid of charset in other,
  calling functions and simplify the code.
- In Cygwin restrict global cygheap locale info to the job performed
  by internal_setlocale.  Use UTF-8 instead of ASCII on the fly in
  internal conversion functions.
- In Cygwin dll_entry, make sure to initialize a TLS area with a NULL
  _REENT->_locale pointer.  Add comment to explain why.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen fbace81684 Import correctly working strtold from David M. Gay.
* libc/stdlib/Makefile.am (GENERAL_SOURCES): Add strtodg.c and
	strtorx.c.
	* libc/stdlib/Makefile.in: Regenerate.
	* libc/stdlib/strtodg.c: New file implementing generic string to long
	double conversion.
	* libc/stdlib/strtorx.c: New file, implementing IEEE format string to
	long double conversion.
	* libc/stdlib/mprec.h (_strtodg_r): Declare.
	(_strtorx_r): Declare.
	* libc/stdlib/gdtoa.h (__UShort): Define.
	* libc/stdlib/strtold.c (__flt_rounds): Define for i386 and x86_64
	target.
	(FLT_ROUNDS): Define, as 0 on platforms missing a __flt_rounds
	function.
	(_strtold_r): Converted from strtold.  Call _strtorx_r on targets
	supporting distinct long doubles.
	(strtold): Just call _strtold_r.
	* libc/include/stdlib.h (_strtold_r): Declare.
	* libc/stdlib/ldtoa.c (_strtold): Comment out.  Explain why.
	* libc/stdio/vfscanf.c (__SVFSCANF_R): Call _strtold_r instead of
	_strtold.
	* libc/machine/powerpc/vfscanf.c (__svfscanf_r): Ditto.

	* common.din (strtold): Drop redirection to _strtold.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 18:14:58 +01:00
Corinna Vinschen 576b7804d6 * vfscanf.c (BUF): Change definition to take multibyte decimal point
into account.
	(__SVFSCANF_R): Handle radix char language-dependent
	per POSIX.
	(__SVFWSCANF_R): Ditto.
2013-12-18 19:23:33 +00:00
Jeff Johnston b334e6660a 2013-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/stdio/local.h (CHECK_INIT): Evaluate argument only once.
	(CHECK_STD_INIT): Likewise.
	* libc/stdio/fgetc.c (fgetc): Use local variable for _REENT.
	* libc/stdio/fgetwc.c (fwgetc): Likewise.
	* libc/stdio/fgetws.c (fgetws): Likewise.
	* libc/stdio/fputc.c (fputc): Likewise.
	* libc/stdio/fputwc.c (fputwc): Likewise.
	* libc/stdio/fputws.c (fputws): Likewise.
	* libc/stdio/getc.c (getc): Likewise.
	* libc/stdio/getchar.c (_getchar_r): Likewise.
	* libc/stdio/putc.c (putc): Likewise.
	* libc/stdio/putchar.c (putchar): Likewise.
	* libc/stdio/scanf.c (scanf): Likewise.
	* libc/stdio/setvbuf.c (setvbuf): Likewise.
	* libc/stdio/ungetwc.c (ungetwc): Likewise.
	* libc/stdio/vfscanf.c (VFSCANF): Likewise.
	* libc/stdio/vfwscanf.c (VFWSCANF): Likewise.
	* libc/stdio/viprintf.c (viprintf): Likewise.
	* libc/stdio/viscanf.c (viscanf): Likewise.
	* libc/stdio/vprintf.c (vprintf): Likewise.
	* libc/stdio/vscanf.c (vscanf): Likewise.
	* libc/stdio/vwprintf.c (vwprintf): Likewise.
	* libc/stdio/vwscanf.c (vwscanf): Likewise.
	* libc/stdio/wscanf.c (wscanf): Likewise.
	* libc/stdlib/ecvtbuf.c (fcvtbuf): Likewise.
	(fcvtbuf): Likewise.
	(ecvtbuf): Likewise.
	(ecvtbuf): Likewise.
	* libc/stdlib/mblen.c (mblen): Likewise.
	* libc/stdlib/mbrlen.c (mbrlen): Likewise.
	* libc/stdlib/mbrtowc.c (mbrtowc): Likewise.
	* libc/stdlib/mbtowc.c (mbtowc): Likewise.
	* libc/stdlib/rand.c (srand): Likewise.
	(rand): Likewise.
	* libc/stdlib/wcrtomb.c (wcrtomb): Likewise.
	* libc/stdlib/wctob.c (wctob): Likewise.
	* libc/stdlib/wctomb.c (wctomb): Likewise.
	* libc/string/strtok.c (strtok): Likewise.
	* libc/time/asctime.c (asctime): Likewise.
	* libc/time/gmtime.c (gmtime): Likewise.
	* libc/time/lcltime.c (lcltime): Likewise.
2013-04-29 21:06:23 +00:00
Corinna Vinschen 1f232abc89 Throughout, run newlib with -Wall -Werror option and fix bugs and
compiler warnings found this way.

	* libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags.

	* libc/include/stdio.h (_rename): Define when building newlib.
	* libc/include/sys/signal.h (_kill): Ditto.
	* libc/include/sys/stat.h (_mkdir): Ditto.
	* libc/include/sys/time.h (_gettimeofday): Ditto.
	* libc/include/sys/times.h (_times): Ditto.
	* libc/include/sys/wait.h (_wait): Ditto.
	* libc/locale/lmessages.c (empty): Don't define for Cygwin.
	* libc/locale/lmonetary.c (cnv): Ditto.
	* libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s.
	* libc/posix/collate.c: Throughout cast to avoid compiler warning.
	* libc/posix/engine.c (matcher): Initialize dp to avoid compiler
	warning.
	* libc/posix/glob.c: Disable on Cygwin.  Explain why.
	* libc/posix/regcomp.c: Fix "uninitialized" compiler warnings.
	(dissect): Deliberately silence gcc compiler warning.  Add comment to
	explain why.
	* libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result
	is never used.
	* libc/posix/popen.c (popen): Ditto for variable last.
	* libc/reent/mkdirr.c: Include sys/stat.h.
	* libc/reent/renamer.c: Include stdio.h.
	* libc/search/hash.c:  Throughout use underscored variants of the stat
	function family.
	(init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case.
	* libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid
	compiler warning.
	* libc/search/hash_page.c (overflow_page): Initalize freep to NULL to
	avoid compiler warning.
	* libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char *
	to avoid compiler warning.
	(asiprintf): Ditto.
	* libc/stdio/asprintf.c (_asprintf_r): Ditto.
	(asprintf): Ditto.
	* libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto.
	* libc/stdio/vasprintf.c (_vasprintf_r): Ditto.
	* libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to
	isdigit to avoid compiler warning.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for
	grouping to avoid compiler warning.  Only define and set nseps and
	nrepeats if they are really used.
	* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto.  Only define state if
	it is really used.
	* libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char.
	(__SVFSCANF_R): Cast fmt in call to __mbtowc.
	* libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building
	Cygwin.
	(JIS_action_table): Ditto.
	* libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid
	compiler warning.
	* libc/string/strcasestr.c: Deliberately silence gcc compiler warning.
	Add comment to explain why.
	* libc/time/strptime.c (strptime): Cast to unsigned char in calls to
	isspace to avoid compiler warning.
	* libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid
	compiler warning.
	* libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid
	compiler warning.  Drop setting it to 0 later.
	* libm/math/ef_exp.c (__ieee754_expf): Ditto.
	* libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler
	warning.
	* libm/math/ef_pow.c (__ieee754_powf): Ditto.
	* libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to
	avoid compiler warning.
	* libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto.
	* libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z.
	* libm/common/sf_round.c (roundf): Remove signbit variable since result
	is never used.
2012-08-08 11:04:18 +00:00
Corinna Vinschen 4aa28d8ae2 * libc/stdio/local.h (_newlib_flockfile_start): New macro to
secure stream related critical section against thread cancellation.
	(_newlib_flockfile_exit): Ditto.
	(_newlib_sfp_lock_end): Ditto.
	(_newlib_sfp_lock_start): Ditto for the list of streams.
	(_newlib_sfp_lock_exit): Ditto.
	(_newlib_sfp_lock_end): Ditto.
	Use aforementioned macros in place of _flockfile/_funlockfile
	and __sfp_lock_acquire/__sfp_lock_release throughout the code.
	* libc/stdio/fclose.c: Explicitely disable and re-enable thread
	cancellation.  Explain why.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio64/freopen64.c: Ditto.
2012-05-30 08:58:42 +00:00
Ralf Corsepius 0792b19670 2011-08-23 Ralf Corsépius <ralf.corsepius@rtems.org>
* libc/posix/regexec.c: Define "nope" only #ifndef NDEBUG.
	* libc/stdio/vfscanf.c: Define "state" only #ifdef _MB_CAPABLE.
	* libc/string/wcwidth.c: Include <wctypes.h> for "iswprint" and
	"iswcntrl".
2011-08-23 11:59:56 +00:00
Corinna Vinschen 656df313e0 * libc/stdio/fclose.c: Only use sfp lock to guard non-atomic
changes of flags and fp lock.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio/freopen64.c: Ditto.
	* libc/stdio/fgetc.c: Revert change from 2009-04-24, remove sfp locks
	which guard entire function to avoid potential deadlocks when using
	stdio functions in multiple thraeds.
	* libc/stdio/fgets.c: Ditto.
	* libc/stdio/fgetwc.c: Ditto.
	* libc/stdio/fgetws.c: Ditto.
	* libc/stdio/fread.c: Ditto.
	* libc/stdio/fseek.c: Ditto.
	* libc/stdio/getc.c: Ditto.
	* libc/stdio/getdelim.c: Ditto.
	* libc/stdio/gets.c: Ditto.
	* libc/stdio/vfscanf.c: Ditto.
	* libc/stdio/vfwscanf.c: Ditto.

	* libc/stdio/fflush.c (_fflush_r): Split out core functionality into
	new function __sflush_r.  Just lock file and call __sflush_r from here.
	* libc/stdio/fwalk.c (_fwalk): Remove static helper function and move
	functionality back into main function. Don't walk a file with flags
	value of 1.  Add comment.
	(_fwalk_reent): Ditto.
	* libc/stdio/local.h (__sflush_r): Declare.
	* libc/stdio/refill.c (__srefill): Before calling fwalk, set flags
	value to 1 so this file pointer isn't walked.  Revert flags afterwards
	and call __sflush_r for this fp if necessary.  Add comments.
2011-01-28 10:49:11 +00:00
Jeff Johnston 044cd63533 2010-01-19 Andy Koppe <andy.koppe@gmail.com>
* libc/stdio/vfscanf.c (__SVFSCANF_R): Fix handling of non-ASCII
        characters and allow invalid bytes in format string.
2010-01-19 23:16:45 +00:00
Corinna Vinschen b4fee5273e * libc/stdio/vfprintf.c: Include ../stdlib/local.h. Replace call to
_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.
2009-11-18 09:49:57 +00:00
Corinna Vinschen d0b85c158f * libc/include/wchar.h (fwscanf, swscanf, vfwscanf, vswscanf, vwscanf,
wscanf): Declare.
	(_fwscanf_r, _swscanf_r, _vfwscanf_r, _vswscanf_r, _vwscanf_r,
	_wscanf_r): Declare.
	* libc/stdio/Makefile.am: Add new wscanf files.
	* libc/stdio/Makefile.in: Regenerate.
	* libc/stdio/fwscanf.c: New file.
	* libc/stdio/local.h (__svfwscanf_r, __ssvfwscanf_r, __svfiwscanf_r,
	__ssvfiwscanf_r): Declare.
	* libc/stdio/stdio.tex: Add new documentation references.
	* libc/stdio/swscanf.c: New file.
	* libc/stdio/vfwscanf.c: New file.
	* libc/stdio/vswscanf.c: New file.
	* libc/stdio/vwscanf.c: New file.
	* libc/stdio/wscanf.c: New file.

	* libc/stdio/vfscanf.c (_sungetc_r): Make externaly available.  Only
	define if INTEGER_ONLY is defined.  Declare otherwise.
	(__ssrefill_r): Ditto.
	(_sfread_r): Ditto.

	Remove static eofread/eofread1 functions and use __seofread
	function instead, throughout.
	* libc/stdio/local.h (__seofread): Declare.
	* libc/stdio/stdio.c (__seofread): Define.

	* libc/stdio/fgetwc.c (__fgetwc): Fix compiler warning.
	* libc/stdio/fgetws.c (_fgetws_r): Ditto.
	* libc/stdio/fread.c (_fread_r): Ditto.
	* libc/stdio/vfprintf.c: Ditto.
	* libc/stdio/vswprintf.c: Ditto.
2009-03-11 11:53:22 +00:00
Jeff Johnston 3e703e875a 2009-01-28 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfscanf.c (__SVFSCANF_R): Add additional check for
        inf and nan processing to not proceed if we have already collected
        zeroes.
2009-01-28 18:12:52 +00:00
Jeff Johnston 7dd0c33097 2008-12-11 Craig Howland <howland@LGSInnovations.com>
* libc/include/sys/lock.h:  Add void cast to avoid "statement has no
        effect" warnings from gcc.
        * libc/include/sys/stdio.h:  Ditto.
        * libc/include/sys/time.h:  Correct gettimeofday() prototype.
        * libc/stdlib/__exp10.c:  Add #include "std.h" for function prototype.
        * libc/stdlib/__ten_mu.c:  Ditto.
        * libc/stdlib/std.h:  Correct __exp10's ANSI prototype.
        * libc/stdlib/ldtoa.c:  Change eiisinf definition to ANSI form.  (Are
        already others in file without _ansi method, so did not bother.)
        * libc/stdlib/system.c:  Use _ansi forms for function prototypes and
        definitions.
        * libc/time/mktime.c:  Ditto.
        * libc/misc/__dprintf.c:  Ditto.
        * libc/include/stdio.h:  Add function prototypes for _fgetc_r,
        _fgetpos_r, _fsetpos_r, _freopen_r, _rewind_r, freopen64, _freopen64_r,
        _funopen_r, and _fopencookie_r.
        * libc/include/reent.h:  Add function prototype for _stat64_r, align
        _execve_r prototype with POSIX definition for execve.
        * libc/reent/execr.c:  Align function prototype with POSIX definition.
        * libc/stdio/asniprintf.c:  Add #include "local.h".
        * libc/stdio/vasniprintf.c:  Ditto.
        * libc/stdio/fread.c:  Remove unused variable newcount.
        * libc/stdio/local.h:  Add function prototype for __sccl.
        * libc/stdio/open_memstream.c:  Remove unused variable flags.
        * libc/stdio/vfscanf.c:  Proper prototyping for ccfn, remove prototype
        for __sccl since now in local.h.
        * libc/string/memcpy.c:  Add #include <string.h> (for real and for
        traditional synopsis), remove extraneous stddef.h and limits.h.
        * libc/syscalls/sysclose.c:  Add #include <unistd.h>.
        * libc/syscalls/sysfork.c:  Ditto.
        * libc/syscalls/sysgetpid.c:  Ditto.
        * libc/syscalls/sysexecve.c:  Add #include <unistd.h>, align function
        prototype with POSIX definition.
        * libc/syscalls/sysfstat.c:  Add #include <sys/stat.h>.
        * libc/syscalls/sysgettod.c:  Correct sys/times.h to sys/time.h.
        * libc/syscalls/syskill.c:  Add #include <signal.h>.
        * libc/syscalls/syslink.c:  Add #include <unistd.h>, fix prototype.
        * libc/syscalls/sysunlink.c:  Ditto.
        * libc/syscalls/sysstat.c:  Add #include <sys/stat.h>, fix prototype.
        * libc/syscalls/syswait.c:  Add #include <sys/wait.h>, fix prototype.
2008-12-11 17:27:56 +00:00
Jeff Johnston 0751f22675 2008-12-10 Corinna Vinschen <corinna@vinschen.de>
Implement basic wide char stdio functionality, based on FreeBSD.
        * libc/include/stdio.h (__SORD): Define.
        (__SWID): Define.
        * libc/include/wchar.h: Add declarations for new wide char functions.
        (getwc): Define as macro.
        (getwchar): Ditto.
        (putwc): Ditto.
        (putwchar): Ditto.
        * libc/include/sys/reent.h (struct __sFILE): Add _mbstate member.
        (struct __sFILE64): Ditto.
        * libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c, fgetws.c,
        fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c, putwchar.c
        and ungetwc.c.
        (CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def, fputws.def,
        fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
        ungetwc.def.
        Add header dependency rules for the new files.
        * libc/stdio/Makefile.in: Regenerate.
        * libc/stdio/fgetwc.c: New file, implementing fgetwc and _fgetwc_r.
        * libc/stdio/fgetws.c: New file, implementing fgetws and _fgetws_r.
        * libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
        (__sfmoreglue): Ditto.
        * libc/stdio/fputs.c (_fputs_r): Set stream orientation.
        * libc/stdio/fputwc.c: New file, implementing fputwc and _fputwc_r.
        * libc/stdio/fputws.c: New file, implementing fputws and _fputws_r.
        * libc/stdio/fread.c (_fread_r): Set stream orientation.
        * libc/stdio/freopen.c (_freopen_r): Reset stream orientation.  Reset
        _mbstate.
        * libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
        * libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
        * libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
        * libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
        * libc/stdio/getwchar.c: New file, implementing getwchar and
        _getwchar_r.
        * libc/stdio/local.h (ORIENT): New macro.
        * libc/stdio/puts.c (_puts_r): Set stream orientation.
        * libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
        * libc/stdio/putwchar.c: New file, implementing putwchar and
        _putwchar_r.
        * libc/stdio/refill.c (__srefill_r): Set stream orientation.
        * libc/stdio/stdio.tex: Add documentation for new functions.
        * libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
        * libc/stdio/ungetwc.c: New file, implementing ungetwc and _ungetwc_r.
        * libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
        * libc/stdio/wbuf.c (__swbuf_r): Ditto.
2008-12-10 23:43:12 +00:00
Corinna Vinschen 14773e10a0 * libc/include/stdio.h (__SMOD): Remove definition of unused flag.
* libc/include/sys/reent.h (struct __sFILE): Add _flags2 member.
	* libc/stdio/findfp.c (std): Initialize _flags2.
	(__sfp): Ditto.
	* libc/stdio/refill.c (__srefill_r): Drop resetting __SMOD flag.
	* libc/stdio/vfscanf.c (__ssrefill_r): Ditto.
	* libc/stdio/fseek.c (_fseek_r): Drop checking __SMOD flag.
	* libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
2008-11-24 17:15:43 +00:00
Jeff Johnston 1dc1ccd4ae 2008-10-31 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/diprintf.c: Modify documentation so eclipse newlib
        libhover docs generate properly.
        * libc/stdio/dprintf.c: Ditto.
        * libc/stdio/fflush.c: Ditto.
        * libc/stdio/fopencookie.c: Ditto.
        * libc/stdio/fread.c: Ditto.
        * libc/stdio/fsetpos.c: Ditto.
        * libc/stdio/getc_u.c: Ditto.
        * libc/stdio/getchar_u.c: Ditto.
        * libc/stdio/putc_u.c: Ditto.
        * libc/stdio/putchar_u.c: Ditto.
        * libc/stdio/remove.c: Ditto.
        * libc/stdio/siprintf.c: Ditto.
        * libc/stdio/siscanf.c: Ditto.
        * libc/stdio/sprintf.c: Ditto.
        * libc/stdio/sscanf.c: Ditto.
        * libc/stdio/vfprintf.c: Ditto.
        * libc/stdio/vfscanf.c: Ditto.
        * libc/stdio/viprintf.c: Ditto.
        * libc/stdio/viscanf.c: Ditto.
        * libc/stdlib/calloc.c: Ditto.
        * libc/stdlib/efgcvt.c: Ditto.
        * libc/stdlib/envlock.c: Ditto.
        * libc/time/asctime.c: Ditto.
        * libc/time/ctime.c: Ditto.
        * libc/time/gmtime.c: Ditto.
        * libc/time/lcltime.c: Ditto.
        * libc/time/tzset.c: Ditto.
        * libc/stdlib/envlock.h: Moved to libc/include.
2008-10-31 21:08:03 +00:00
Jeff Johnston 236e5c4017 2008-10-15 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfscanf.c (__ssvfiscanf_r): Do not support %lc, %C, %ls or
	%S conversions when the EL/IX level is 1.
2008-10-15 19:33:10 +00:00
Jeff Johnston eabd7de028 2008-04-14 Jeff Johnston <jjohnstn@redhat.com>
* 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.
2008-04-14 21:14:55 +00:00
Eric Blake 391b530a05 Fix 'make info'.
* libc/stdio/stdio.tex: Add missing include.
* libc/stdio/vfprintf.c: Use expected node name.
* libc/stdio/vfscanf.c: Likewise.
* libc/stdio/sscanf.c: Likewise.
* libc/stdio/sprintf.c: Likewise.
* libc/stdio/siscanf.c: Likewise.
* libc/stdio/siprintf.c: Likewise.
* libc/stdio/fopencookie.c: Quote raw {}.
Reported by DJ Delorie.
2007-07-19 03:42:21 +00:00
Eric Blake aa5341f9ac * libc/stdio/vfprintf.c (_VFPRINTF_R): Don't truncate %p when
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.
2007-05-24 04:25:18 +00:00
Eric Blake 9a3ec8622b * libc/stdio/vfscanf.c (__SVFSCANF_R): Support scanf(%1$s).
Avoid warning when !FLOATING_POINT.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Simplify _NO_POS_ARGS
slightly.
2007-05-23 20:36:28 +00:00
Eric Blake 8aab2bc260 * libc/stdio/vfprintf.c [_WANT_IO_LONG_LONG]: Allow non-gcc
compilers.
* libc/stdio/vfscanf.c: Likewise.
2007-05-18 14:33:30 +00:00
Eric Blake 0962fe9178 Minimize printf/scanf size on platforms that don't need C99.
* acconfig.h (_WANT_IO_C99_FORMATS): New macro.
* newlib.hin (_WANT_IO_C99_FORMATS): Likewise.
* configure.in (newlib-io-c99-formats): New configure option.
(_WANT_IO_C99_FORMATS): Define appropriately.
* configure.host (*-linux*, cygwin): Default c99-formats to yes.
* libc/stdio/vfprintf.c (_VFPRINTF_R) [!_WANT_IO_C99_FORMATS]:
Cripple ' flag; hh, z, j, t sizes; a, A, F, C, S specifiers.
* libc/stdio/vfscanf.c (_VFSCANF_R) [!_WANT_IO_C99_FORMATS]:
Likewise.
* configure: Regenerate.
2007-05-11 20:09:00 +00:00
Jeff Johnston fb5750bfb4 2007-04-17 Brian Dessent <brian@dessent.net>
* libc/stdio/sscanf.c: Update documentation comments.
        * libc/stdio/vfscanf.c (__SVFSCANF_R): Handle j, t, and z modifiers.
2007-04-17 20:53:24 +00:00
Jeff Johnston e5e148d15b 2006-09-26 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h[_REENT_SMALL]: Do not allow macros
        for clearerr, feof, or fileno.
        * libc/include/sys/reent.h[_REENT_SMALL](struct _reent): Change
        the dummy std stream scheme to use pointers to const external
        fake files, one for each standard stream.
        * libc/stdio/local.h (CHECK_INIT): Change to take a file pointer
        argument.  For _REENT_SMALL, reset the file pointer if it
        matches one of the fake std stream pointers.
        * libc/stdio/clearerr.c: Fix CHECK_INIT macro to add file pointer
        argument.
        * libc/stdio/fclose.c: Ditto.
        * libc/stdio/feof.c: Ditto.
        * libc/stdio/ferror.c: Ditto.
        * libc/stdio/fflush.c: Ditto.
        * libc/stdio/fgetc.c: Ditto.
        * libc/stdio/fgets.c: Ditto.
        * libc/stdio/fileno.c: Ditto.
        * libc/stdio/findfp.c: Ditto.
        * libc/stdio/fputc.c: Ditto.
        * libc/stdio/fputs.c: Ditto.
        * libc/stdio/fread.c: Ditto.
        * libc/stdio/freopen.c: Ditto.
        * libc/stdio/fseek.c: Ditto.
        * libc/stdio/ftell.c: Ditto.
        * libc/stdio/fwrite.c: Ditto.
        * libc/stdio/getc.c: Ditto.
        * libc/stdio/getdelim.c: Ditto.
        * libc/stdio/putc.c: Ditto.
        * libc/stdio/refill.c: Ditto.
        * libc/stdio/setvbuf.c: Ditto.
        * libc/stdio/ungetc.c: Ditto.
        * libc/stdio/vfprintf.c: Ditto.
        * libc/stdio/vfscanf.c: Ditto.
        * libc/stdio/wbuf.c: Ditto.: Ditto.
        * libc/stdio/wsetup.c: Ditto.
        * libc/stdio64/freopen64.c: Ditto.
        * libc/stdio64/fseeko64.c: Ditto.
        * libc/stdio64/ftello64.c: Ditto.
        * libc/machine/powerpc/vfprintf.c: Ditto.
        * libc/machine/powerpc/vfscanf.c: Ditto.
2006-09-26 21:22:19 +00:00
Jeff Johnston 4dc0c0c4e5 2006-06-14 Jeff Johnston <jjohnstn@redhat.com>
* 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>.
2006-06-14 20:49:11 +00:00
Jeff Johnston 884c0ff016 2005-10-28 Bob Wilson <bob.wilson@acm.org>
* libc/stdio/siprintf.c: Wrap long lines in ANSI_SYNOPSIS.
        * libc/stdio/siscanf.c: Likewise.
        * libc/stdio/sprintf.c: Likewise.
        * libc/stdio/sscanf.c: Likewise.
        * libc/stdio/vfprintf.c: Likewise.
        * libc/stdio/vfscanf.c: Likewise.
        * libc/stdio/viprintf.c: Likewise.
        * libc/stdio/viscanf.c: Likewise.
2005-10-28 21:38:59 +00:00
Jeff Johnston 5456408b84 2005-04-28 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfscanf.c (__svfscanf_r): Fix code thinko
        when checking for multiple flags.
2005-04-28 18:26:08 +00:00
Jeff Johnston 85da703991 2005-04-05 Dave Korn <dave.korn@artimi.com>
* libc/stdio/vfscanf.c (__svfscanf_r): If an error occurs processing
        something that looks like a "NaN", put back the characters processed.
2005-04-05 18:38:09 +00:00
Jeff Johnston 1159e0fd94 2005-02-07 Antony King <antony.king@st.com>
* libc/stdio/clearerr.c (clearerr): Ensure CHECK_INIT() is
        called before _flockfile to prevent lock object use before
        initialisation. _REENT_SMALL_CHECK_INIT() and CHECK_INIT()
        take a struct _reent * instead of a FILE *.
        * libc/stdio/fclose.c (_fclose_r): Ditto.
        * libc/stdio/feof.c (feof): Ditto.
        * libc/stdio/ferror.c (ferror): Ditto.
        * libc/stdio/fflush.c (fflush): Ditto.
        * libc/stdio/fgetc.c (fgetc): Ditto.
        * libc/stdio/fgets.c (fgets): Ditto.
        * libc/stdio/fileno.c (fileno): Ditto.
        * libc/stdio/fputc.c (fputc): Ditto.
        * libc/stdio/fputs.c (fputs): Ditto.
        * libc/stdio/fread.c (fread): Ditto.
        * libc/stdio/freopen.c (_freopen_r): Ditto.
        * libc/stdio/fseek.c (_fseek_r): Ditto.
        * libc/stdio/ftell.c (_ftell_r): Ditto.
        * libc/stdio/fwrite.c (fwrite): Ditto.
        * libc/stdio/getc.c (getc): Ditto.
        * libc/stdio/getdelim.c (__getdelim): Ditto.
        * libc/stdio/putc.c (putc): Ditto.
        * libc/stdio/setvbuf.c (setvbuf): Ditto.
        * libc/stdio/ungetc.c (_ungetc_r): Ditto.
        * libc/stdio/vfprintf.c (_VFPRINTF_R): Ditto.
        * libc/stdio64/freopen64.c (_freopen64_r): Ditto.
        * libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
        * libc/stdio64/ftello64.c (_ftello64_r): Ditto.
        * libc/stdio/local.h (CHECK_INIT): Argument is now a struct
        _reent * instead of a FILE * and so replace incorrect use of
        _REENT with argument.
        * libc/sys/arm/syscalls.c (CHECK_INIT): Ditto.
        * libc/stdio/getchar.c (getchar): _REENT_SMALL_CHECK_INIT() and
        CHECK_INIT() take a struct _reent * instead of a FILE *.
        * libc/stdio/iprintf.c (iprintf, _iprintf_r): Ditto.
        * libc/stdio/iscanf.c (iscanf, _iscanf_r): Ditto.
        * libc/stdio/perror.c (perror): Ditto.
        * libc/stdio/printf.c (printf, _printf_r): Ditto.
        * libc/stdio/putchar.c (putchar): Ditto.
        * libc/stdio/puts.c (puts): Ditto.
        * libc/stdio/refill.c (__srefill): Ditto.
        * libc/stdio/scanf.c (scanf, _scanf_r): Ditto.
        * libc/stdio/vfscanf.c (VFSCANF, _VFSCANF_R): Ditto.
        * libc/stdio/viprintf.c (viprintf, _viprintf_r): Ditto.
        * libc/stdio/viscanf.c (viscanf, _viscanf_r): Ditto.
        * libc/stdio/vprintf.c (vprintf, _vprintf_r): Ditto.
        * libc/stdio/vscanf.c (vscanf, _vscanf_r): Ditto.
        * libc/stdio/wbuf.c (__swbuf): Ditto.
        * libc/stdio/wsetup.c (__swsetup): Ditto.
        * libc/stdlib/mallocr.c (malloc_stats): Ditto.
        * libc/stdlib/mstats.c (_mstats_r): Ditto.
        * libc/include/sys/reent.h (_REENT_SMALL_CHECK_INIT): Ditto.
        * libc/machine/powerpc/vfscanf.c (vfscanf): Ditto.
        * libc/stdio/fgetpos.c (_fgetpos_r): Removed unnecessary calls
        to _flockfile and _funlockfile; rely on locking in _ftell_r.
        * libc/stdio64/fgetpos64.c (_fgetpos64_r): Ditto (_ftello64_r).
        * libc/machine/powerpc/vfprintf.c (__sbprintf): Removed unnecessary
        initialision of _data field in FILE structure.
        * libc/machine/powerpc/vfprintf.c (VFPRINTF): Added CHECK_INIT() call.
2005-02-08 01:33:19 +00:00
Jeff Johnston 8fa6cb9a5d 2005-01-06 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/strtod.c (_strtod_r): Add NaN support.
        * (strtof): Ditto.
        * libc/stdio/vfscanf.c (__svfscanf_r): Ditto.
        * Makefile.am (MATHOBJS_IN_LIBC): Add s_nan and sf_nan
        functions for use by strtod and strtof.
        * Makefile.in: Regenerated.
2005-01-06 23:31:56 +00:00
Jeff Johnston 3bf091476a 2004-11-23 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h: Add new iprintf and iscanf variants.  Also
        do some reordering.
        * libc/machine/powerpc/vfscanf.c: Remove __sccl function.
        * libc/stdio/Makefile.am: Add support for new iprintf and iscanf
        family functions.
        * libc/stdio/Makefile.in: Regenerated.
        * libc/stdio/fiprintf.c: Remove doc to siprintf.c.
        * libc/stdio/iprintf.c: Ditto.
        * libc/stdio/local.h (__svfiscanf_r): New prototype.
        * libc/stdio/siprintf.c: Add docs for various iprintf family functions.
        * libc/stdio/sniprintf.c: Move docs to siprintf.c.
        * libc/stdio/stdio.tex: Add new functions.
        * libc/stdio/vfscanf.c: Split out __sccl function to separate
        file and add special name defines so this file can be used
        to build vfiscanf.o.
        * libc/stdio/asiprintf.c: New file.
        * libc/stdio/fiscanf.c: Ditto.
        * libc/stdio/iscanf.c: Ditto.
        * libc/stdio/sccl.c: Ditto.
        * libc/stdio/siscanf.c: Ditto.
        * libc/stdio/vasiprintf.c: Ditto.
        * libc/stdio/viprintf.c: Ditto.
        * libc/stdio/viscanf.c: Ditto.
        * libc/stdio/vsiprintf.c: Ditto.
        * libc/stdio/vsiscanf.c: Ditto.
        * libc/stdio/vsniprintf.c: Ditto.
2004-11-24 00:45:41 +00:00
Jeff Johnston 3ea9de7644 2004-10-04 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/vfscanf.c (__svfscanf_r): For int conversions,
        count skipped zero characters as part of the nread count for %n.
        * libc/machine/powerpc/vfscanf.c: Ditto.
2004-10-04 17:51:50 +00:00