Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.6.2.17 $; site uiucuxc.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!uiucuxc!hamilton
From: hamilton@uiucuxc.UUCP
Newsgroups: net.lang.c
Subject: Re: Re: gripe: variable arg lists
Message-ID: <21000015@uiucuxc.UUCP>
Date: Tue, 11-Dec-84 18:12:00 EST
Article-I.D.: uiucuxc.21000015
Posted: Tue Dec 11 18:12:00 1984
Date-Received: Thu, 13-Dec-84 00:46:17 EST
References: <4648@utzoo.UUCP>
Lines: 34
Nf-ID: #R:utzoo:-464800:uiucuxc:21000015:000:1091
Nf-From: uiucuxc!hamilton    Dec 11 17:12:00 1984

>> ... The secret is a little subroutine that knows where arguments are to be
>> found and ... builds a contiguous memory array of them. ... I think
>> that with sufficient "cleverness", one can always get away with this
>> type of trick.
>
>Does the magic routine parse the printf string to find out how many
>arguments there are?  If not, how does it determine this?

i think the "secret" subroutine he's referring to is _vaarg(), which gets
called by the va_arg macro in .  however, it doesn't really
build up a list; since it's called in a sequential-access mode, it only
scans a pointer across the places where args are stashed.  it's main
job is figuring when that pointer needs to jump from the register frame
to the stack.

other lovers of _doprnt() who have migrated to a pyramid 90x, try this:

	#include 
	main ()
	{
	    foo ("%d %.0f %s\n", 1, 2., "3");
	}

	foo (fmt, args)
	    char *fmt;
	    int args;
	{
	    int varargs_block[3];

	    _doprnt (fmt, _vastart (varargs_block, &args), stdout);
	}

wayne ({decvax,ucbvax}!pur-ee!uiucdcs!uiucuxc!)hamilton