summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
AgeCommit message (Collapse)Author
2018-01-02some grammar fixes; from dholland@netbsd, -r1.68Jason McIntyre
2017-12-08Fix the return value of fwscanf(3) when encountering an early matchingKevin Lo
failure. This change brings fwscanf(3) back in line with fscanf(3). From FreeBSD; ok deraadt@, millert@
2017-12-01Consistently .Xr the corresponding wide char functions from char- andIngo Schwarze
string-handling <stdio.h> functions, like we already do it for <string.h>. Includes a smaller patch from <kshe59 at zoho dot eu>, OK jmc@.
2017-12-01add missing argument name; from <kshe59 at zoho dot eu>; OK jmc@;Ingo Schwarze
while here, consistently use .Fo to cure execessive line lengths
2017-11-28GNU ld has prefixed the contents of .gnu.warning.SYMBOL sectionsTheo Buehler
with "warning: " since 2003, so the messages themselves need not contain the prefix anymore. From Scott Cheloha ok jca, deraadt
2017-11-21Use a simple forward search to find '%' in the format string instead ofTheo Buehler
using mbrtowc(3). Thus, we now treat the format string as a bytestring, not as a multibyte character string. We think that ANSI C made a small error when adding wide characters: The committees essentially replaced "characters" with "wide characters" in the existing printf documentation, which was written before the concept of processing was established. Doing processing on the format string would break some 8-bit format strings in the wild, and that isn't something these committees gave themselves license to do. Based on the "10x printf speedup" commit from android found by tedu: https://github.com/aosp-mirror/platform_bionic/commit/5305a4d4a723b06494b93f2df81733b83a0c46d3 Thanks to millert and schwarze for digging into the history and testing *printf behavior on other platforms. ok deraadt, millert
2017-11-16Add error checking to some calls to __find_arguments(). Matches similarTheo Buehler
changes by schwarze to vfprintf.c r1.71. Cherrypicked from android: https://github.com/aosp-mirror/platform_bionic/commit/5305a4d4a723b06494b93f2df81733b83a0c46d3 ok millert
2017-10-17add missing HISTORY; based on CVS logs and release announcementsIngo Schwarze
2017-08-15fmt0 is a wchar_t *, so use %ls to reportTheo de Raadt
2017-07-22Favor err() over perror() in example.anton
ok schwarze@
2017-07-041. mild deprecation noticeIngo Schwarze
2. point to getline (suggested by nicm@) 3. cross reference fgetc(3) rather than putc(3) 4. add missing error handling to the example code OK nicm@
2017-06-12Add dprintf() and vdprintf() RETURN VALUES. OK deraadt@Todd C. Miller
2017-04-13Use recallocarray in getdelim/getline to clear memory on buffer resizes,Bryan Steele
inspired by a similar change to fgetln. ok deraadt millert
2017-03-17Use recallocarray() to avoid leaving detritus in memory when resizingTodd C. Miller
the string buffer used by asprintf() and vasprintf(). OK deraadt@
2017-03-17Use recallocarray() to avoid leaving detritus in memory when resizingTheo de Raadt
buffers. We don't bother doing this for objects containing pointers, but focus on controllable data. ok millert
2017-03-16Only reallocate the buffer to fit for medium-size allocations whereTodd C. Miller
we expanded the buffer to a single page. The final realloc() can be expensive for large buffers and is not realled needed. OK deraadt@
2017-03-16When reallocating the buffer for asprintf(), just round up to theTodd C. Miller
nearest page instead of doubling the old size until it is large enough. OK deraadt@
2017-03-14Use a macro for the initial length of the buffer instead of 127; OK deraadt@Todd C. Miller
2016-10-30include float.h for the LDBL_MAX_EXP cpp test in floatio.hJonathan Gray
2016-09-21Delete casts to off_t and size_t that are implied by assignmentsPhilip Guenther
or prototypes. Ditto for some of the char* and void* casts too. verified no change to instructions on ILP32 (i386) and LP64 (amd64) ok natano@ abluhm@ deraadt@ millert@
2016-08-29Store the return value of mbrtowc() in a size_t, not int.Todd C. Miller
OK schwarze@
2016-08-27Stop recommending the non-standard and slightly dangerous fgetln(3).Ingo Schwarze
Recommend POSIX getline(3) instead.
2016-08-27When a precision is specified for a string format use strnlen()Todd C. Miller
to determine the length instead of doing it manually. OK schwarze@
2016-08-27improve revision 1.2: in unusual cases, fgetwc(3) can succeedIngo Schwarze
even though ferror(3) is already set; also from Andrey Chernov <ache at freebsd dot org>; OK millert@
2016-08-25After read errors, fgetln(3) sometimes succeeded (returning non-NULL)Ingo Schwarze
and failed (setting errno and ferror(3)) both at the same time. That's a bad idea in general, and here in particular since returning partial lines was neither reliable (sometimes, you got NULL anyway) nor predictable (almost always, the line would be truncated long before the actual read error). Instead, on read failure, fail properly and always return NULL. Issue found in a discussion with Andrey Chernov <ache at freebsd dot org> who finally agreed to move FreeBSD into the same direction. The fix is joint work with and OK by millert@.
2016-08-24set the error indicator on malloc(3) failure;Ingo Schwarze
from Andrey Chernov <ache at freebsd dot org>; OK millert@
2016-08-21bugfix: when fgetwc(3) fails, fgetwln(3) must fail as well;Ingo Schwarze
OK jca@ martijn@ millert@
2016-08-17% is escaped with more %, not backslash.Ted Unangst
2016-08-17Generate syslog warnings for %s fmt strings NULL to "(null)" conversions.Theo de Raadt
Over time we can repair software which performs this non-standard behaviour, and fix bugs along the way. Let's first find out how bad the situation is by deploying this in snapshots. This type of logging is possible because OpenBSD syslog_r(3) -> sendsyslog(2) is side-effect free enough to be used in the bowels of libc. ok tedu
2016-06-06Add ERRORS section, from FreeBSD. OK tedu@Todd C. Miller
2016-06-06Return EOVERFLOW, not ENOMEM for overflow conditions to match POSIX.Todd C. Miller
2016-05-26fputs(3) now returns a non-negative number (as opposed to 0) on successfulTodd C. Miller
completion, just like puts(3). Found the hard way in portable code. OK jmc@
2016-05-23Make _fwalk and _cleanup completely internal to libcPhilip Guenther
ok deraadt@
2016-05-07Use a Thread Information Block in both single and multi-threaded programs.Philip Guenther
This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
2016-04-05Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specificPhilip Guenther
data isn't necessary. ok mpi@, ok&tweak natano@
2016-04-04get* can change *lineptr on failurePhilip Guenther
ok sthen@
2016-03-30for some time now mandoc has not required MLINKS to functionJason McIntyre
correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
2016-03-26fix typo: "prefer seek()" -> "prefer fseek()"Theo Buehler
ok deraadt@, stsp@
2016-03-20Currently we have about a 50/50 split over fcntl(n, F_GETFL [,0])Kenneth R Westerback
idioms. Adopt the more concise fcntl(n, F_GETFL) over fcntl(n, F_GETFL, 0) where it is obvious further investigation will not yield and even better way. Obviousness evaluation and ok guenther@
2016-03-15remind people rewind is seldom a good choiceMarc Espie
okay jmc@
2016-01-26When encoding fails in fputwc(3), set the error indicator as requiredIngo Schwarze
by POSIX and as FreeBSD, SunOS 10/11, and glibc also do it. Note that an enquiry to the Austin Group led to the conclusion that this change probably violates the C standard: C and POSIX unintentionally conflict. But the POSIX behaviour makes more sense (easier to write correct error handling code for it, and a lower risk that programs miss errors) and is much more widespread, and the Austin Group intends to approach the C committee in order to adjust the C standard. See: http://austingroupbugs.net/view.php?id=1022 While here, do not set errno a second time, wcrtomb(3) already did that, and it is required to do it by the standard. OK millert@ and tedu@, and jca@ no longer objects
2016-01-19remove a nop assignment that has been #if 0'd since 1996mmcc
ok millert@
2016-01-04Bugfix: When errno happens to be EILSEQ upon entry to fgetws(3),Ingo Schwarze
and when the file ends without a terminating Ln character, fgetws(3) discarded any characters read and reported bogus EOF. Never inspect errno(2) unless right after an error occurred! OK millert@
2016-01-04Fix lots of bugs.Ingo Schwarze
1. When fprintf(fp, "...%ls...", ...) encounters an encoding error, do not destroy all the fp->_flags, which made the file permanently unreadable and unwriteable. 2. Do not change fp->_flags at all in case of encoding errors. Neither the manual nor POSIX ask for it, no other conversions set the error indicator, and it isn't needed because the return value reports failure and must be checked anyway. 3. Detect failure in mbrtowc(3), do not silently treat invalid bytes in the format string as the end of the format string. 4. Detect failure of __find_arguments(), no matter whether due to out of memory conditions or encoding errors, and gracefully fail rather than accessing an invalid pointer. 5. Remove the pointless and slightly dangerous errno = EILSEQ overrides after functions that already do that and are required by the standard to do so. OK jca@ on items 1, 2, and 5. OK millert@ on the complete diff. "Completely brutal mix of bugs." deraadt@
2015-12-28Remove NULL-checks before free() and a few related dead assignments.mmcc
ok and valuable input from millert@
2015-12-24Both our manual and POSIX ask us to set the error indicator when anIngo Schwarze
encoding error occurs, so do it. While here, do not set errno after mbrtowc(3) failure; mbrtowc(3) already does that, and that behaviour is required by the standard. ok jca@ guenther@ "nice find" deraadt@
2015-11-04replace setbuf with setvbuf, from Frederic NowakTed Unangst
2015-10-25Hide __atexit and __atexit_register_cleanup()Philip Guenther
Wrap __cxa_{atexit,finalize}() so the call from exit() goes direct Switch regress/lib/libc/atexit/ to be built with -static so that it can still access __atexit* ok millert@ jca@
2015-10-13Sync printf family return value with ISO C which specifies thatTodd C. Miller
these functions return a negative value on failure. OK doug@ deraadt@
2015-10-07Be explicit that the user is responsible for freeing the line bufferTodd C. Miller
and show this in the example.