master
Add <stdio_ext.h> with the seven APIs needed to have gnulib operate without poking directly into the FILE structure.
The mdoc(7) .Ft macro does not need quoting of its arguments, but about 10% of our manual pages using this macro employed useless quoting anyway. Remove these quotes such that they do not incite fear, uncertainty, and doubt in developers who happen to look at these pages. jmc@ and tb@ agree with the direction.
I am retiring my old email address; replace it with my OpenBSD one.
Add framework for resolving (pun intended) libc namespace issues, using wrapper .h files and asm labels to let internal calls resolve directly and not be overridable or use the PLT. Then, apply that framework to most of the functions in stdio.h, string.h, err.h, and wchar.h. Delete the should-have-been-hidden-all-along _v?(err|warn)[cx]? symbols while here.
Again. Make exit(), fclose(), fflush(), and freopen() comply with POSIX-2008 requirements for setting the underlying file position when flushing read-mode streams, and make an fseek()-after-fflush() not change the underlying file position. This commit fixes some minor problems of the previous.
When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
document that fileno(3) returns -1 for some kinds of FILE * objects; triggerd by but simpler than a similar patch sent in by Simon Branch <simonmbranch at gmail dot com>; OK millert@ jmc@
fpurge() first appeared in 4.3BSD-Reno ok deraadt@ schwarze@
Consistently .Xr the corresponding wide char functions from char- and 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@.
Use recallocarray() to avoid leaving detritus in memory when resizing buffers. We don't bother doing this for objects containing pointers, but focus on controllable data. ok millert
Delete casts to off_t and size_t that are implied by assignments or prototypes. Ditto for some of the char* and void* casts too.
Both our manual and POSIX ask us to set the error indicator when an 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@
remove .Tn from stdio manuals; Kaspars Bankovskis found one of these
improve revision 1.2: in unusual cases, fgetwc(3) can succeed even though ferror(3) is already set; also from Andrey Chernov <ache at freebsd dot org>; OK millert@
Bugfix: When errno happens to be EILSEQ upon entry to fgetws(3), 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@
next citrus step.
A few sys/param.h annotations lacked ALIGNBYTES
Add additional userland interfaces for setting close-on-exec on fds when creating them: mkostemp(), mkostemps(), the 'e' mode letter for fopen(), freopen(), fdopen(), and popen(). The close-on-exec flag will be cleared by the action created by posix_spawn_file_actions_adddup2().
Wrap the remaining __*dtoa() functions so that internal calls go direct
Use a Thread Information Block in both single and multi-threaded programs. 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!
Xr open_memstream in fmemopen.3
Fix append mode so it always writes to the end and expand regress. OK deraadt@ martijn@
don't mention what language functions are implemented in remove a line relating to the 2BSD libNS ok schwarze@
If OK to read flag is set, don't set write space to buffer size. Avoids a problem where after fpurge(), putc() characters to a read-write FILE may be lost.
When encoding fails in fputwc(3), set the error indicator as required 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
observe the following spelling: - wide character (noun) - wide-character (adjective)
ansi ok mpi@ deraadt@
Fix typo: nemb -> nmemb
Restore the optimization for unbuffered I/O. The buffer needs to be reset before each call to __srefill(). Passes new regress. OK semarie@
.Li -> .Vt where appropriate; from josiah frentsos, tweaked by schwarze
change some 4.4BSD references to earlier releases ok schwarze@
funopen(): change seekfn argument to use off_t, not fpos_t On BSD, fpos_t is typedef'd to off_t but some systems use a struct. This means fpos_t is not a portable function argument or return value. Both FreeBSD and the Linux libbsd funopen() have switched to off_t for this--we should too. From Joe Nelson. OK deraadt@
__sfvwrite: allow writing buffers larger than BUFSIZ or st_blksize.
Use static and __{BEGIN,ENV}_HIDDEN_DECLS to hide a bunch of internal symbols that are not longer exported. (This improves the generated code.)
Make _fwalk and _cleanup completely internal to libc
convert to new .Dd format;
fwide() does not unlock if error was occurred.
add a missing .Vt macro; from Josiah Frentsos <jfrent at tilde dot team>
Use recallocarray in getdelim/getline to clear memory on buffer resizes, inspired by a similar change to fgetln.
Use the fancy .In macro for includes. From Jan Klemkow. ok jmc schwarze
No need to initialize the first element of st->string since it was just calloc(3)-ed a few lines above. OK tb@
More consistently put remarks about the less useful LC_* categoties, i.e. those other than LC_CTYPE, into the CAVEATS section, and standardize wording somewhat. OK jmc@
asprintf() and vasprintf() are in POSIX-2024. Update #include visibility and manpages and add restrict qualifiers in all the specified places to the *printf family.
__swsetup: set error flag and errno on error.
Fix the handle locking in stdio to use flockfile/funlockfile internally when and where required. Macros in <stdio.h> are updated to automatically call the underlying functions when the process is threaded to obtain the necessary locking. A private mutex is added to protect __sglue, the internal list of FILE handles, and another to protect the one-time initialization. Some routines in libc that use getc() change to use getc_unlocked() as they're either protected by their own lock or aren't thread-safe routines anyway.
Use .Rv where appropriate, and move it to RETURN VALUES; remove .Tn, and a few minor macro adjustments. Patch from Kaspars at Bankovskis dot net.
Use fseeko() instead of fseek() inside libc, as the latter just calls the former with a loss of range. Mark fseek symbol as deprecated to block accidental use in the future.
man pages: add missing commas between subordinate and main clauses
C99 says setvbuf() returns non-zero, not EOF. Also, POSIX documents that it returns an error for invalid mode which matches our behavior. OK jmc@ deraadt@
If a command or interface first appeared in PWB/UNIX, UNIX System III or UNIX System V mention it. Only do so in manual pages with a pre-existing HISTORY section.
Fix incorrect range check for size in setvbuf
GNU ld has prefixed the contents of .gnu.warning.SYMBOL sections with "warning: " since 2003, so the messages themselves need not contain the prefix anymore.
rework some fflush text, as requested From: Edward tweaks From: Tim van der Molen
Undo changes to tmpfile.c r1.5. Doing the fchown call causes pledge("tmppath") to be insufficient and the the umask dance may cause race-conditions in multithreaded applications.
.Dt same as filename
article fixes; from eddie youseph
in vdprintf(), no need to use the file locking mecanism when using fflush() as the variable is stack based (no possible concurrent access). call directly __sflush()
Fix printf(3) signal safety for wide character strings.
spelling fixes; from paul tagliamonte any changes not taken noted on tech, but chiefly here i did not take the cancelation - cancellation changes;
Set EOVERFLOW for overflow conditions to match POSIX.
add some prototypes, casts, includes, parenthesis, and whatnot to silence some warnings.
mop up stdarg rename; ok deraadt