aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio
AgeCommit message (Collapse)AuthorFilesLines
2018-12-13nano-vfprintf_float.c: Fix check if negative for nans.Jon Beniston1-1/+2
2018-08-29Use nanf("") instead of nanf(NULL)Keith Packard3-3/+3
Newer GCC versions require a non-NULL argument to this function for some reason. Signed-off-by: Keith Packard <keithp@keithp.com>
2018-08-08newlib: fix various gcc warningsCorinna Vinschen1-1/+1
* unused variables * potentially used uninitialized * suggested bracketing * misleading indentation Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-17Print sign of NaN values to nano-vfprintf.Kumar Gala1-0/+2
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-07-05Fix newlib functions perror()/psignal() not to use writev().Takashi Yano1-19/+21
This fix is for some platforms which do not have writev(). *perror.c: Use _write_r() instead of writev(). *psignal.c: Use write() insetad of writev(). Revise commit: d4f4e7ae1be1bcf8c021f2b0865aafc16b338aa3
2018-07-04Fix a bug of perror()/psignal() that changes the orientation of stderr.Takashi Yano1-5/+27
* perror.c: Fix the problem that perror() changes the orientation of stderr to byte-oriented mode if stderr is not oriented yet. * psignal.c: Ditto.
2018-03-01Add global stdio streams support for reent small.Our Air Quality2-8/+14
2018-02-01Fix vprintf and vfscanf for GCC PR 14577Jon Beniston2-33/+24
2018-01-17ansification: remove _HAVE_STDCYaakov Selkowitz18-306/+0
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _EXFUN, _EXFUN_NOTHROWYaakov Selkowitz26-157/+157
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _EXFNPTR, _EXPARMYaakov Selkowitz1-1/+1
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _DEFUNYaakov Selkowitz131-634/+317
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _VOIDYaakov Selkowitz9-27/+27
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _DEFUN_VOIDYaakov Selkowitz7-13/+13
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _CAST_VOIDYaakov Selkowitz11-17/+17
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _PTRYaakov Selkowitz20-42/+42
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _PARAMSYaakov Selkowitz6-15/+15
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _DOTSYaakov Selkowitz19-38/+38
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _CONSTYaakov Selkowitz47-168/+168
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _ANDYaakov Selkowitz114-525/+525
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-09newlib: fvprintf: fix get_arg for !_MB_CAPABLEIvan Grokhotkov1-0/+2
Code path for _MB_CAPABLE scans for the '%' character and advances 'fmt' pointer past '%'. Code path for !_MB_CAPABLE leaved fmt pointing to '%', which caused the state machine to go from START to DONE state immediately.
2018-01-08fix incompatible pointer type for va_list in nano versions of printf and ↵Alexander Fedotov2-5/+24
scanf for target like PowerPC
2017-12-18newlib: ftello{64}: Handle appending stream without fflushingCorinna Vinschen1-7/+13
Neither upstream FreeBSD nor glibc ever call fflush from ftell and friends. In border cases it has the tendency to return wrong or unexpected values, for instance on block devices. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-18newlib: ftello{64}: Fix type of returned valueCorinna Vinschen1-4/+4
Especially don't just use -1L since _off_t/_off64_t are not guaranteed to be of type long. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-07makedoc: make errors visibleJon Turney1-3/+3
Discard QUICKREF sections, rather than writing them to stderr Discard MATHREF sections, rather than discarding as an error Pass NOTES sections through to texinfo, rather than discarding as an error Don't redirect makedoc stderr to .ref file Remove makedoc output on error Remove .ref files from CLEANFILES Regenerate Makefile.ins Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-12-04newlib: vfwscanf: fix negation bug in %[ conversionCorinna Vinschen1-1/+1
Old BSD bug: While ^ is recognized and the set of matching characters is negated, the code neglects to increment the pointer pointing to the matching characters. Thus, on a negation expression like %[^xyz], the matching doesn't only stop at x, y, or z, but incorrectly also on ^. Fix this by setting the start pointer after recognizing the ^. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01newlib: vfscanf: Implement %l[Corinna Vinschen1-2/+88
Just as %lc and %ls, this is only enabled on ELIX_LEVEL >= 2. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01newlib: vf[w]scanf: Fix conversion multibyte <-> wchar_tCorinna Vinschen2-25/+53
* 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-01newlib: vf[w]scanf: Drop width computation mixupCorinna Vinschen2-70/+44
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-01stdio: remove TRAD_SYNOPSISYaakov Selkowitz75-1022/+75
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30newlib: vf[w]scanf: Implement POSIX %m modifierCorinna Vinschen2-24/+448
* 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-30newlib: vfwscanf: fix miscomputation of max field width in %[] caseCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30newlib: vf[w]scanf: add validity checksCorinna Vinschen2-0/+37
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-30newlib: vf[w]scanf: Use SIZE_MAX rather than ~0Corinna Vinschen2-4/+4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30newlib: vfscanf: fix formattingCorinna Vinschen1-2/+2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30newlib: vf[w]scanf: Only return from a single point to simplify cleanupCorinna Vinschen2-4/+2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-29newlib: [w]scanf: Fix behaviour on matching failureCorinna Vinschen2-22/+3
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-07-28stdio: Fix make rule overrideSebastian Huber2-10/+0
The Makefile.am contained two rules for the vfwscanf object. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-30Enable _REENT_GLOBAL_STDIO_STREAMS for RTEMSSebastian Huber1-1/+1
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-30Introduce _REENT_GLOBAL_STDIO_STREAMSSebastian Huber1-0/+24
In Newlib, the stdio streams are defined to thread-specific pointers _reent::_stdin, _reent::_stdout and _reent::_stderr. In case _REENT_SMALL is not defined, then these pointers are initialized via _REENT_INIT_PTR() or _REENT_INIT_PTR_ZEROED() to thread-specific FILE objects provided via _reent::__sf[3]. There are two problems with this (at least in case of RTEMS). (1) The thread-specific FILE objects are closed by _reclaim_reent(). This leads to problems with language run-time libraries that provide wrappers to the C/POSIX stdio streams (e.g. C++ and Ada), since they use the thread-specific FILE objects of the initialization thread. In case the initialization thread is deleted, then they use freed memory. (2) Since thread-specific FILE objects are used with a common output device via file descriptors 0, 1 and 2, the locking at FILE object level cannot ensure atomicity of the output, e.g. a call to printf(). Introduce a new Newlib configuration option _REENT_GLOBAL_STDIO_STREAMS to enable the use of global stdio FILE objects. As a side-effect this reduces the size of struct _reent by more than 50%. The _REENT_GLOBAL_STDIO_STREAMS should not be used without _STDIO_CLOSE_PER_REENT_STD_STREAMS. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-30Add stdin_init(), stdout_init() and stderr_init()Sebastian Huber1-17/+33
This simplifies further changes in this area. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-30Remove superfluous parameter from std()Sebastian Huber1-7/+6
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-19Revert "Don't overread or write memory returned by _DTOA_R"Corinna Vinschen1-13/+12
This reverts commit efaef1bba263501e1e7264833ddfc9b8c20f9ebc.
2017-06-09Don't overread or write memory returned by _DTOA_RSilviu Baranga1-12/+13
Don't over-read memory returned by _DTOA_R, and never write to it since the result might be a string literal. For example, when doing: swprintf(tt, 20, L"%.*f", 6, 0.0); we will get back "0". Instead, write the result returned by _DTOA_R to the output buffer. After this, write the 0 chars directly to the the output buffer (if there are any). This also has the (marginal) advantage that we read/write less memory overall.
2017-06-07Print sign of NaN values.Kito Cheng2-0/+8
2017-04-18Add __packed to struct ldieeeKito Cheng1-8/+9
- We don't want any padding in struct ldieee, otherwise the offset might wrong in most compiler.
2017-04-03Use enum __packed in favour of -fshort-enumsSebastian Huber3-41/+46
Some architectures like ARM encode the short enum option state in the object file and the linker checks that this option is consistent for all objects of an executable. In case applications use -fno-short-enums, then this leads to linker warnings. Use the enum __packed attribute for the relevent enums to avoid the -fshort-enums compiler option. This attribute is at least available on GCC, LLVM/clang and the Intel compiler. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-02-06Unify names of all lock objectsFreddie Chopin1-6/+6
In preparation for the patch that would allow retargeting of locking routines, rename all lock objects to follow this pattern: "__<name>_[recursive_]mutex". Following locks were renamed: __dd_hash_lock -> __dd_hash_mutex __sfp_lock -> __sfp_recursive_mutex __sinit_lock -> __sinit_recursive_mutex __atexit_lock -> __atexit_recursive_mutex _arc4random_mutex -> __arc4random_mutex __env_lock_object -> __env_recursive_mutex __malloc_lock_object -> __malloc_recursive_mutex __atexit_mutex -> __at_quick_exit_mutex __tz_lock_object -> __tz_mutex
2016-12-152016-12-15 Giuseppe Musumeci <giuseppe.musumeci@broadcom.com>Jeff Johnston1-2/+2
__sinit initialises some common file descriptors as line buffered and relies on the first users of such FDs to call __smakebuf_r. If __smakebuf_r realises there's no space for a buffer (malloc returns NULL), it makes them unbuffered. However, while setting the __SNBF bit, it doesn't clear the __SLBF bit in the flags. Depending on the order in which functions check buffering flags in the FD, sometime they assume it's line buffered (e.g. __sfvwrite_r), trashing application memory that's not really been allocated to them. This patch solves the problem by clearing the unbuffered/line buffered flag when setting the line buffered/unbuffered flag.
2016-10-22Fix a potential buffer overflow in wscanf familyCorinna Vinschen1-6/+8
Fixes Coverity CID 60046 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>