summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
...
* 1) Back out r304607 case 2). fgetwln() as its pair fgetln() supposed toAndrey A. Chernov2016-08-222-24/+7
| | | | | | | | | | | | | | return partial line on any errors. See the comment in fgetln.c. Add corresponding comment to fgetwln() too. 2) Rewrite r304607 case 1). 3) Remove "Fast path" from __fgetwc_mbs() since it can't detect encoding errors and ignores them all. PR: 212033 MFC after: 7 days Notes: svn path=/head/; revision=304641
* Fix error processing.Andrey A. Chernov2016-08-221-1/+13
| | | | | | | | | | | | | 1) Don't forget to set __SERR on __slbexpand() error. 2) Check for __fgetwc() errors using errno. Don't check for __SERR as PR suggested, it user-visible flag which can stick from previous functions and stdio code don't check it for this purpose. PR: 212033 MFC after: 3 days Notes: svn path=/head/; revision=304607
* Remove usage of _WITH_DPRINTFBaptiste Daroussin2016-07-301-1/+0
| | | | Notes: svn path=/head/; revision=303529
* Remove last traces of _WITH_GETLINEBaptiste Daroussin2016-07-301-1/+0
| | | | Notes: svn path=/head/; revision=303528
* Remove _WITH_GETLINE and _WITH_DPRINTF guardsBaptiste Daroussin2016-07-302-60/+2
| | | | | | | | | | | | | When adding getline(3) and dprintf(3) into libc, those guards were added to prevent breaking too many ports. 7 years later the ports tree have been fixed, it is time to remove this FreeBSDism While here remove the extra parenthesis surrounding dprintf(3) Notes: svn path=/head/; revision=303524
* 1) Eliminate possibility to call __*collate_range_cmp() with inclompleteAndrey A. Chernov2016-07-141-3/+3
| | | | | | | | | | | | | | | locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() only for single bytes locales (we can't do it now for other ones). In previous state only first 256 wchars are considered and all others are just silently dropped from the range. Notes: svn path=/head/; revision=302824
* Back out non-collating [a-z] ranges.Andrey A. Chernov2016-07-141-5/+22
| | | | | | | | | | Instead of changing whole course to another POSIX-permitted way for consistency and uniformity I decide to completely ignore missing regex fucntionality and concentrace on fixing bugs in what we have now, too many small obstacles instead, counting ports. Notes: svn path=/head/; revision=302820
* Remove broken support for collation in [a-z] type ranges.Andrey A. Chernov2016-07-101-22/+5
| | | | | | | | | | | | | | | | | | | | | Only first 256 wide chars are considered currently, all other are just dropped from the range. Proper implementation require reverse tables database lookup, since objects are really big as max UTF-8 (1114112 code points), so just the same scanning as it was for 256 chars will slow things down. POSIX does not require collation for [a-z] type ranges and does not prohibit it for non-POSIX locales. POSIX require collation for ranges only for POSIX (or C) locale which is equal to ASCII and binary for other chars, so we already have it. No other *BSD implements collation for [a-z] type ranges. Restore ABI compatibility with unused now __collate_range_cmp() which is visible from outside (will be removed later). Notes: svn path=/head/; revision=302512
* Fix regression from r301461.Pedro F. Giffuni2016-06-101-3/+3
| | | | | | | | | | | | | | | The fix to the __collate_range_cmp() ABI breakage missed some replacements in libc's vfscanf(). Replace them with __wcollate_range_cmp() which does what is expected. This was breaking applications like xterm and pidgin when using wide characters. Reported by: Vitalij Satanivskij Approved by: re Notes: svn path=/head/; revision=301777
* libc: Actually export fopencookie(3)Conrad Meyer2016-05-121-0/+1
| | | | | | | | | A follow-up to r299456. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299572
* libc: Add fopencookie(3) wrapper around funopen(3)Conrad Meyer2016-05-114-3/+329
| | | | | | | | | Reviewed by: jhb, oshogbo Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D6282 Notes: svn path=/head/; revision=299456
* libc: spelling fixes.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | Mostly on comments. Notes: svn path=/head/; revision=298830
* freopen(3): prevent uninitialized errno.Pedro F. Giffuni2016-03-301-1/+0
| | | | | | | | | | Revert completley r297408 (and r297407): this ends up touching errno, which we are not allowed to do. Pointed out by: ache, bde Notes: svn path=/head/; revision=297417
* freopen(3): prevent uninitialized errno.Pedro F. Giffuni2016-03-301-2/+2
| | | | | | | | | | | Revert r297407 and redo it cleanly. Pointed out by: Jukka A. Ukkonen CID: 1018720 MFC after: 1 week Notes: svn path=/head/; revision=297408
* freopen(3): prevent uninitialized errno.Pedro F. Giffuni2016-03-301-1/+2
| | | | | | | | | | The case doesn't look very likely but clean the possibility nevertheless CID: 1018720 MFC after: 1 week Notes: svn path=/head/; revision=297407
* Fix bunch of .Xrs.Edward Tomasz Napierala2016-03-281-2/+2
| | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=297355
* fputs: Return the number of bytes written.Pedro F. Giffuni2016-02-151-1/+1
| | | | | | | | | | Fix r295631: wrong value. Pointy hat: pfg (me) Pointed out by: bde Notes: svn path=/head/; revision=295638
* getln: We cannot expand the buffer beyond INT_MAX.Pedro F. Giffuni2016-02-152-2/+12
| | | | | | | | | | | | In such cases return ENOMEM. This is a limitation of our implementation, alternatively you may consider getline(3). Differential Revision: https://reviews.freebsd.org/D442 (Partial) Obtained from: Apple Inc. (Libc 997.90.3) Relnotes: yes Notes: svn path=/head/; revision=295632
* fputs: Return the number of bytes written.Pedro F. Giffuni2016-02-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX.1-2008 requires that successful completion simply return a non-negative integer. We have regularly returned a constant value. Another, equally valid, implementation convention implies returning the number of bytes written. Adopt this last convention to be in line with what Apple's libc does. POSIX also explicitly notes: Note that this implementation convention cannot be adhered to for strings longer than {INT_MAX} bytes as the value would not be representable in the return type of the function. For backwards-compatibility, implementations can return the number of bytes for strings of up to {INT_MAX} bytes, and return {INT_MAX} for all longer strings. Developers shouldn't depend specifically on either convention but the change may help port software from Apple. Differential Revision: https://reviews.freebsd.org/D442 (Partial) Obtained from: Apple Inc. (Libc 997.90.3 with changes) Relnotes: yes Notes: svn path=/head/; revision=295631
* Use __alignof__ instead of assuming int64_t to get the rightWarner Losh2015-12-301-10/+1
| | | | | | | | | alignment. Differential Revision: https://reviews.freebsd.org/D4708 Notes: svn path=/head/; revision=292902
* The FILE structure has a mbstate_t in it. This structure needs to beWarner Losh2015-12-271-2/+14
| | | | | | | | | | | | | aligned on a int64_t boundary. However, when we allocate the array of these structures, we use ALIGNBYTES which defaults to sizeof(int) on arm, i386 and others. The i386 stuff can handle unaligned accesses seemlessly. However, arm cannot. Take this into account when creating the array of FILEs, and add some comments about why. Differential Revision: https://reviews.freebsd.org/D4708 Notes: svn path=/head/; revision=292809
* Use stdint.h instead of inttypes.h as the latter pollutes namespace moreEnji Cooper2015-12-092-4/+4
| | | | | | | | | | MFC after: 3 days X-MFC with: r292004 Submitted by: bde Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=292013
* Fix compilation when -DDEBUG is defined by adding inttypes.h #includeEnji Cooper2015-12-082-0/+6
| | | | | | | | | | | | | for intmax_t MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D4434 Reported by: cppcheck Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=292004
* Link fclose(3) to fdclose(3)Enji Cooper2015-11-251-1/+1
| | | | | | | | | X-MFC with: r285140 MFC after: 3 weeks (need to evaluate whether or not r285140 can be MFCed) Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291337
* markup fixesDag-Erling Smørgrav2015-11-231-3/+9
| | | | Notes: svn path=/head/; revision=291197
* 1) Remove my overcomplicated error fallback and just return errorAndrey A. Chernov2015-11-121-11/+3
| | | | | | | | | | | | immediatelly as old code does, now for append modes too. Real use case for such fallback is impossible (unless specially crafted). 2) Remove now unneded include I forgot to remove in prev. commits. MFC after: 1 week Notes: svn path=/head/; revision=290729
* Reorganize code to elimitate one _sseek() call for append modes.Andrey A. Chernov2015-11-081-21/+14
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=290549
* Microoptimize.Andrey A. Chernov2015-11-011-4/+3
| | | | Notes: svn path=/head/; revision=290232
* Addition to prev. commit.Andrey A. Chernov2015-11-011-4/+6
| | | | | | | | | | In some edge cases fp->_p can be changed in _sseek(), recalculate. PR: 204156 MFC after: 1 week Notes: svn path=/head/; revision=290231
* Don't seek to the end if write buffer is empty (in append modes).Andrey A. Chernov2015-11-011-11/+12
| | | | | | | | PR: 204156 MFC after: 1 week Notes: svn path=/head/; revision=290230
* Add _flags2 per jhb@ suggestion since no room left in _flags.Andrey A. Chernov2015-10-286-10/+7
| | | | | | | | | Rewrite O_APPEND flag checking using new __S2OAP flag. MFC after: 3 weeks Notes: svn path=/head/; revision=290110
* According to POSIX, a write operation shall start at the current size ofAndrey A. Chernov2015-10-251-0/+3
| | | | | | | | | the stream (if mode had 'a' as the first character). MFC after: 1 week Notes: svn path=/head/; revision=289931
* Since no room left in the _flags, reuse __SALC for O_APPEND.Andrey A. Chernov2015-10-245-19/+31
| | | | | | | | | | It helps to remove _fcntl() call from _ftello() and optimize seek position calculation in _swrite(). MFC after: 3 weeks Notes: svn path=/head/; revision=289863
* Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.Craig Rodrigues2015-09-203-8/+6
| | | | Notes: svn path=/head/; revision=288033
* Remove names from some prototypesCraig Rodrigues2015-09-201-1/+1
| | | | Notes: svn path=/head/; revision=288032
* Remove names from some prototypesCraig Rodrigues2015-09-201-2/+2
| | | | Notes: svn path=/head/; revision=288031
* Add declarations to eliminate -Wmissing-prototypes warningsCraig Rodrigues2015-09-203-0/+6
| | | | Notes: svn path=/head/; revision=288006
* Switch libc from using _sig{procmask,action,suspend} symbols, whichKonstantin Belousov2015-08-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | are aliases for the syscall stubs and are plt-interposed, to the libc-private aliases of internally interposed sigprocmask() etc. Since e.g. _sigaction is not interposed by libthr, calling signal() removes thr_sighandler() from the handler slot etc. The result was breaking signal semantic and rtld locking. The added __libc_sigprocmask and other symbols are hidden, they are not exported and cannot be called through PLT. The setjmp/longjmp functions for x86 were changed to use direct calls, and since PIC_PROLOGUE only needed for functional PLT indirection on i386, it is removed as well. The PowerPC bug of calling the syscall directly in the setjmp/longjmp implementation is kept as is. Reported by: Pete French <petefrench@ingresso.co.uk> Tested by: Michiel Boland <boland37@xs4all.nl> Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=287292
* Fix a couple of markup typos.John Baldwin2015-08-021-3/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=286177
* Add fdclose(3) function.Mariusz Zaborski2015-07-043-27/+134
| | | | | | | | | | | | | This function is equivalent to fclose(3) function except that it does not close the underlying file descriptor. fdclose(3) is step forward to make FILE structure private. Reviewed by: wblock, jilles, jhb, pjd Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D2697 Notes: svn path=/head/; revision=285140
* Reassign copyright statements on several files from AdvancedJohn Baldwin2015-04-233-3/+3
| | | | | | | | | | Computing Technologies LLC to Hudson River Trading LLC. Approved by: Hudson River Trading LLC (who owns ACT LLC) MFC after: 1 week Notes: svn path=/head/; revision=281887
* Support file verification in MAC.Craig Rodrigues2015-04-221-0/+4
| | | | | | | | | | | | | | | | | * Add VCREAT flag to indicate when a new file is being created * Add VVERIFY to indicate verification is required * Both VCREAT and VVERIFY are only passed on the MAC method vnode_check_open and are removed from the accmode after * Add O_VERIFY flag to rtld open of objects * Add 'v' flag to __sflags to set O_VERIFY flag. Submitted by: Steve Kiernan <stevek@juniper.net> Obtained from: Juniper Networks, Inc. GitHub Pull Request: https://github.com/freebsd/freebsd/pull/27 Relnotes: yes Notes: svn path=/head/; revision=281845
* libc: clean some set-but-not-used errors.Pedro F. Giffuni2015-02-181-3/+0
| | | | | | | | | | These were found by gcc 5.0 on Dragonfly BSD, however I made no attempt to silence the false positives. Obtained from: DragonFly (cf515c3a6f3a8964ad592e524442bc628f8ed63b) Notes: svn path=/head/; revision=278932
* In r268924 __fflush was modified so that when write(2) was not successful,Xin LI2014-12-101-4/+6
| | | | | | | | | | | | | | | _p and _w are adjusted to account for the partial write (if any). However, _p and _w should not be unconditionally adjusted and should only be changed when we actually wrote some bytes, or the accumulated accounting error will eventually result in a heap buffer overflow. Reported by: adrian and alfred (Norse Corporation) Security: FreeBSD-SA-14:27.stdio Security: CVE-2014-8611 Notes: svn path=/head/; revision=275665
* Fix prototypes.Kevin Lo2014-10-281-3/+3
| | | | Notes: svn path=/head/; revision=273760
* Fix the example: free the memory that was allocated by getline().Nick Hibma2014-07-311-0/+1
| | | | Notes: svn path=/head/; revision=269326
* In the "Too many open files" edge cases don't try to preserve oldAndrey A. Chernov2014-07-261-0/+8
| | | | | | | | | | number for non-std* descriptors, but close old file and retry. Obtained from: inspired by Apple's change from pfg@ MFC after: 2 weeks Notes: svn path=/head/; revision=269116
* Avoid possible cast degradation.Pedro F. Giffuni2014-07-222-2/+2
| | | | | | | | | | | | | | For consistency with r268985 for fputs.c, assign iov_len first, avoiding the cast to uio_resid (int in stdio) from degrading the value. We currently don't support lengths higher than INT_MAX so this change is little more than cosmetic. MFC after: 3 days Notes: svn path=/head/; revision=269001
* For "a"-mode files and rewind/fseek + fwrite combination return meaningfulAndrey A. Chernov2014-07-221-0/+18
| | | | | | | | value now, like Apple does, but avoid their __sflush physical write performance degradation as much as possible. Notes: svn path=/head/; revision=268997
* Back the whole change out until I figure out how to obtain O_APPEND,Andrey A. Chernov2014-07-221-6/+0
| | | | | | | it can't be used in this field at all. Notes: svn path=/head/; revision=268992