summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* tmpnam(3): Also mention tmpfile in the ENVIRONMENT sectionGordon Bergling2020-08-071-1/+3
| | | | | | | | | PR: 181785 Submitted by: Kevin P. Neal <kpneal atpobox dot com> MFC after: 1 week Notes: svn path=/head/; revision=364029
* fgetln(3): Add a Caveats SectionGordon Bergling2020-06-181-1/+31
| | | | | | | | | | | Reviewed by: yuripv, bcr (mentor) Approved by: bcr (mentror) Obtained from: OpenBSD MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D24916 Notes: svn path=/head/; revision=362326
* libc manpages: various improvements from NetBSDGordon Bergling2020-06-143-3/+34
| | | | | | | | | | | | | | - Add STANDARDS and HISTORY sections within the appropriate manpages - Mention two USENIX papers within kqueue(2) and strlcpy(3) Reviewed by: bcr (mentor) Approved by: bcr (mentor) Obtained from: NetBSD MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D24650 Notes: svn path=/head/; revision=362171
* Add HISTORY section to getc(3)Sergio Carlavilla Delgado2020-04-101-1/+17
| | | | | | | | | PR: 240269 Submitted by: Gordon Bergling Differential Revision: https://reviews.freebsd.org/D24295 Notes: svn path=/head/; revision=359773
* Note some functions that appeared in First Edition UnixWarner Losh2020-04-011-0/+7
| | | | | | | | | These functions first appeared in the First Edition of Unix (or earlier in the pdp-7 version). Just claim 1st Edition for all this. The pdp-7 code is too fragmented at this point to extend history that far back. Notes: svn path=/head/; revision=359547
* libc: provide fputc_unlockedKyle Evans2020-02-022-3/+12
| | | | | | | | | | | | | | Among the same justification as the other stdio _unlocked; in addition to an inline version in <stdio.h>, we must provide a function in libc as well for the functionality. This fixes the lang/gcc* builds, which want to use the symbol from libc. PR: 243810 Reported by: antoine, swills, Michael <michael.adm gmail com> X-MFC-With: r357284 Notes: svn path=/head/; revision=357419
* stdio: provide _unlocked variants of fflush, fputc, fputs, fread, fwriteKyle Evans2020-01-3011-16/+102
| | | | | | | | | | | | | | | | fflush_unlocked is currently desired in ports by sysutils/metalog, and redefined as the locked fflush. fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are currently desired in ports by devel/elfutils, and redefined as the locked fputs, fread, and fwrite respectively. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D23336 Notes: svn path=/head/; revision=357284
* libc: remove getsEd Maste2019-09-013-44/+10
| | | | | | | | | | | | | | | | | | | | gets is unsafe and shouldn't be used (for many years now). Leave it in the existing symbol version so anything that previously linked aginst it still runs, but do not allow new software to link against it. (The compatability/legacy implementation must not be static so that the symbol and in particular the compat sym gets@FBSD_1.0 make it into libc.) PR: 222796 (exp-run) Reported by: Paul Vixie Reviewed by: allanjude, cy, eadler, gnn, jhb, kib, ngie (some earlier) Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D12298 Notes: svn path=/head/; revision=351659
* Add mkostempsat(3).Mark Johnston2019-07-294-19/+54
| | | | | | | | | | | | | | | This is a variant of mkostemps() which takes a directory descriptor and returns a descriptor for a tempfile relative to that directory. Unlike the other mktemp functions, mkostempsat() can be used in capability mode. Reviewed by: cem Discussed with: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21031 Notes: svn path=/head/; revision=350420
* GC a historical artifact.Brooks Davis2019-02-071-10/+0
| | | | | | | | | | | | Back in 1993, the fgetln (then fgetline) interface was changed to not return a C string. The change was accomplished by ifdefing out the code that did the termination. Changing the interface would violate our API stability rules so remove the old implementation. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=343884
* Follow up on r331936. gets_s(3) will also fail in the same way thatCy Schubert2018-10-231-0/+2
| | | | | | | | | | gets(3) does. This was missed in r331936. Reported by: emaste@ MFC after: 3 days Notes: svn path=/head/; revision=339656
* Fix formatting.Mark Johnston2018-10-201-2/+2
| | | | | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=339458
* Implement printf(3) family %m format string extension.Konstantin Belousov2018-05-222-1/+28
| | | | | | | | | Reviewed by: ed, dim (code only) Sponsored by: Mellanox Technologies MFC after: 1 week Notes: svn path=/head/; revision=334031
* Conform to Berne Convention.Cy Schubert2018-05-191-1/+1
| | | | | | | | Prompted by: Recent discussion MFC after: 3 days Notes: svn path=/head/; revision=333895
* Don't put multiple names on a single .Nm line. This fixes apropos(1)Edward Tomasz Napierala2018-04-171-2/+12
| | | | | | | | | | | | | | | | output, from this: strnlen, strlen, strlen,(3) - find length of string │······· ... to this: strlen, strnlen(3) - find length of string PR: 223525 MFC after: 2 weeks Notes: svn path=/head/; revision=332642
* The correct symbol version for FreeBSD 12 is 1.5.Cy Schubert2018-04-031-1/+4
| | | | | | | | | | Reported by: kib@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Notes: svn path=/head/; revision=331947
* Correct the version number for gets_s(3).Cy Schubert2018-04-031-1/+1
| | | | | | | | | | Reported by: kib@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Notes: svn path=/head/; revision=331945
* Add gets_s(3) to the man page title (noticed by ed@).Cy Schubert2018-04-031-2/+3
| | | | | | | | | | | | While I'm at it correct the update date in the man page. Reported by: ed@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Notes: svn path=/head/; revision=331942
* Add new gets_s(3) stdio function.Cy Schubert2018-04-034-3/+129
| | | | | | | | | | | | | | This implements the gets_s(3) function as documented at http://en.cppreference.com/w/c/io/gets. It facilitates the optional removal of gets(3). Reviewed by: ed MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D12785 Notes: svn path=/head/; revision=331936
* __printf_render_int(): small type change to match use.Pedro F. Giffuni2018-02-231-2/+2
| | | | | | | | | | | Variable l is consistently used as an int rather than a char. Sort names while here. Obtained from: Apple's Libc-1244.30.3 MFC after: 5 days Notes: svn path=/head/; revision=329848
* fsync(3): correctly document return valuesEitan Adler2017-12-251-5/+8
| | | | | | | | | | In r268924 the behavior of fflush was changed to return success on read only streams. Document this. Reported by: zrj@DragonFlyBSD.org Notes: svn path=/head/; revision=327181
* fopen.1: document truncationEitan Adler2017-12-231-1/+1
| | | | | | | | | | This documentation truncation similar to POSIX and glibc. PR: 202545 Reported by: intron@intron.ac Notes: svn path=/head/; revision=327099
* The function fwscanf() return value is wrong when encountering an earlyStephen J. Kiernan2017-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | matching failure. According to the Open Group documentation for fwscanf: "Upon successful completion, these functions shall return the number of successfully matched and assigned input items; this number can be zero in the event of an early matching failure." Without this change, fwscanf would return EOF in the case of an early matching failure, instead of the proper return value of 0. This change aligns fwscanf(3) with the implementation in fscanf(3). PR: 202240 Submitted by: rajendra.sy@gmail.com Reviewed by: jhb, cem Approved by: sjg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D13288 Notes: svn path=/head/; revision=326635
* Truncate negative lengths to zeroPoul-Henning Kamp2017-11-271-1/+5
| | | | Notes: svn path=/head/; revision=326246
* libc: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2533-2/+68
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326193
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2082-4/+168
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* While discussing the new gets_s.c in D12785, ed@ suggested puttingCy Schubert2017-11-031-2/+2
| | | | | | | | | | | | {}'s around the if (c == EOF) block to prevent potential 'trailing else' issues from being introduced when refactoring. As my gets_s() code is based on this, it makes sense to fix the same issue here first here and now, then do an svn copy again to capture this history). Suggested by: ed@ in D12785 Notes: svn path=/head/; revision=325357
* Revert r325031. This breaks the build due to __FBSDID.Cy Schubert2017-10-271-1/+1
| | | | | | | Pointy hat to: cy Notes: svn path=/head/; revision=325032
* Ensure all incude statements are kept together by moving theCy Schubert2017-10-271-1/+1
| | | | | | | | | | sys/cdefs.h include appropriately. MFC after: 1 week X-MFC with: r325030 Notes: svn path=/head/; revision=325031
* Remove redundant sys/cdefs.h include.Cy Schubert2017-10-271-1/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=325030
* In the stdio cleanup push and pop wrappers, always call libc stubs forKonstantin Belousov2017-06-301-3/+3
| | | | | | | | | | | | | | | | | | __pthread_cleanup_push/pop_imp instead of symbols also exported from libthr. This prevents calls into libthr if libthr is not yet initialized. The situation occurs e.g. when an LD_PRELOADed object is not linked against libthr, but the main binary is. Reported and tested by: jbeich PR: 220381 Discussed with: vangyzen Sponsored by: The FreeBSD Foundation MFC after: 13 days Notes: svn path=/head/; revision=320509
* Fix typo in the r320472 change to fgetws(). Return proper value.Konstantin Belousov2017-06-301-1/+1
| | | | | | | | | | Reported by: Oleg Ginzburg <olevole@olevole.ru> Reviewed by: vangyzen Sponsored by: The FreeBSD Foundation MFC after: 13 days Notes: svn path=/head/; revision=320508
* Make stdio deferred cancel-safe.Konstantin Belousov2017-06-2938-138/+185
| | | | | | | | | | | | | | | | | | | | | | | If used with fopen(3)/fdopen(3)-ed FILEs, stdio accurately uses non-cancellable internal versions of the functions, i.e. it seems to be fine with regard to cancellation. But if the funopen(3) and f{r,w}open(3) functions were used to open the FILE, and corresponding user functions create cancellation points (they typically have no other choice), then stdio code at least leaks FILE' lock. The change installs cleanup handler which unlocks FILE. Some minimal restructuring of the code was required to make it use common return place to satisfy hand-rolled pthread_cleanup_pop() requirements. Noted by: eugen Reviewed by: eugen, vangyzen Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D11246 Notes: svn path=/head/; revision=320472
* fopencookie(3): declare function pointers in SYNOPSIS correctlyEnji Cooper2017-05-231-4/+4
| | | | | | | | | | | Add obligatory `*` in declarations. Reported by: make manlint MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=318711
* fopen(3): make manlint fixesEnji Cooper2017-05-231-5/+10
| | | | | | | | | | | | - Break on new lines. - Use .Dv with NULL. - Rewrap lines as necessary/when possible. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=318705
* libc: provide some bounds-checking through reallocarray(3).Pedro F. Giffuni2017-03-123-4/+4
| | | | | | | | | | | | reallocarray(3) is a non portable extension that originated in OpenBSD. Given that it is already in FreeBSD's libc it is useful for the cases where reallocation involves a multiplication. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9955 Notes: svn path=/head/; revision=315162
* libc: small cleanup.Pedro F. Giffuni2017-03-121-1/+2
| | | | | | | | Initialize newsize in the code section so we avoids asigning the value if we exit early. Notes: svn path=/head/; revision=315104
* Renumber copyright clause 4Warner Losh2017-02-2834-34/+34
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Revert r310138Enji Cooper2016-12-221-31/+0
| | | | | | | | | | | | | | | Adding %b support to vfprintf for parity with kernel space requires more discussion/review. In particular, many parties were concerned over introducing a non-standard format qualifier to *printf(3) which didn't already exist in other OSes, e.g. Linux, thus making code which used %b harder to port to other operating systems. Requested by: many Notes: svn path=/head/; revision=310433
* vfprintf(3): Add support for kernel %b formatConrad Meyer2016-12-161-0/+31
| | | | | | | | | | | | | | | This is a direct port of the kernel %b format. I'm unclear on if (more) non-portable printf extensions will be a problem. I think it's desirable to have userspace formats include all kernel formats, but there may be competing goals I'm not aware of. Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8426 Notes: svn path=/head/; revision=310138
* Detect integer overflow and limit the number of positionalRuslan Bukin2016-10-311-12/+33
| | | | | | | | | | | arguments in the string format. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8286 Notes: svn path=/head/; revision=308145
* Fix error handling.Andrey A. Chernov2016-09-051-4/+10
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=305413
* Fix n == 1 case. Here should be no physical read (fill buffer) attemptAndrey A. Chernov2016-09-051-2/+6
| | | | | | | | | | (we read n - 1 chars with the room for NUL, see fgets()), and no NULL return. MFC after: 3 days Notes: svn path=/head/; revision=305412
* 1) Prevent out of bounds access to ws[-1] (passed buffer) which happensAndrey A. Chernov2016-09-051-2/+2
| | | | | | | | | | | | | when the first mb sequence is incomplete and there are not enougn chars in the read buffer. ws[-1] may lead to memory faults or false results, in case the memory here contains '\n'. 2) Fix EOF checking I mess in my previos r305406 commit. MFC after: 3 days Notes: svn path=/head/; revision=305409
* Fix errors handling.Andrey A. Chernov2016-09-051-6/+18
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=305406
* fgetwc(3) may set both __SEOF and __SERR at once (in case of incompleteAndrey A. Chernov2016-09-011-1/+11
| | | | | | | | | | | sequence near EOF), so we can't just check for (wc == WEOF && !__sfeof(fp)) and must relay on __sferror(fp) with __SERR clearing/restoring. MFC after: 7 days Notes: svn path=/head/; revision=305241
* If error happens, don't overwrite original errno comes from __mbrtowc()Andrey A. Chernov2016-09-011-5/+8
| | | | | | | | | and __srefill(). MFC after: 3 days Notes: svn path=/head/; revision=305219
* Original fgetln() from 44lite return sucess for line tail errors,Andrey A. Chernov2016-08-252-4/+6
| | | | | | | | | | | | | | i.e. partial line, but set __SERR and errno in the same time, which is inconsistent. Now both OpenBSD and NetBSD return failure, i.e. no line and set error indicators for such case, so make our fgetln() and fgetwln() (as its wide version) compatible with the rest of *BSD. PR: 212033 MFC after: 7 days Notes: svn path=/head/; revision=304819
* Remove "Fast path", it bypass __wcrtomb() and all its error checking.Andrey A. Chernov2016-08-251-13/+3
| | | | | | | | | One of affected encoding example: US-ASCII MFC after: 7 days Notes: svn path=/head/; revision=304811
* Don't check for __SERR which may stick from one of any previous stdioAndrey A. Chernov2016-08-253-2/+14
| | | | | | | | | | functions. __SERR is for user and the rest of stdio code do not check it for error sensing internally, only set it. In vf(w)printf.c here it is more easy to save __SERR, clear and restore it. Notes: svn path=/head/; revision=304810