Article View: comp.std.c
Article #3555Re: printf() format extensions - looking for beta testers...
From: Peter Seebach
Date: Fri, 12 Apr 1996 13:19
Date: Fri, 12 Apr 1996 13:19
23 lines
1310 bytes
1310 bytes
In article <4klicn$ndl@solutions.solon.com>,
Ari Lukumies <aril@cmt.lpr.mail.carel.fi> wrote:
>Peter Seebach wrote:
> > int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
> > strncpy(s, strerror(errno), len);
> > s[len - 1] = '\0';
> > return strlen(s);
> > }
>Given the above, how about calls like (well, not a pretty one, but you get the
>idea...):
> fprintf(stderr, "%-*.2!", something);
This would call
bangcvt(&ap, buf, len, { '!', something, 2, FMT_LEFT });
and leave the interpretation of the width and precision up to bangcvt.
flags are or'ed together.
It might not work correctly; I think my sample implementation may have a bug
in handling flags. The principle is as given, though.
-s
Technical Details
Message-ID:
<4kll9l$o5h@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: seebs@taniemarie.solon.com (Peter Seebach) Newsgroups: comp.std.c,comp.lang.c.moderated Subject: Re: printf() format extensions - looking for beta testers... Date: 12 Apr 1996 08:19:49 -0500 Organization: Usenet Fact Police (Undercover) Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4kll9l$o5h@solutions.solon.com> References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com