need info: %r in printf

Mark Horton mark at cbosgd.UUCP
Sat Oct 15 05:17:52 AEST 1983


I think %r was in UNIX/32V (undocumented) and possibly V7.
It went away in 4BSD and was never in System III or its
precursors.

Calling _doprnt is very unportable.  In particular, System III
and V don't have _doprnt, they have _print, with slightly
different conventions.  There are also slight differences
between V7 and 32V.

The next release of System V has something called vsprintf:
	vsprintf(string, format, ap)
	char *string, *fmt;
	va_list ap;
(see varargs(3)).  This is like sprintf, except that ap is
something that can be passed through more than one layer of
function (e.g. it's normally a pointer to the first argument
in the list.) Assuming you consider System V "standard",
this will be the first documented way to do this in "standard UNIX".

In general, this is useful when you want to provide a printf-style
routine for other routines to use.  It's great for debugging and
error messages.  It's also useful when you want to provide a
subroutine package - e.g. printw in curses.



More information about the Comp.unix.wizards mailing list