Path: utzoo!attcan!uunet!husc6!purdue!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: "%#s"? Message-ID: <11713@mimsy.UUCP> Date: 28 May 88 19:00:36 GMT References: Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 In article jk3k+@andrew.cmu.edu (Joe Keane) writes: >It would be nice for printf et al. to have a %#s format specifier, >to convert unprintable characters into backslash escapes. Thus > printf ("%#s", "\b\fhi\n\207"); >would be equivalent to > printf ("\\b\\fhi\\n\\207"); There are many things that might be nice: Roman numerals (both upper and lower case: %r and %R are both free), unsigned decimal conversions, chopped vs. rounded (and up or down?) floating numbers, and so forth. But some of us feel that printf is already too complex. (Keith Bostic and I spent a week arguing over exactly what printf is supposed to do in odd cases, poring over ANSI drafts, and coming up with perverse test cases like `%500.400g' or `%#0500x'. The 4.3BSD _doprnt fails the huge-fill-count tests, incidentally.) >Has anyone else thought of this? Yes. >Is it a good idea? Possibly. You can always your own code for it. (Probably the best way to augment printf, if it is to be augmented at all, is to add a `%' conversion that calls a function, passing it the various flags and specifiers and the FILE and va_list arguments. The function would return the number of characters transferred. At least, that would fit well with our new _doprnt.) >Can it be put in the standard? Anything that is not an `editorial change' is probably not going to make it. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris