summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/xprintf_time.c
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
* 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.)
* Remove spurious "union arg" from printf.hphk2006-02-041-2/+3
| | | | Make sure to always print something in the alternate time format.
* Add missing 's' suffix on alternate rendition of time.phk2006-01-311-1/+1
|
* Add an extensible version of our *printf(3) implementation to libcphk2005-12-161-0/+114
on probationary terms: it may go away again if it transpires it is a bad idea. This extensible printf version will only be used if either environment variable USE_XPRINTF is defined or one of the extension functions are called. or the global variable __use_xprintf is set greater than zero. In all other cases our traditional printf implementation will be used. The extensible version is slower than the default printf, mostly because less opportunity for combining I/O operation exists when faced with extensions. The default printf on the other hand is a bad case of spaghetti code. The extension API has a GLIBC compatible part and a FreeBSD version of same. The FreeBSD version exists because the GLIBC version may run afoul of our FILE * locking in multithreaded programs and it even further eliminate the opportunities for combining I/O operations. Include three demo extensions which can be enabled if desired: time (%T), hexdump (%H) and strvis (%V). %T can format time_t (%T), struct timeval (%lT) and struct timespec (%llT) in one of two human readable duration formats: "%.3llT" -> "20349.245" "%#.3llT" -> "5h39m9.245" %H will hexdump a sequence of bytes and takes a pointer and a length argument. The width specifies number of bytes per line. "%4H" -> "65 72 20 65" "%+4H" -> "0000 65 72 20 65" "%#4H" -> "65 72 20 65 |er e|" "%+#4H" -> "0000 65 72 20 65 |er e|" %V will dump a string in strvis format. "%V" -> "Hello\tWor\377ld" (C-style) "%0V" -> "Hello\011Wor\377ld" (octal) "%+V" -> "Hello%09Wor%FFld" (http-style) Tests, comments, bugreports etc are most welcome.
OpenPOWER on IntegriCloud