summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfwprintf.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r268926, r268930, r268983:pfg2014-08-031-1/+3
| | | | | | | | | | | | Use a correct errno in freopen. Use EBADF instead of EINVAL when working around incorrect O_ACCMODE. Adjust errno on failed prepwrite. rewind: always clear error indicator as required by POSIX. Obtained from: Apple Inc. (Libc 997.90.3) Phabric: D442
* Renumber clauses to reduce diffs to other versionsemaste2013-04-231-1/+1
| | | | | | | NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3, so follow suit to make comparison easier. Acked-by: imp@
* If the size passed to {,v}s{w,n}printf is larger than INT_MAX+1das2012-04-211-0/+3
| | | | | | | | | | | | | | | | | (i.e., the return value would overflow), set errno to EOVERFLOW and return an error. This improves the chances that buggy applications -- for instance, ones that pass in a negative integer as the size due to a bogus calculation -- will fail in safe ways. Returning an error in these situations is specified by POSIX, but POSIX appears to have an off-by-one error that isn't duplicated in this change. Previously, some of these functions would silently cap the size at INT_MAX+1, and others would exit with an error after writing more than INT_MAX characters. PR: 39256 MFC after: 2 weeks
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds atheraven2011-11-201-34/+46
| | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor)
* 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
* Replace a dozen lines of code with a call to strnlen() / wcsnlen().das2009-02-281-17/+1
|
* Make sure %zd treats negative arguments properly on 32-bit platforms.das2009-02-281-1/+1
| | | | | | | Fix harmless but related bugs in %_$zd and %_$tu. PR: 131880 MFC after: 1 week
* Add support for multibyte thousands_sep encodings, e.g., U+066C.das2009-01-221-62/+116
| | | | | | | | 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-191-16/+26
|
* When f[w]printf() is called on an unbuffered file like stdout, itdas2009-01-171-7/+11
| | | | | | | | | | | | | | | | 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.)
* Reduce code duplication by moving functions that are identical in bothdas2009-01-151-214/+0
| | | | | 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-151-38/+58
| | | | | | | | | | | 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.
* Consolidate some variable initializations. No substantive change.das2008-12-111-6/+6
|
* Initialize "nconv" to a reasonable value in all code paths. Prior tocperciva2008-08-041-1/+3
| | | | | | | this commit, sprintf("%s", "") could fail depending on what happened to be on the stack. Found by: LLVM/Clang Static Checker
* Correctly handle malloc() failure. While here, reduce the code size adas2008-06-291-3/+9
| | | | bit by removing some calls to the inline function addtype().
* Reduce the level of duplication between vfprintf() and vfwprintf()das2008-06-291-488/+3
| | | | | | by moving the positional argument handling code to a new file, printf-pos.c, and moving common definitions to printflocal.h. No functional change intended.
* Begin de-spaghettifying the code that handles positional arguments.das2008-06-291-94/+153
| | | | | | | | | | | | | | In particular, encapsulate the state of the type table in a struct, and add inline functions to initialize, free, and manipulate that state. This replaces some ugly macros that made proper error handling impossible. While here, remove an unneeded test for NULL and a variable that is initialized (many times!) but never used. The compiler didn't catch these because of rampant use of the same variable to mean different things in different places. This commit should not cause any changes in functionality.
* Next stage of stdio cleanup: Retire __sFILEX and merge the fields back intojhb2008-04-171-1/+2
| | | | | | | | | | | | | | | | | | | __sFILE. This was supposed to be done in 6.0. Some notes: - Where possible I restored the various lines to their pre-__sFILEX state. - Retire INITEXTRA() and just initialize the wchar bits (orientation and mbstate) explicitly instead. The various places that used INITEXTRA didn't need the locking fields or _up initialized. (Some places needed _up to exist and not be off the end of a NULL or garbage pointer, but they didn't require it to be initialized to a specific value.) - For now, stdio.h "knows" that pthread_t is a 'struct pthread *' to avoid namespace pollution of including all the pthread types in stdio.h. Once we remove all the inlines and make __sFILE private it can go back to using pthread_t, etc. - This does not remove any of the inlines currently and does not change any of the public ABI of 'FILE'. MFC after: 1 month Reviewed by: peter
* Catch up with vfprintf.c,v 1.77.das2007-12-181-0/+1
|
* Per Regents of the University of Calfornia letter, remove advertisingimp2007-01-091-4/+0
| | | | | | clause. # If I've done so improperly on a file, please let me know.
* Use correct type in va_arg argument.kan2006-09-211-1/+1
|
* Add missing #if's for NO_FLOATING_POINTphk2006-04-011-2/+4
|
* Be bug-for-bug compatible with the C standard with respect todas2005-04-161-2/+8
| | | | printf("%#.0o", 0). Cite an amusing passage from a defect report.
* Don't forget to va_end() the va_list we get from va_copy().des2004-08-261-0/+1
| | | | | Submitted by: Sean McNeil <sean@mcneil.com> MFC after: 3 days
* The third operand of the conditional operator should have type void too.stefanf2004-06-081-1/+1
| | | | Approved by: das (mentor)
* Rename cantwrite() to prepwrite(). The latter is less confusing,das2004-06-081-1/+1
| | | | since the macro isn't really a predicate, and it has side-effects.
* Fix damaged FBSDID.obrien2004-05-021-3/+1
|
* Merge vfprintf.c, v1.65:das2004-05-021-24/+17
| | | | | - s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/ - Remove HEXFLOAT
* Use the correct size to allocate, copy and clear argument type tablestjr2004-04-221-6/+9
| | | | | | | | | | after their change from an array of char to an array of enum. This fixes problems that occurred when using positional arguments in format strings, particularly with more than STATIC_ARG_TBL_SIZE (8) of them. PR: 65841 Submitted by: Steven Smith (mostly)
* Prepare to handle trivial state-dependent encodings. Full support fortjr2004-04-071-3/+10
| | | | | state-dependent encodings with locking shifts will come later if there is demand for it.
* Merge vfprintf.c, v1.61 and 1.62. For compatibility with __hdtoa()das2004-01-231-19/+25
| | | | | | | and to reduce diffs between vfprintf.c and vfwprintf.c, declare xdigs* to be char arrays rather than wchar_t arrays. In collaboration with: tjr
* Remove unused variables and function declarations. Add missing headers.nectar2004-01-061-2/+1
|
* Use __sfvwrite() instead of __sputc() via __fputwc() to write to faketjr2003-11-121-1/+30
| | | | | | | | string files (__SSTR flag set). This is necessary because __sputc() does not respect the __SALC flag, and crashes trying to flush the buffer instead of resizing it. PR: 59167
* Pass NULL instead of a pointer to a zeroed mbstate_t object.tjr2003-11-051-5/+2
|
* %E-like %g and %G conversions should remove trailing zeroes unlessdas2003-04-191-0/+7
| | | | | | | | the # flag is present. Implement this behavior and add a comment describing it. Noticed by: Enache Adrian <enache@rdslink.ro> Pointy hat to: das
* Merge in vfprintf.c rev. 1.58.tjr2003-04-141-9/+11
|
* Catch up with recent vfprintf.c changes.tjr2003-04-071-175/+215
|
* Add missing #include to unbreak previous commit.das2003-04-051-0/+1
|
* Correct some buffer sizes.das2003-04-051-9/+15
| | | | | | | | | | - __vfprintf()'s 'buf' has never been used for floating point, so don't define it in terms of (incorrect) constants describing floating point numbers. The actual size needed depends on sizeof(uintmax_t) and locale details, so I slightly overestimated. - We don't need a 308-character buffer to store the string "308". With long doubles and %a we need more than three characters, though.
* Merge vfprintf.c revision 1.52.tjr2003-03-141-2/+2
|
* Unexpand RCS tag.tjr2003-03-141-1/+1
|
* MFp4: Catch up to recent __dtoa() interface changes and removal of cvt()'stjr2003-03-131-11/+10
| | | | last argument.
* Set the error bit on the stream if an encoding error occurs. Improvetjr2002-10-161-1/+3
| | | | handling of multibyte sequences representing null wide characters.
* Add support for the XSI %C and %S formats, which are the same as %lctjr2002-10-161-0/+12
| | | | and %ls.
* Use the new va_copy macro to copy variable argument lists instead oftjr2002-09-241-1/+1
| | | | | | | | assignment. This is needed on powerpc but is also more correct for the other ports. Submitted by: grehan Tested on: alpha, i386, sparc64
* Add implementations of the wprintf() family of functions, which performtjr2002-09-211-0/+1538
formatted wide-character output.
OpenPOWER on IntegriCloud