[net.lang.c] What ever happened to %r in printf ?

lvc@danews.UUCP (Larry Cipriani) (05/29/86)

Does anyone know why the %r formatting option of printf was
never documented on older UNIX systems ?  It doesn't exist
on the Sys 5 Rel 2 we have.

This option lets you do things like:

	doprint("usage: %s: not found", argv[0]);

and for doprint we have:

doprint(fmt)
	char *fmt;
{
	stuff ...

	printf("%r", &fmt);

	other stuff ...
}

The %r tells printf to use &fmt as the address of a
printf formatting string, and to get the arguments
for it off the stack.  I don't know if it would
work if fmt contained another %r.  Can vprintf be
used to produce the same result ?

Thanks,
-- 

Larry Cipriani		AT&T Network Systems
danews!lvc		Mail responses to ihnp4!cbsck!lvc please - thanks
		"Nothing is worse than an itch you can never scratch."

ark@alice.UucP (Andrew Koenig) (05/30/86)

> The %r tells printf to use &fmt as the address of a
> printf formatting string, and to get the arguments
> for it off the stack.  I don't know if it would
> work if fmt contained another %r.  Can vprintf be
> used to produce the same result ?

Vprintf and varargs.h can be used to produce a very
similar result, but portably.

henry@utzoo.UUCP (Henry Spencer) (06/04/86)

> Does anyone know why the %r formatting option of printf was
> never documented on older UNIX systems ?  It doesn't exist
> on the Sys 5 Rel 2 we have.

There is no portable way to write the corresponding argument.  vprintf
(in cooperation with varargs.h) is intended as a portable way to get
the same effect.
-- 
Usenet(n): AT&T scheme to earn
revenue from otherwise-unused	Henry Spencer @ U of Toronto Zoology
late-night phone capacity.	{allegra,ihnp4,decvax,pyramid}!utzoo!henry

pa@lri.UUCP (Patrick Amar) (06/17/86)

Hello world!
I think that %r in printf was used to format a string in radix50.
This code is used to compact file names in the DEC RT11 operating
system on the PDP11. On this system only upper case letters and digits
are allowed for file names (XXXXXX.EXT).

This format was maybe used on V6 UNIX to talk to RT11 file system,
or for debug ???

				[pa]

guy@sun.UUCP (06/19/86)

> I think that %r in printf was used to format a string in radix50.

Nope.  No version of UNIX released by AT&T has any support for RADIX50
whatsoever.  The "r" stood for "remote", not "RADIX50"; "%r" told "printf"
that the next argument was a pointer to a "printf"-style argument list, and
that it should use that list instead of the one it was passed.  This is very
tricky to do portably, and impossible to do on some implementations, so it
was nuked in V7.

> This format was maybe used on V6 UNIX to talk to RT11 file system,

Nope.  No version of UNIX released by AT&T knows anything about RT11, except
for VAX versions which have to deal with VAX-11/780 console floppies.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com (or guy@sun.arpa)