From owner-cvs-src@FreeBSD.ORG Fri Dec 16 18:56:40 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7A2BD16A41F; Fri, 16 Dec 2005 18:56:40 +0000 (GMT) (envelope-from phk@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C06243D66; Fri, 16 Dec 2005 18:56:39 +0000 (GMT) (envelope-from phk@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jBGIudsX093609; Fri, 16 Dec 2005 18:56:39 GMT (envelope-from phk@repoman.freebsd.org) Received: (from phk@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jBGIudig093608; Fri, 16 Dec 2005 18:56:39 GMT (envelope-from phk) Message-Id: <200512161856.jBGIudig093608@repoman.freebsd.org> From: Poul-Henning Kamp Date: Fri, 16 Dec 2005 18:56:39 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/include Makefile printf.h src/lib/libc/stdio Makefile.inc vfprintf.c xprintf.c xprintf_float.c xprintf_hexdump.c xprintf_int.c xprintf_str.c xprintf_time.c xprintf_vis.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 18:56:40 -0000 phk 2005-12-16 18:56:39 UTC FreeBSD src repository Modified files: include Makefile lib/libc/stdio Makefile.inc vfprintf.c Added files: include printf.h lib/libc/stdio xprintf.c xprintf_float.c xprintf_hexdump.c xprintf_int.c xprintf_str.c xprintf_time.c xprintf_vis.c Log: 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. Revision Changes Path 1.253 +1 -1 src/include/Makefile 1.1 +155 -0 src/include/printf.h (new) 1.34 +3 -0 src/lib/libc/stdio/Makefile.inc 1.72 +7 -0 src/lib/libc/stdio/vfprintf.c 1.1 +674 -0 src/lib/libc/stdio/xprintf.c (new) 1.1 +425 -0 src/lib/libc/stdio/xprintf_float.c (new) 1.1 +97 -0 src/lib/libc/stdio/xprintf_hexdump.c (new) 1.1 +471 -0 src/lib/libc/stdio/xprintf_int.c (new) 1.1 +187 -0 src/lib/libc/stdio/xprintf_str.c (new) 1.1 +114 -0 src/lib/libc/stdio/xprintf_time.c (new) 1.1 +76 -0 src/lib/libc/stdio/xprintf_vis.c (new)