summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* Because we call __printf_out() with a on-stack buffer, also callpjd2011-03-061-2/+4
| | | | | | __printf_flush() so we are sure it won't be referenced after we return. MFC after: 2 weeks
* Fix various issues in how %#T is handled:pjd2011-03-061-7/+11
| | | | | | | | | | - If precision is 0, don't print period followed by no digits. - If precision is 0 stop printing units as soon as possible (eg. if we have three years and five days and precision is 0 print only 3y5d). - If precision is not 0, print all units (eg. 3y0d0h0m0s.00). MFC after: 2 weeks
* When reopening a stream backed by an open file descriptor, do not closejhb2010-12-091-12/+9
| | | | | | | | | | | | | the existing file descriptor. Instead, let dup2() atomically close the old file descriptor when assigning the newly opened file to the same descriptor. This closes a race in a multithreaded application where a concurrent open() could allocate the existing file descriptor in between the calls to close() and dup2(). PR: threads/79887 Submitted by: Dmitrij Tejblum tejblum of yandex-team.ru Reviewed by: davidxu MFC after: 1 week
* Remove two unused variables, left over from the refactoring in r180104.gavin2010-12-021-6/+0
| | | | | | PR: bin/152551 Submitted by: Henning Petersen <henning.petersen t-online.de> MFC after: 2 weeks
* Update the documentation to reflect changes to the implementation indas2010-11-301-14/+14
| | | | | | | r197752, which is related to handling of null buffer pointers. Also make a few minor wording changes. Reported by: jh@
* Revert changes of 'assure' to 'ensure' made in r211936.brucec2010-09-111-1/+1
| | | | Approved by: rrs (mentor)
* Fix incorrect usage of 'assure' and 'insure'.brucec2010-08-281-1/+1
| | | | Approved by: rrs (mentor)
* mdoc: move CAVEATS, BUGS and SECURITY CONSIDERATIONS sections to theuqs2010-05-134-98/+98
| | | | | | | | | | | bottom of the manpages and order them consistently. GNU groff doesn't care about the ordering, and doesn't even mention CAVEATS and SECURITY CONSIDERATIONS as common sections and where to put them. Found by: mdocml lint run Reviewed by: ru
* mdoc: fix parenthesisuqs2010-05-111-2/+2
| | | | Reviewed by: brueffer
* mdoc: use macro for +- that is understood by mdocmluqs2010-05-112-4/+4
| | | | Reviewed by: brueffer
* I feel this wording of the history is more clear.obrien2010-04-052-9/+6
| | | | ANSIfy vasprintf() while I'm here.
* - Use an initializer macro to initialize fields in 'fake' FILE objects usedjhb2010-03-1112-39/+22
| | | | | | | | | | | | by *sprintf(), etc. - Explicitly initialize _fl_mutex to PTHREAD_MUTEX_INITIALIZER for all FILE objects. This is currently a nop on FreeBSD, but is import for other platforms (or in the future) where PTHREAD_MUTEX_INITIALIZER is not simply zero. PR: threads/141198 Reported by: Jeremy Huddleston @ Apple MFC after: 2 weeks
* In _gettemp(), check that the length of the path doesn't exceedjh2010-02-281-0/+4
| | | | | | | | MAXPATHLEN. Otherwise the path name (or part of it) may not fit to carrybuf causing a buffer overflow. PR: bin/140228 Suggested by: jilles
* %U was macroized in mdoc(7), escape.ru2010-02-161-1/+1
|
* Give a less silly response to a silly request.cperciva2010-01-102-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, fread/fwrite calls with size * nmemb > SIZE_MAX were handled by reading or writing (size_t)(size * nmemb) bytes; for example, on 32-bit platforms, fread(ptr, 641, 6700417, f) would read 1 byte and indicate that the requested 6700417 blocks had been read. This commit adds a check for such integer overflows, and treats them as if an overly large request was passed to read/write; i.e., it sets errno to EINVAL, sets the error indicator on the file, and returns a short object count (0, to be specific). The overflow check involves an integer division, so as a performance optimization we check first to see if both size and nmemb are less than 2^16; if they are, no overflow is possible and we avoid the division. We assume here that size_t is at least 32 bits; this appears to be true on all platforms FreeBSD supports. Although this commit fixes an integer overflow, it is not likely to have any security implications, since any program which would be affected by this bug fix is quite clearly already very confused. Reviewed by: kib MFC after: 1 month
* Remove unnecessary quoting and markup, add missing punctuation.brueffer2010-01-081-3/+2
| | | | | | PR: 140494 Submitted by: Jeremy Huddleston <jeremyhu@apple.com>, bde MFC after: 1 week
* Use vsprintf instead of rolling our own.delphij2009-12-211-9/+1
| | | | | | PR: bin/140496 Submitted by: Jeremy Huddleston <jeremyhu apple.com> MFC after: 1 month
* Use vsscanf instead of rolling our own.delphij2009-12-211-24/+1
| | | | | | PR: bin/140530 Submitted by: Jeremy Huddleston <jeremyhu apple.com> MFC after: 1 month
* K&R -> ANSI prototype.delphij2009-12-211-8/+3
| | | | MFC after: 1 month
* (no commit message)matteo2009-12-161-1/+2
|
* Fix many "function declaration isn't a prototype" warnings in libc.ed2009-12-052-6/+6
| | | | | I've only fixed code that seems to be written by `us'. There are still many warnings like this present in resolv/, rpc/, stdtime/ and yp/.
* Fix the dprintf() prototype.brueffer2009-12-021-2/+2
| | | | | | PR: 141087 Submitted by: Jeremy Huddleston <jeremyhu@apple.com> MFC after: 3 days
* Eliminate more dead stores.wollman2009-11-251-1/+1
| | | | | Found by: Clang static analyzer MFC after: 7 days
* Make all three if conditions look similar by always initializing nsecwollman2009-11-251-1/+2
| | | | | | | | and moving the default initialization of prec into the else clause. The clang static analyzer erroneously thought that nsec can be used uninitialized here; it was not actually possible, but better to make the code clearer. (Clang can't know that sprintf() won't modify *pi behind the scenes.)
* In __mbsconv(), if prec was zero, nconv could have been usedwollman2009-11-251-1/+1
| | | | | | | | | uninitialized. Initialize it to a safe value so that there's no chance of returning an error if stack garbage happens to be equal to (size_t)-1 or (size_t)-2. Found by: Clang static analyzer MFC after: 7 days
* Eliminate dead store.wollman2009-11-251-1/+1
| | | | | Found by: Clang static analyzer MFC after: 7 days
* Better glibc compatibility for getline/getdelim:das2009-10-041-2/+2
| | | | | | | | | | | | | | - Tolerate applications that pass a NULL pointer for the buffer and claim that the capacity of the buffer is nonzero. - If an application passes in a non-NULL buffer pointer and claims the buffer has zero capacity, we should free (well, realloc) it anyway. It could have been obtained from malloc(0), so failing to free it would be a small memory leak. MFC After: 2 weeks Reported by: naddy PR: ports/138320
* Make the description of `b' a little better.ed2009-09-091-1/+1
| | | | | | | If you have a one-byte sequence, `w', `b' is the second character. Not the third. Submitted by: Christoph Mallon
* Fix fwrite() to return 0 when size or nmemb are zero.ed2009-07-122-4/+9
| | | | | | | | Right now nmemb is returned when size is 0. In newer versions of the standards, it is explicitly required that fwrite() should return 0. Submitted by: Christoph Mallon Approved by: re (kib)
* Return -1 instead of 0 upon reaching EOF. This is somewhat ill-adviseddas2009-04-062-4/+6
| | | | | | | | because it means getdelim() returns -1 for both error and EOF, and never returns 0. However, this is what the original GNU implementation does, and POSIX inherited the bug. Reported by: marcus@
* Add dprintf() and vdprintf() from POSIX.1-2008. Like getline(),das2009-03-046-32/+198
| | | | | | dprintf() is a simple wrapper around another function, so we may as well implement it. But also like getline(), we can't prototype it by default right now because it would break too many ports.
* Rewrite asprintf() as a wrapper around vasprintf(), thus reducing thedas2009-03-021-43/+22
| | | | | number of functions that have an incestuous relationship with the arcane innards of stdio.
* The argument corresponding to %zn is supposed to be an ssize_t *, notdas2009-03-022-6/+6
| | | | a size_t *, although the distinction is moot in practice.
* Use C99-style initializers. No functional change.das2009-03-011-4/+9
| | | | Reviewed by: md5(1)
* Replace a dozen lines of code with a call to strnlen() / wcsnlen().das2009-02-282-33/+2
|
* - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(),das2009-02-288-5/+377
| | | | | | | | | | | | wcscasecmp(), and wcsncasecmp(). - Make some previously non-standard extensions visible if POSIX_VISIBLE >= 200809. - Use restrict qualifiers in stpcpy(). - Declare off_t and size_t in stdio.h. - Bump __FreeBSD_version in case the new symbols (particularly getline()) cause issues with ports. Reviewed by: standards@
* Make sure %zd treats negative arguments properly on 32-bit platforms.das2009-02-283-5/+8
| | | | | | | Fix harmless but related bugs in %_$zd and %_$tu. PR: 131880 MFC after: 1 week
* Better wording for clearing EOF indicator.trhodes2009-01-281-0/+4
| | | | Submitted by: keramida and jhb
* Remove another comment about clearing EOF indicator.trhodes2009-01-281-4/+1
| | | | Noticed by: bde
* Update the manpage to reflect r145172.das2009-01-281-2/+1
|
* Remove comment about clearerr() being the only method of clearingtrhodes2009-01-281-3/+1
| | | | | | | | | the EOF indicator, fseek() may also be used for this. Bump document date. PR: 76333 Submitted by: Yoshihiko Sarumaru <mistral@imasy.or.jp>
* Add support for multibyte thousands_sep encodings, e.g., U+066C.das2009-01-223-173/+225
| | | | | | | | The integer thousands' separator code is rewritten in order to avoid having to preallocate a buffer for the largest possible digit string with the most possible instances of the longest possible multibyte thousands' separator. The new version inserts thousands' separators for integers using the same code as floating point.
* - Add support for multibyte decimal_point encodings, e.g., U+066B.das2009-01-192-23/+49
| | | | | A forthcoming gdtoa import is needed to make this fully work. - Improve the way "nan(...)" is parsed.
* Add support for multibyte decimal_point encodings, e.g., U+066B.das2009-01-192-23/+35
|
* When f[w]printf() is called on an unbuffered file like stdout, itdas2009-01-172-14/+23
| | | | | | | | | | | | | | | | sets up a fake buffered FILE and then effectively calls itself recursively. Unfortunately, gcc doesn't know how to do tail call elimination in this case, and actually makes things worse by inlining __sbprintf(). This means that f[w]printf() to stderr was allocating about 5k of stack on 64-bit platforms, much of which was never used. I've reorganized things to eliminate the waste. In addition to saving some stack space, this improves performance in my tests by anywhere from 5% to 17% (depending on the test) when -fstack-protector is enabled. I found no statistically significant performance difference when stack protection is turned off. (The tests redirected stderr to /dev/null.)
* Simplify printf's inlined output buffering routines. On amd64, thisdas2009-01-171-18/+18
| | | | reduces the code size by about 10% and improves performance slightly.
* Introduce a local variable and use it instead of passed in parameterrdivacky2009-01-152-2/+6
| | | | | | | | to get rid of restrict qualifier discarding. This lets libc compile cleanly in gnu99 mode. Suggested by: kib, christoph.mallon at gmx.de Approved by: kib (mentor)
* Reduce code duplication by moving functions that are identical in bothdas2009-01-153-427/+216
| | | | | vfprintf.c and vfwprintf.c (except for char/wchar_t differences) to a common header file.
* Convert the insidious macros that handle printf()'s buffering intodas2009-01-153-86/+204
| | | | | | | | | | | slightly less evil inline functions, and move the buffering state into a struct. This will make it possible for helper routines to produce output for printf() directly, making it possible to untangle the code somewhat. In wprintf(), use the same buffering mechanism to reduce diffs to printf(). This has the side-effect of causing wprintf() to catch write errors that it previously ignored.
* Set the error indicator on an attempt to write to a read-only stream.das2009-01-081-0/+1
| | | | | PR: 127335 MFC after: 2 weeks
OpenPOWER on IntegriCloud