Article View: comp.std.c
Article #3560Re: printf() format extensions - looking for beta testers...
From: Casper H.S. Dik - Network Securi...
Date: Sun, 14 Apr 1996 15:57
Date: Sun, 14 Apr 1996 15:57
42 lines
2042 bytes
2042 bytes
Ari Lukumies <aril@cmt.lpr.mail.carel.fi> writes:
> > format('!', bangcvt);
> >
> > /* do something which can generate an error */
> > fprintf(stderr, "%s: %!\n", "open failed");
> > }
>Given the above, how about calls like (well, not a pretty one, but you get the
>idea...):
> fprintf(stderr, "%-*.2!", something);
Yes, it seems that the format call back function (bangcvt) should take
a number of flags (leading 0/- found, precision, maximum width) and
a generic way to make the user defined format specifier output characters,
as it can be called from functions like "snprintf", which limit the output.
Passing a buffer to but the output in doesn't strike me as sufficient;
if "bangcvt" can have unlimited output, it must be possible for the
mechanism to cater for that.
And, of course, you want a input conversion as well :-)
So instead of:
> > int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
You'd get something more like:
bangcvt (va_list *ap, int flags, int width, int precision,
char fmt, int (*putit)(char c, void *output), void *output)
(Where you call "putit" for each character of output with *output
as magic for the call back)
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Technical Details
Message-ID:
<4kr78t$kao@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: Casper.Dik@Holland.Sun.COM (Casper H.S. Dik - Network Security Engineer) Newsgroups: comp.std.c,comp.lang.c.moderated Subject: Re: printf() format extensions - looking for beta testers... Date: 14 Apr 1996 10:57:17 -0500 Organization: Sun Microsystems, Netherlands Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4kr78t$kao@solutions.solon.com> References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com