[comp.unix.questions] printf implementation again

srini@diablo.amd.com (02/03/90)

In article <22238@mimsy.umd.edu> you write:
>>Also, how is printf implemeted (upto the _write level) in library?
>>It calls a function _doprnt. What happens from there?
>
>What makes you think it calls _doprnt?  Mine calls vfprintf.

Does vprintf call _doprnt? From what I have found so far, _doprnt
is called, _flsbuf is called to flush buffer, and a memory copy
(memcpy) is done to copy from buffer to file. Other functions that
are involved are _fwrite (where memcpy is done?), _fconv, which
converts everything (?) to strings so that they can be printed.
There may be others.
If all these are implementation dependent, then let me rephrase my
original question. What are the factors that are assumed or 
considered to implement printf or in the already existing printf
implementation(s)?


Srini
-----
Post reply. Or send to srini@cayman.amd.com.

chris@mimsy.umd.edu (Chris Torek) (02/04/90)

In article <29039@amdcad.AMD.COM> srini@diablo.amd.com writes:
>Does vprintf call _doprnt? From what I have found so far, _doprnt
>is called, _flsbuf is called to flush buffer, and a memory copy
>(memcpy) is done to copy from buffer to file.

If you were to trace my stdio, you would see:
	1. printf/fprintf/sprintf
	2. vfprintf
	3. __spstr (someday, a static symbol)
	4. (if buffer fills) __swrite + write

You would also find that there is no function called `_doprnt'.

>If all these are implementation dependent, then let me rephrase my
>original question. What are the factors that are assumed or 
>considered to implement printf or in the already existing printf
>implementation(s)?

All the details are implementation dependent: I suspect neither
__spstr nor __swrite appear in any other stdio, nor will I say what
their call sequence is.  In my implementation, vfprintf() (with
funopen(), a new function that opens functions to do I/O) gives you
everything you need.

The factors that are assumed and considered are those outlined in
the ANSI standard or the SVID or some other applicable standard.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris