freebsd-nq/lib/libc/stdio
Poul-Henning Kamp 75067f4f70 Add an extensible version of our *printf(3) implementation to libc
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.
2005-12-16 18:56:39 +00:00
..
_flock_stub.c Backout the previous revision due to objections. 2004-03-09 04:51:58 +00:00
asprintf.c
clrerr.c
fclose.3 mdoc(7) police: "The .Fn function". 2002-12-18 12:45:11 +00:00
fclose.c
fdopen.c
feof.c Re-add macro versions of getc(), getchar(), putc(), putchar(), feof(), 2004-03-17 01:43:08 +00:00
ferror.3 mdoc(7) police: markup laundry. 2003-02-23 01:47:49 +00:00
ferror.c Re-add macro versions of getc(), getchar(), putc(), putchar(), feof(), 2004-03-17 01:43:08 +00:00
fflush.3 Add or correct section number in .Xr. Use .Vt or .Fn 2003-06-08 10:01:52 +00:00
fflush.c Add commentary explaining why we return EBADF upon attempts to fflush() a 2004-07-04 20:17:00 +00:00
fgetc.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
fgetln.3 Add a cross reference to fgetwln(3). 2004-07-16 06:07:12 +00:00
fgetln.c Rename slbexpand() to __slbexpand() and make it available outside 2004-07-16 05:52:51 +00:00
fgetpos.c
fgets.3 Remove references to nonexistent "FreeBSD Security Architecture" document. 2005-09-05 09:49:33 +00:00
fgets.c
fgetwc.c Call __mbrtowc() and __wcrtomb() directly instead of taking detours 2004-07-20 08:27:27 +00:00
fgetwln.3 Use the correct function name as .Nm argument. 2005-09-18 15:40:03 +00:00
fgetwln.c Fix an off-by-one bug that caused the first character of the buffer to 2004-08-06 17:00:09 +00:00
fgetws.3 MFp4: Add the standard "the {fgetws,fputws} function will fail if" text 2003-03-09 02:56:54 +00:00
fgetws.c Don't add integers to void pointers. 2004-10-03 15:48:32 +00:00
fileno.c Re-add macro versions of getc(), getchar(), putc(), putchar(), feof(), 2004-03-17 01:43:08 +00:00
findfp.c Associate a multibyte conversion state object with each stream. Reset it 2004-05-22 15:19:41 +00:00
flags.c
floatio.h Prototype __hdtoa() and __hldtoa(). 2004-01-18 08:28:47 +00:00
flockfile.3 Add missing word to "Return Values" section. 2003-01-13 01:29:14 +00:00
fopen.3 The correct description for mode "w" is 2005-05-04 08:12:44 +00:00
fopen.c
fprintf.c
fpurge.c
fputc.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
fputs.3 mdoc(7) police: "The .Fa argument.". 2002-12-19 09:40:28 +00:00
fputs.c
fputwc.c Call __mbrtowc() and __wcrtomb() directly instead of taking detours 2004-07-20 08:27:27 +00:00
fputws.3 Assorted mdoc(7) fixes. 2003-05-22 13:02:28 +00:00
fputws.c Implement the GNU extensions of mbsnrtowcs() and wcsnrtombs(). These are 2004-07-21 10:54:57 +00:00
fread.3
fread.c With current pthread implementations, a mutex initialization will 2005-12-16 02:50:53 +00:00
freopen.c Associate a multibyte conversion state object with each stream. Reset it 2004-05-22 15:19:41 +00:00
fscanf.c #include "local.h" to make __svfscanf()'s prototype visible. 2003-01-03 23:27:27 +00:00
fseek.3 Improve documentation for fgetpos() and fsetpos(), and discourage 2004-03-20 08:38:27 +00:00
fseek.c Associate a multibyte conversion state object with each stream. Reset it 2004-05-22 15:19:41 +00:00
fsetpos.c
ftell.c
funopen.3 Eliminate double whitespace. 2004-07-03 22:30:10 +00:00
funopen.c
fvwrite.c Rename cantwrite() to prepwrite(). The latter is less confusing, 2004-06-08 05:45:48 +00:00
fvwrite.h
fwalk.c
fwide.3 mdoc(7) police: "The .Fn function". 2002-12-18 12:45:11 +00:00
fwide.c
fwprintf.c
fwrite.c
fwscanf.c
getc.3 Fix prototype. 2005-11-23 20:26:58 +00:00
getc.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
getchar.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
gets.c Back out previous. Many people disagreed with removing the warning. 2003-01-30 23:32:53 +00:00
getw.c
getwc.3 Fix prototype. 2005-11-23 20:26:58 +00:00
getwc.c Provide trivial macro implementations of getwc(), getwchar(), putwc() and 2004-05-25 10:42:52 +00:00
getwchar.c Provide trivial macro implementations of getwc(), getwchar(), putwc() and 2004-05-25 10:42:52 +00:00
glue.h The header glue.h should provide just a declaration for the variable 2005-05-13 21:12:34 +00:00
local.h With current pthread implementations, a mutex initialization will 2005-12-16 02:50:53 +00:00
makebuf.c Move the declaration of __cleanup to libc_private.h as it is used in both 2005-09-12 13:46:32 +00:00
Makefile.inc Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
mktemp.3 Sort sections. 2005-01-20 09:17:07 +00:00
mktemp.c Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go). 2003-02-16 17:29:11 +00:00
perror.c Write the message to stderr, not file descriptor 2, so that perror() 2002-12-19 09:53:26 +00:00
printf.3 Remove references to nonexistent "FreeBSD Security Architecture" document. 2005-09-05 09:49:33 +00:00
printf.c
putc.3 Re-add description of putc() macro (back out rev. 1.13.) 2004-03-17 12:46:17 +00:00
putc.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
putchar.c Do not redundantly set the stream orientation in getc(), putc(), and 2004-03-19 09:04:56 +00:00
puts.c Set stream orientation in puts(). 2004-03-10 09:15:38 +00:00
putw.c
putwc.3 Refer to "wide characters" instead of "wide-characters". 2004-03-16 13:30:11 +00:00
putwc.c Provide trivial macro implementations of getwc(), getwchar(), putwc() and 2004-05-25 10:42:52 +00:00
putwchar.c Provide trivial macro implementations of getwc(), getwchar(), putwc() and 2004-05-25 10:42:52 +00:00
refill.c
remove.3
remove.c
rewind.c
rget.c
scanf.3 Update to reflect changes in vfscanf.c,v 1.32. Remove bogus 2003-06-28 09:03:25 +00:00
scanf.c #include "local.h" to make __svfscanf()'s prototype visible. 2003-01-03 23:27:27 +00:00
setbuf.3 Scheduled mdoc(7) sweep. 2005-01-11 20:50:51 +00:00
setbuf.c
setbuffer.c
setvbuf.c
snprintf.c
sprintf.c
sscanf.c
stdio.3 Sort sections. 2005-01-20 09:17:07 +00:00
stdio.c #include <stdlib.h> for free()'s prototype. 2003-01-07 06:17:13 +00:00
swprintf.c
swscanf.c
tempnam.c
tmpfile.c Fix use of an uninitialized pointer introduced in a previous revision. 2003-02-06 01:08:19 +00:00
tmpnam.3 Remove references to nonexistent "FreeBSD Security Architecture" document. 2005-09-05 09:49:33 +00:00
tmpnam.c
ungetc.3
ungetc.c Set stream orientation in ungetc() instead of __ungetc(). This avoids 2004-03-10 12:41:11 +00:00
ungetwc.3 Refer to "wide characters" instead of "wide-characters". 2004-03-16 13:30:11 +00:00
ungetwc.c Include <sys/types.h> and <limits.h> ourselves, don't assume they are included 2005-08-20 07:59:13 +00:00
unlocked.c Add function versions of getchar_unlocked(), getc_unlocked(), 2003-01-10 04:35:08 +00:00
vasprintf.c
vfprintf.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
vfscanf.c With current pthread implementations, a mutex initialization will 2005-12-16 02:50:53 +00:00
vfwprintf.c Be bug-for-bug compatible with the C standard with respect to 2005-04-16 22:36:51 +00:00
vfwscanf.c Include <sys/types.h> and <limits.h> ourselves, don't assume they are included 2005-08-20 07:59:13 +00:00
vprintf.c
vscanf.c #include "local.h" to make __svfscanf()'s prototype visible. 2003-01-03 23:27:27 +00:00
vsnprintf.c When size is 1 should just null terminate the string. The dummy variable 2003-07-02 07:08:44 +00:00
vsprintf.c
vsscanf.c
vswprintf.c Fix EOVERFLOW detection in vswprintf(3) 2005-02-21 19:41:44 +00:00
vswscanf.c Prepare to handle trivial state-dependent encodings. Full support for 2004-04-07 09:55:05 +00:00
vwprintf.c
vwscanf.c
wbuf.c Rename cantwrite() to prepwrite(). The latter is less confusing, 2004-06-08 05:45:32 +00:00
wprintf.3 Add more useful cross-references to the SEE ALSO section. 2003-07-05 07:55:34 +00:00
wprintf.c
wscanf.3 Catch up with recent FP-related changes to scanf.3 and vfwscanf.c. 2003-07-05 07:47:55 +00:00
wscanf.c
wsetup.c Set errno to EBADF on attempts to write to a stream that is not 2004-06-08 05:44:52 +00:00
xprintf_float.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf_hexdump.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf_int.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf_str.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf_time.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf_vis.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00
xprintf.c Add an extensible version of our *printf(3) implementation to libc 2005-12-16 18:56:39 +00:00