Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl
From: karl@haddock.ISC.COM (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: "%#s"?
Message-ID: <4392@haddock.ISC.COM>
Date: 3 Jun 88 05:32:31 GMT
References: <1988May28.222450.2680@utzoo.uucp> <4311@haddock.ISC.COM> <1043@cresswell.quintus.UUCP>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 28
In article <1043@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
>In article <4311@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes:
>>Since the result is probably going to be handed to printf anyway, I'd get
>>rid of the width/places arguments and let printf handle them. This keeps
>>the function simpler.
>
>It also makes it very little use [because the argument may not be terminated
>by a null character]
True. I think I'd handle it with separate functions, perhaps called
strview(), strnview(), and memview().
>I think we can describe the proposed effect of %#c quite succinctly:
>... both '' and "" would be legal C constants ...
So '\'' and '"' would be escaped, in addition to '\\'? I hadn't considered
that, but I suppose it makes sense (especially if the application is a
code generator, rather than a debugging routine).
>The effect of %#s would be the effect of the appropriate sequence of %#c
>instances.
Assuming that the C constant "" should represent the argument to %#s, this
may not always be possible: as of the Jan88 dpANS, the only way to write the
two-character string "\x400""3" without using string-pasting is to write the
character '3' in octal or hex, but %#c would want to emit a '3'.
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint