housel@en.ecn.purdue.edu (Peter S. Housel) (12/17/88)
Here is an improved version of the 'varargs.h' file originally posted in EFTH report #47. There is also a version of vsprintf() included. This makes Frans Meulenbroeck's patch to the curses "printw.c" file unnecessary. (How this particular patch ever managed to work in the first place is beyond me...) Actually, what ought to happen is that _doprintf() should be renamed vfprintf(), and that it and all of the other printf() and scanf() routines should be rewritten in terms of varargs.h or stdarg.h, whichever is supported by POSIX. (I'll probably do this sometime soon.) -Peter S. Housel- housel@en.ecn.purdue.edu ...!pur-ee!housel #!/bin/sh echo 'x - varargs.h' sed 's/^X//' <<'**-varargs.h-EOF-**' >varargs.h X/* varargs.h */ X Xtypedef char *va_list; X X#define va_dcl int va_alist; X#define va_start(p) (p) = (va_list) &va_alist; X#define va_arg(p,type) ( (type *) ((p)+=sizeof(type)) )[-1] X#define va_end(p) X X#define vfprintf _doprintf X#define vprintf(fmt,args) vfprintf(stdout,fmt,args) **-varargs.h-EOF-** echo 'x - vsprintf.c' sed 's/^X//' <<'**-vsprintf.c-EOF-**' >vsprintf.c X#include <stdio.h> X#include <varargs.h> X Xchar *vsprintf(buf,format,argp) Xchar *buf, *format; Xva_list argp; X{ X FILE _tempfile; X X _tempfile._fd = -1; X _tempfile._flags = WRITEMODE + STRINGS; X _tempfile._buf = buf; X _tempfile._ptr = buf; X X vfprintf(&_tempfile,format,argp); X putc('\0',&_tempfile); X X return buf; X} **-vsprintf.c-EOF-** exit 0