summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/vfprintf.c
Commit message (Collapse)AuthorAgeFilesLines
* The third operand of the conditional operator should have type void too.Stefan Farfeleder2004-06-081-1/+1
| | | | | | | Approved by: das (mentor) Notes: svn path=/head/; revision=130242
* Rename cantwrite() to prepwrite(). The latter is less confusing,David Schultz2004-06-081-1/+1
| | | | | | | since the macro isn't really a predicate, and it has side-effects. Notes: svn path=/head/; revision=130231
* - To make it easier to compile *printf() and *scanf() withoutDavid Schultz2004-05-021-24/+16
| | | | | | | | | | | | floating-point support, remove default definition of FLOATING_POINT from the source, and change the compile-time option to NO_FLOATING_POINT. - Remove the HEXFLOAT option. It saves an insignificant amount of space (<0.1% of the size of libc on i386) and complicates vfprintf() and checkfmt(). Notes: svn path=/head/; revision=128819
* Use the correct size to allocate, copy and clear argument type tablesTim J. Robbins2004-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) Notes: svn path=/head/; revision=128550
* Prepare to handle trivial state-dependent encodings. Full support forTim J. Robbins2004-04-071-4/+12
| | | | | | | | state-dependent encodings with locking shifts will come later if there is demand for it. Notes: svn path=/head/; revision=128002
* Implement __hdtoa() and __hldtoa() and enable printf() support for %aDavid Schultz2004-01-181-5/+2
| | | | | | | and %A, which print floating-point numbers in hexadecimal. Notes: svn path=/head/; revision=124667
* Fix some bugs affecting the %a and %A format specifiers. SinceDavid Schultz2004-01-181-6/+16
| | | | | | | | | | | | | | | | these are not fully implemented and ifdef'd out, the bugs have never manifested themselves. Specifically: - Fix a memory leak in the case where %a follows another floating-point format. - Make the %a/%A code behave like %e/%E with respect to precision. - It is no longer valid to assume that '-' and '0x' are mutually exclusive. - Address other minor issues. Notes: svn path=/head/; revision=124657
* Pass NULL instead of a pointer to a zeroed mbstate_t object.Tim J. Robbins2003-11-051-9/+4
| | | | Notes: svn path=/head/; revision=122105
* %E-like %g and %G conversions should remove trailing zeroes unlessDavid Schultz2003-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 Notes: svn path=/head/; revision=113723
* Fix a bug where printf was erroneously printing a decimal point forDavid Schultz2003-04-141-8/+10
| | | | | | | | | | | | %f and sufficiently short %g specifiers where the precision was explicitly zero, no '#' flag was specified, and the floating point argument was > 0 and <= 0.5. While at it, add some comments to better explain the relevant bits of code. Noticed by: Christoph Kukulies <kuku@physik.rwth-aachen.de> Notes: svn path=/head/; revision=113468
* __wcsconv(): free(convbuf) before returning NULLAndrey A. Chernov2003-04-071-2/+4
| | | | Notes: svn path=/head/; revision=113196
* Today just isn't my day. Remove some old commented out code that snuckDavid Schultz2003-04-071-1/+1
| | | | | | | | | into the last commit. Noticed by: mike Notes: svn path=/head/; revision=113194
* - %e conversions with precision 0 should not cause a decimal point toDavid Schultz2003-04-071-18/+22
| | | | | | | | | | | be printed. - Fix %f conversions where the number of significant digits is < expt. This would be a one-line change were it not for thousands separators. Noticed by tjr. - Remove some unnecessary code in the parsing of precision specifiers. Notes: svn path=/head/; revision=113191
* Rework the floating point code in printf(). Significant changes:David Schultz2003-04-051-151/+189
| | | | | | | | | | | | | | | | | | | | | - We used to round long double arguments to double. Now we print them properly. - Bugs involving '%F', corner cases of '#' and 'g' format specifiers, and the '.*' precision specifier have been fixed. - Added support for the "'" specifier to print thousands' grouping characters in a locale-dependent manner. - Implement the __vfprintf() side of hexadecimal floating point support. All that is still needed is a routine to convert the mantissa to hex digits one nibble at a time in the style of ultoa(). Reviewed by: silence on standards@ Notes: svn path=/head/; revision=113146
* Correct some buffer sizes.David Schultz2003-04-051-10/+16
| | | | | | | | | | | | | - __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. Notes: svn path=/head/; revision=113142
* Kludge around a bug that results from printf() assuming thatDavid Schultz2003-03-141-1/+1
| | | | | | | | | | | | dtoa() is buggy. The bug would cause incorrect output to be generated when format strings such as '%5.0f' were used with nonzero numbers whose magnitude is less than 1. Reported by: df(1) by way of periodic(8) Reviewed by: mike Notes: svn path=/head/; revision=112224
* Replace our ancient dtoa/strtod implementation with the gdtoaDavid Schultz2003-03-121-9/+10
| | | | | | | | | | | | | | | | | | | | | package, a more recent, generalized set of routines. Among the changes: - Declare strtof() and strtold() in stdlib.h. - Add glue to libc to support these routines for all kinds of ``long double''. - Update printf() to reflect the fact that dtoa works slightly differently now. As soon as I see that nothing has blown up, I will kill src/lib/libc/stdlib/strtod.c. Soon printf() will be able to use the new routines to output long doubles without loss of precision, but numerous bugs in the existing code must be addressed first. Reviewed by: bde (briefly), mike (mentor), obrien Notes: svn path=/head/; revision=112163
* Set the error bit on the stream if an encoding error occurs. ImproveTim J. Robbins2002-10-161-2/+6
| | | | | | | handling of multibyte sequences representing null wide characters. Notes: svn path=/head/; revision=105234
* Add support for the XSI %C and %S formats, which are the same as %lcTim J. Robbins2002-10-161-0/+12
| | | | | | | and %ls. Notes: svn path=/head/; revision=105204
* Use the new va_copy macro to copy variable argument lists instead ofTim J. Robbins2002-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 Notes: svn path=/head/; revision=103876
* Implement the %ls and %lc conversions for printing wide character stringsTim J. Robbins2002-09-191-6/+110
| | | | | | | | | and wide characters. These were already documented in the manual page, with an entry mentioning that they were not implemented yet. The XSI %S and %C synoyms have not been added. Notes: svn path=/head/; revision=103633
* Convert eight space indents to tabs in the "*" format handling code.Tim J. Robbins2002-09-161-43/+43
| | | | Notes: svn path=/head/; revision=103399
* Style: One space between "restrict" qualifier and "*".Tim J. Robbins2002-09-061-1/+1
| | | | Notes: svn path=/head/; revision=103012
* Print a '-' sign for negative zero. Tested withJens Schweikhardt2002-08-271-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | #include <stdio.h> int main(void) { printf("%+f\n", -0.0); printf("%+f\n", +0.0); printf("%+f\n", 0.0); return 0; } to output -0.000000 +0.000000 +0.000000 PR: bin/41823 Submitted by: GOTO Kentaro <gotoken@notwork.org> Liked by: bde MFC after: 3 weeks Notes: svn path=/head/; revision=102499
* - For compliance with IEEE Std 1003.1-2001, add the 'restrict'Robert Drehmel2002-08-151-1/+2
| | | | | | | | | qualifier to function prototypes and definitions where appropriate using the '__restrict' macro. - Update the manual page. Notes: svn path=/head/; revision=101914
* Basic support for wide character I/O: getwc(), fgetwc(), getwchar(),Tim J. Robbins2002-08-131-0/+1
| | | | | | | putwc(), fputwc(), putwchar(), ungetwc(), fwide(). Notes: svn path=/head/; revision=101776
* Assume __STDC__, remove non-__STDC__ code.Alfred Perlstein2002-05-281-4/+0
| | | | | | | Submitted by: keramida Notes: svn path=/head/; revision=97407
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-4/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Remove multi-line __P() usage.David E. O'Brien2002-03-221-5/+5
| | | | Notes: svn path=/head/; revision=92941
* Remove __P() usage.David E. O'Brien2002-03-211-6/+6
| | | | Notes: svn path=/head/; revision=92905
* Remove 'register' keyword.David E. O'Brien2002-03-211-2/+2
| | | | Notes: svn path=/head/; revision=92889
* Fix some style bugsAlexey Zelkin2001-12-171-15/+18
| | | | | | | Prompted by: mike Notes: svn path=/head/; revision=88057
* Also fix cases when thousands separator should be put before number. ForAlexey Zelkin2001-12-131-2/+4
| | | | | | | | example before for grouping sequence "\003\003" number 123456 was formated as ",123,456", now "123,456". Notes: svn path=/head/; revision=87818
* Respect locale while handling of \' flag.Alexey Zelkin2001-12-131-22/+63
| | | | | | | | | | | | | In original version grouping was hardcoded. It assumed that thousands separator should be inserted to separate each 3 numbers. I.e. grouping string "\003" was assumed for all cases. In correct case (per POSIX) vfprintf should respect locale defined non-monetary (LC_NUMERIC category) grouping sequence. Also simplify thousands_sep handling. Notes: svn path=/head/; revision=87815
* * localeconv() usage is not FLOATING_POINT specific anymore (due to "'" flagAlexey Zelkin2001-12-071-3/+3
| | | | | | | | addition) so move locale.h inclusion out of FLOATING_POINT ifdef's. * add more comments Notes: svn path=/head/; revision=87490
* Implement several of the c99 updates to printf(3):Bill Fenner2001-11-301-115/+233
| | | | | | | | | | | | | | | | | | | - New length modifiers: hh, j, t, z. - New flag: '. Note that %'f is not yet implemented. - Use "inf"/"nan" for efg formats, "INF"/"NAN" for EFG formats. - Implemented %q in terms of %ll; if "quad_t" is not "long long" %q will break. Still to do: - %C, %S, %lc, %ls (wide character support) - %'f (thousands in integer portion of %f) - %a/%A (exact hex representation of floating-point numbers) Garrett Wollman wrote the first version of the vfprintf.c update; Mike Barcroft wrote the first version of the printf.3 changes. Notes: svn path=/head/; revision=87113
* Fixed style bugs in previous commit.Bruce Evans2001-10-151-15/+15
| | | | Notes: svn path=/head/; revision=84962
* Make this compile on ia64.Doug Rabson2001-10-141-25/+46
| | | | Notes: svn path=/head/; revision=84922
* Mark some functions as __printflike() and/or taking const char * argumentsKris Kennaway2001-08-201-1/+1
| | | | | | | | | instead of char *. MFC after: 2 weeks Notes: svn path=/head/; revision=81975
* Remove freelists managed by Balloc/Bfree.Tor Egge2001-02-151-5/+18
| | | | | | | | | | | Change __dtoa to not free the string it allocated the previous time it was called. The caller now frees the string after usage if appropiate. PR: 15070 Reviewed by: deischen Notes: svn path=/head/; revision=72523
* Take decimal point from locale instead of hardcoded '.' (SUSv2)Andrey A. Chernov2001-02-101-9/+10
| | | | Notes: svn path=/head/; revision=72291
* Backout previous commit. Use of spinlocks was not approved.Tor Egge2001-02-091-18/+5
| | | | | | | PR: 15070 Notes: svn path=/head/; revision=72254
* Protect freelists managed by Balloc/Bfree with a spinlock.Tor Egge2001-02-081-5/+18
| | | | | | | | | | Change __dtoa to not free the string it allocated the previous time it was called. The caller now frees the string after usage if appropiate. PR: 15070 Notes: svn path=/head/; revision=72179
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-62/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch Notes: svn path=/head/; revision=71579
* Fix bugs in the handling of > 8 positional arguments:Archie Cobbs2001-01-061-14/+18
| | | | | | | | | | | - The stack was getting smashed by __grow_type_table() - reallocf() was being called with the wrong pointer - The maximum argument number was being incorrectly computed PR: misc/23521 Notes: svn path=/head/; revision=70725
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Add support for long long modifier (e.g. %llx, %lld).Doug Rabson1999-03-111-3/+9
| | | | | | | Reviewed by: bde Notes: svn path=/head/; revision=44674
* Replace memory leaking instances of realloc with non-leaking reallocf.Warner Losh1998-09-161-2/+2
| | | | | | | | | | | | | | In some cases replace if (a == null) a = malloc(x); else a = realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is guaranteed to be the same thing. I've been running these on my system here w/o ill effects for some time. However, the CTM-express is at part 6 of 34 for the CAM changes, so I've not been able to do a build world with the CAM in the tree with these changes. Shouldn't impact anything, but... Notes: svn path=/head/; revision=39327
* Don't assign the va_list variable 'ap' directly to the argtable becauseJohn Birrell1998-05-081-19/+18
| | | | | | | | va_list is not a pointer on alpha. Instead, use the va_arg() macro to return the address that is stored in the argtable. Notes: svn path=/head/; revision=35835
* Add FILE locking stubs for libc.John Birrell1998-04-111-17/+6
| | | | | | | | | | | Change the FILE locking to support kernel threads when linked with libpthread (which you haven't see yet). This requires that libc become thread-safe and thread-aware, testing __isthreaded before attempting to do lock/unlock calls. The impact on non-threaded programs is minor. This change works with libc_r, so it's the best compromise. Notes: svn path=/head/; revision=35129