This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Extending vfprintf and family
- From: Philip Prindeville <philipp_subx at redfish-solutions dot com>
- To: Ryan Arnold <ryan dot arnold at linaro dot org>
- Cc: Russ Allbery <eagle at eyrie dot org>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Tue, 19 Aug 2014 12:33:58 -0600
- Subject: Re: Extending vfprintf and family
- Authentication-results: sourceware.org; auth=none
- References: <6B382F29-D813-41AA-ADA1-EDF9EE541704 at redfish-solutions dot com> <87oavm7vws dot fsf at hope dot eyrie dot org> <5A3CB9A1-7A05-4A76-BC7B-5EF3CF16CF3F at redfish-solutions dot com> <CAJE4xBPu9cexqSAn6Y9iV4wG+_jOw_yrwpy57xXYA5iVEkyysQ at mail dot gmail dot com>
Hmmmâ Actually, there already is a standard for format specifiers for common network objects, or at least there is in Linux.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/lib/vsprintf.c?id=refs/tags/v3.16.1#n1608
It doesnât look like most of this could be implemented using register_printf_*(). It doesnât seem to me that the state machine which parses the format could pick up characters past the actual conversion specifier itself:
Format of the format string
The format string is a character string, beginning and ending in its
initial shift state, if any. The format string is composed of zero or
more directives: ordinary characters (not %), which are copied
unchanged to the output stream; and conversion specifications, each of
which results in fetching zero or more subsequent arguments. Each conâ
version specification is introduced by the character %, and ends with a
conversion specifier.
Looks like libbacktrace would be required, at a minimum. And the printf_function() would need to be able to peek ahead in the format string and consume extra charactersâ which itâs not able to do.
Looks like it would be easier just to port the vsnprintf code from the Linux kernel. Sigh.
-Philip