Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!sdcsvax!ucbvax!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: comp.lang.c Subject: Questions on vsprintf(), vsscanf(), stdarg.h, varargs.h Message-ID: <2545@hoptoad.uucp> Date: Tue, 28-Jul-87 05:38:32 EDT Article-I.D.: hoptoad.2545 Posted: Tue Jul 28 05:38:32 1987 Date-Received: Wed, 29-Jul-87 05:33:40 EDT Organization: Nebula Consultants in San Francisco Lines: 34 Tonight I reimplemented the curses routine printw(), which used to call into the guts of stdio, using vsprintf(). I could not reimplement scanw() because there is apparently no vsscanf(). If not, why not? I looked both in the Sun documentation (Rel 3.3) and in the draft C standard. This seems like an obvious omission. Also, I noticed that the Sun documentation for varargs says: "The argument list (or its remainder) can be passed to another function using a pointer to a variable of type va_list -- in which case a call to va_arg in the subroutine advances the argument-list pointer with respect to the caller as well." On the other hand, vsprintf() wants the argument list passed as a variable of type va_list, not a pointer to such a variable. It is not clear what effect this has on the argument pointer, since the type of va_list is unknown, and vsprintf() doesn't document the effect. In the draft C standard, it specifies: "The type declared is va_list which is an array type... The variable ap may be passed as an argument to another function." (ap refers to the parameter declared as va_list.) If passed to another function, the array will be converted to a pointer, which presumably means that calls to va_arg in the subroutine would also advance the argument pointer, as documented in SunOS. The standard should specify this behaviour rather than leaving it to be inferred. (Actually the standard should standardizerather than a newly invented, incompatible construction.) -- {dasys1,ncoast,well,sun,ihnp4}!hoptoad!gnu gnu@postgres.berkeley.edu Alt.all: the alternative radio of the Usenet.