🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3557

Re: printf() format extensions - looking for beta testers...

#3557
From: Sean 'Captain Napalm' Conner
Date: Sat, 13 Apr 1996 13:58
30 lines
1858 bytes
In article <4kll9l$o5h@solutions.solon.com> seebs@taniemarie.solon.com (Peter Seebach) writes:
 >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.
 >
  But there is a potential problem with doing this.  What if you use a
pre-compiled module that has extended printf(), say, using '%#' (unbeknownst
to you, the documentation may be a bit lax (happens enough)).  What happens
when you try to extend printf() using '%#'?  With possible different
semantics (different type, say)?

  -spc (Or does your printf() report a redefinition error?)
Technical Details
Message-ID: <4kobun$8i2@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> <4kll9l$o5h@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: spc@gate.net (Sean 'Captain Napalm' Conner)
Newsgroups: comp.std.c,comp.lang.c.moderated
Subject: Re: printf() format extensions - looking for beta testers...
Date: 13 Apr 1996 08:58:47 -0500
Organization: CyberGate, Inc.
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4kobun$8i2@solutions.solon.com>
References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> <4kll9l$o5h@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com