USG and _doprnt
Guy Harris
guy at rlgvax.UUCP
Wed Dec 12 09:45:56 AEST 1984
> In non-USG versions, *printf calls _doprnt which does the work.
> In our Hewlett-Packard 9000, there is no such function (usually
> written in assembler so far as I know) and the man
> claims that the printf familiy calls getc. We have some code
> here which was written including _doprnt, and wonder if there
> is an equivalent call. The HP runs essentially Sys III, and this
> posting assumes that the disappearance of _doprnt is common
> to Unix Support Group versions although I welcome correction. Even
> more welcome is help in finding a substitute (including the varargs
> stuff) for _doprnt.
Well, in System III "*printf" may call "_doprnt" in the VAX version, but
don't depend on it. System III had undocumented routines called
"vprintf", "vsprintf", and "vfprintf" which did what you want - in effect,
they had calling sequences similar to "_doprnt" (we used "vsprintf" for
our "curses" implementation). Those routines disappeared in System V,
and reappeared in System V Release 2 with documentation (along with "_doprnt",
which reappeared but without documentation). Basically, all the "v*printf"
routines take a "va_list" argument (as seen on "varargs.h" :-)) instead of
their normal list of arguments to be printed; i.e., you call "vprintf" with
vprintf(format_string, va_list_argument);
I *believe* that the argument would be a pointer to the first argument
in the list of things to be printed by the caller of "vprintf"; the same
pointer is passed to "_doprnt" as one of its arguments.
WARNING: as Henry Spencer and others have pointed out, there is *NO*
guarantee that any of the "varargs" stuff, including "v*printf", is
implementable on any particular machine and C implementation. (Henry
knows whereof he speaks, because he worked on the Perq implementation
of C and UNIX - stack machines like the Perq tend to assume that the
*called* routine handles the argument list, which is very hard to do if
only the *calling* routine knows how many arguments it's passing).
There is no guarantee that they are available on any particular S3
implementation (they're not documented), and there is almost a guarantee
that they are not available under S5 Release 1 (they weren't provided).
There is no guarantee at all that "_doprnt" will be available, or will
work the way you expect it to, under *any* release of UNIX (except 4.2BSD,
where it is documented - a mistake, in my opinion; they should have written
their own "v*printf" implementation and used that, instead); Zilog's ZEUS V7
implementation didn't have it, because they had to screw around a lot
to get "printf" to work. They put some arguments into registers in their
calling sequence, which means all the "varargs" stuff is a bitch. I
have no idea if any ZEUS release has the "varargs" stuff.
Guy Harris
{seismo,ihnp4,allegra}!rlgvax!guy
More information about the Comp.unix
mailing list