summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/snprintf.c
Commit message (Collapse)AuthorAgeFilesLines
* Style: One space between "restrict" qualifier and "*".tjr2002-09-061-1/+1
|
* - Introduce the 'restrict' qualifier to function prototypes androbert2002-08-151-1/+1
| | | | | definitions to comply with IEEE Std 1003.1-2001. - Update the manual pages.
* Basic support for wide character I/O: getwc(), fgetwc(), getwchar(),tjr2002-08-131-0/+3
| | | | putwc(), fputwc(), putwchar(), ungetwc(), fwide().
* Assume __STDC__, remove non-__STDC__ code.alfred2002-05-281-17/+0
| | | | Submitted by: keramida
* Fix the style of the SCM ID's.obrien2002-03-221-4/+2
| | | | I believe have made all of libc .c's as consistent as possible.
* revert freeing of memory that gets allocated when str == NULLassar2001-06-181-2/+0
| | | | | | (this will be fixed in a better way) PR: misc/26044
* free memory that gets allocated by vfprintf when str == NULLassar2001-06-161-0/+2
| | | | | | PR: misc/26044 MFC after: 1 week
* libc MT-safety, part 2.deischen2001-02-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a lock to FILE. flockfile and friends are now implemented (for the most part) in libc. flockfile_debug is implemented in libc_r; I suppose it's about time to kill it but will do it in a future commit. Fix a potential deadlock in _fwalk in a threaded environment. A file flag (__SIGN) was added to stdio.h that, when set, tells _fwalk to ignore it in its walk. This seemed to be needed in refill.c because each file needs to be locked when flushing. Add a stub for pthread_self in libc. This is needed by flockfile which is allowed by POSIX to be recursive. Make fgetpos() error return value (-1) match man page. Remove recursive calls to locked functions (stdio); I think I've got them all, but I may have missed a couple. A few K&R -> ANSI conversions along with removal of a few instances of "register". $Id$ -> $FreeBSD$ in libc/stdio/rget.c Not objected to: -arch, a few months ago
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* 1. EOF was returned when the buffer size was larger than INT_MAX. Thisache1998-01-011-5/+5
| | | | | | | | | | case has very little to do with the output size being larger than INT_MAX. 2. The new #include of <limits.h> was disordered. 3. The new declaration of `on' was disordered (integer types go together). 4. Testing an unsigned value for > 0 was fishy. Submitted by: bde
* Correct type of stored argument place (from previous fix)ache1997-12-241-2/+2
|
* Return back to BSD snprintf semantics which recent C9x standard adoptsache1997-12-241-6/+9
| | | | | | | | | | instead of Singe Unix, thanx Bruce for explaining, I am not realize standards war was there. But now, fix n == 0 case to not return error and fix check for too big n. Things left to do: check for overflow in arguments.
* 1) Oops! Insert again if (n == 0) return 0.ache1997-12-241-5/+5
| | | | | | | | | | | | | | | | | | | Final word is Bruce's quote: C9x specifies the BSD4.4-Lite behaviour: [#3] ... Thus, the null-terminated output has been completely written if and only if the returned value is less than n. It means that if we not have any null-terminated output as for n == 0 we can't return value less than n, so we forced to return value equal to n i.e. 0 The next good thing is glibc compatibility, of course. 2) Do check for too big n in machine-independent way. 3) Minor optimization assuming EOF is < 0
* Back out part related to "return 0 if n == 0" and return EOF as before.ache1997-12-241-3/+1
| | | | | | | | | | | The main argument is that it is impossible to determine if %n evaluated or not when snprintf return 0, because it can happens for both n == 0 and n == 1. Although EOF here is good indication of the end of process, if n is decreased in the loop... Since it is already supposed in many places that EOF *is* negative, f.e. from Single Unix specs for snprintf "return ... a negative value if an output error was encountered" this not makes situation worse.
* snprintf return value fixes to conform Single Unix specs:ache1997-12-241-3/+8
| | | | | | | | | | | | | | | | | | | | 1) if buffer size is smaller than arguments size, return buffer size, not arguments size as before. 2) if buffer size is 0, return 0, not EOF as before. (now it is compatible with Linux and Apache implementations too). NOTE: Single Unix specs says: If the value of n {buffer size} is zero on a call to snprintf(), an unspecified value less than 1 is returned. It means we can't return EOF since EOF can take *any* value in general not especially < 1. Better variant will be return -1 (it is less then 1 and different with n == 1 case) but -1 value is already occuped by EOF in our implementation, so we can't distinguish true IO error in that case. So 0 here is only possible case still conforming to Single Unix specs.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Suggested by: Bruce Evans, Jeffrey Hsu, Gary Palmerjraynard1996-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | Added $Id$'s to files that were lacking them (gpalmer), made some cosmetic changes to conform to style guidelines (bde) and checked against NetBSD and Lite2 to remove unnecessary divergences (hsu, bde) One last code cleanup:- Removed spurious casts in fseek.c and stdio.c. Added missing function argument in fwalk.c. Added missing header include in flags.c and rget.c. Put in casts where int's were being passed as size_t's. Put in missing prototypes for static functions. Changed second args of __sflags() inflags.c and writehook() in vasprintf.c from char * to const char * to conform to prototypes. This directory now compiles with no warnings with -Wall under gcc-2.6.3 and with considerably less warnings than before with the ultra-pedantic script I used for testing. (Most of the remaining ones are due to const poisoning).
* Reviewed by: julian and (hsu?)julian1996-01-221-0/+3
| | | | | | Submitted by: John Birrel(L?) changes for threadsafe operations
* BSD 4.4 Lite Lib Sourcesrgrimes1994-05-271-0/+76
OpenPOWER on IntegriCloud