| To: | yyyyyyyyyyyyyyyyyyyyyy@xxxxxxxxxxxxx |
|---|---|
| Subject: | test + formatting functions |
| From: | Bruce Korb <yyyyy@xxxxxxxxxxx> |
| Date: | Fri, 01 Aug 2003 08:47:52 -0700 |
In "the other list" ``asprintf'' was suggested as a function worthy
of consideration for standardization. I've seen more suggestions
beyond that, and the full cross product of possibilities seems like
a reasonable set to me:
A) result placement types:
1. stdout -- printf
2. FILE* -- fprintf
3. string -- sprintf
4. sized string -- snprintf
5. alloc string -- asprintf
6. file desc. -- dprintf
B) argument passing types:
1. vari-len list -- printf
2. var args -- vprintf
3. arg vector -- printfv
This makes it possible to dynamically compute the argument list.
the profile is: int printfv( const char *fmt, const void **argv )
yielding 18 functions
printf vprintf printfv
fprintf vfprintf fprintfv
sprintf vsprintf sprintfv
snprintf vsnprintf snprintfv
asprintf vasprintf asprintfv
dprintf vdprintf dprintfv
And, yes, there is an implementation:
http://savannah.nongnu.org/projects/libsnprintfv/
It has a few other features:
* output to a dynamically sized string ("filaments")
* user callbacks for formatting extensions. My favorite:
%{struct whatever}
to take an address as a pointer to a ``struct whatever''
and replace the above with the data formatted in some
reasonable way, likely by elf-opening the program file
and searching the symbol table.
Very Useful, and I've seen similar stuff in some other libraries,
but it might be a bit difficult to get agreement on a common approach.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: thread-private working directory, Dave Butenhof |
|---|---|
| Next by Date: | Re: test + formatting functions, Harti Brandt |
| Previous by Thread: | thread-private working directory, Alexander Terekhov |
| Next by Thread: | Re: test + formatting functions, Harti Brandt |
| Indexes: | [Date] [Thread] [All Lists] |