use varargs.h

This commit is contained in:
ceriel 1989-10-30 17:51:31 +00:00
parent a817264e90
commit 046d5b38a9

View file

@ -8,6 +8,7 @@
#include "debug.h" #include "debug.h"
#include "errout.h" #include "errout.h"
#include <varargs.h>
#include <em_arith.h> #include <em_arith.h>
#include <em_code.h> #include <em_code.h>
#include <em_label.h> #include <em_label.h>
@ -46,71 +47,125 @@ extern char *symbol2str();
*/ */
#ifdef DEBUG #ifdef DEBUG
/*VARARGS1*/ /*VARARGS*/
debug(fmt, args) debug(va_alist)
char *fmt; va_dcl
{ {
_error(VDEBUG, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(VDEBUG, NULLNODE, ap);
}
va_end(ap);
} }
#endif DEBUG #endif DEBUG
/*VARARGS1*/ /*VARARGS*/
error(fmt, args) error(va_alist)
char *fmt; va_dcl
{ {
_error(ERROR, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(ERROR, NULLNODE, ap);
}
va_end(ap);
} }
/*VARARGS2*/ /*VARARGS*/
node_error(node, fmt, args) node_error(va_alist)
struct node *node; va_dcl
char *fmt;
{ {
_error(ERROR, node, fmt, &args); va_list ap;
va_start(ap);
{
struct node *node = va_arg(ap, struct node *);
_error(ERROR, node, ap);
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
warning(fmt, args) warning(va_alist)
char *fmt; va_dcl
{ {
if( !options['w'] ) _error(WARNING, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(WARNING, NULLNODE, ap);
}
va_end(ap);
} }
/*VARARGS2*/ /*VARARGS*/
node_warning(node, fmt, args) node_warning(va_alist)
struct node *node; va_dcl
char *fmt;
{ {
if( !options['w'] ) _error(WARNING, node, fmt, &args); va_list ap;
va_start(ap);
{
struct node *node = va_arg(ap, struct node *);
_error(WARNING, node, ap);
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
lexerror(fmt, args) lexerror(va_alist)
char *fmt; va_dcl
{ {
_error(LEXERROR, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(LEXERROR, NULLNODE, ap);
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
lexwarning(fmt, args) lexwarning(va_alist)
char *fmt; va_dcl
{ {
if( !options['w'] ) _error(LEXWARNING, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(LEXWARNING, NULLNODE, ap);
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
fatal(fmt, args) fatal(va_alist)
char *fmt; va_dcl
{ {
_error(FATAL, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(FATAL, NULLNODE, ap);
}
va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
/*VARARGS1*/ /*VARARGS*/
crash(fmt, args) crash(va_alist)
char *fmt; va_dcl
{ {
_error(CRASH, NULLNODE, fmt, &args); va_list ap;
va_start(ap);
{
_error(CRASH, NULLNODE, ap);
}
va_end(ap);
#ifdef DEBUG #ifdef DEBUG
sys_stop(S_ABORT); sys_stop(S_ABORT);
#else #else
@ -118,11 +173,10 @@ crash(fmt, args)
#endif #endif
} }
_error(class, node, fmt, argv) _error(class, node, ap)
int class; int class;
struct node *node; struct node *node;
char *fmt; register va_list ap;
int argv[];
{ {
/* _error attempts to limit the number of error messages /* _error attempts to limit the number of error messages
for a given line to MAXERR_LINE. for a given line to MAXERR_LINE.
@ -132,6 +186,7 @@ _error(class, node, fmt, argv)
static char * last_fn = 0; static char * last_fn = 0;
static int e_seen = 0, w_seen = 0; static int e_seen = 0, w_seen = 0;
register char *remark = 0; register char *remark = 0;
char *fmt;
/* Since name and number are gathered from different places /* Since name and number are gathered from different places
depending on the class, we first collect the relevant depending on the class, we first collect the relevant
@ -152,6 +207,7 @@ _error(class, node, fmt, argv)
switch( class ) { switch( class ) {
case WARNING: case WARNING:
case LEXWARNING: case LEXWARNING:
if (options['w']) return;
remark = "(warning)"; remark = "(warning)";
break; break;
case CRASH: case CRASH:
@ -184,6 +240,7 @@ _error(class, node, fmt, argv)
break; break;
} }
fmt = va_arg(ap, char *);
#ifdef DEBUG #ifdef DEBUG
if( class != VDEBUG ) { if( class != VDEBUG ) {
#endif #endif
@ -217,6 +274,6 @@ _error(class, node, fmt, argv)
if( remark ) fprint(ERROUT, "%s ", remark); if( remark ) fprint(ERROUT, "%s ", remark);
doprnt(ERROUT, fmt, argv); /* contents of error */ doprnt(ERROUT, fmt, ap); /* contents of error */
fprint(ERROUT, "\n"); fprint(ERROUT, "\n");
} }