Use varargs where needed

This commit is contained in:
ceriel 1988-04-15 15:07:51 +00:00
parent 648d745177
commit d1fee09721

View file

@ -5,6 +5,7 @@
/* $Header$ */ /* $Header$ */
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */ /* E R R O R A N D D I A G N O S T I C R O U T I N E S */
#include <varargs.h>
#include <system.h> #include <system.h>
#include <em.h> #include <em.h>
@ -18,7 +19,7 @@
#include "expr.h" #include "expr.h"
#include "LLlex.h" #include "LLlex.h"
/* This file contains the (non-portable) error-message and diagnostic /* This file contains the error-message and diagnostic
functions. Beware, they are called with a variable number of functions. Beware, they are called with a variable number of
arguments! arguments!
*/ */
@ -48,60 +49,93 @@ extern char options[];
*/ */
/*VARARGS1*/ /*VARARGS1*/
error(fmt, args) error(va_alist)
char *fmt; va_dcl
{ {
_error(ERROR, NILEXPR, fmt, &args); va_list ap;
va_start(ap);
_error(ERROR, NILEXPR, ap);
va_end(ap);
} }
/*VARARGS2*/ /*VARARGS2*/
expr_error(expr, fmt, args) expr_error(va_alist)
struct expr *expr; va_dcl
char *fmt;
{ {
if (expr->ex_flags & EX_ERROR) struct expr *expr;
return; /* to prevent proliferation */ va_list ap;
_error(ERROR, expr, fmt, &args);
expr->ex_flags |= EX_ERROR; va_start(ap);
expr = va_arg(ap, struct expr *);
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(ERROR, expr, ap);
expr->ex_flags |= EX_ERROR;
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS1*/
warning(fmt, args) warning(va_alist)
char *fmt; va_dcl
{ {
_error(WARNING, NILEXPR, fmt, &args); va_list ap;
va_start(ap);
_error(WARNING, NILEXPR, ap);
va_end(ap);
} }
/*VARARGS2*/ /*VARARGS2*/
expr_warning(expr, fmt, args) expr_warning(va_alist)
struct expr *expr; va_dcl
char *fmt;
{ {
if (expr->ex_flags & EX_ERROR) struct expr *expr;
return; /* to prevent proliferation */ va_list ap;
_error(WARNING, expr, fmt, &args);
va_start(ap);
expr = va_arg(ap, struct expr *);
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(WARNING, expr, ap);
}
va_end(ap);
} }
/*VARARGS1*/ /*VARARGS1*/
lexerror(fmt, args) lexerror(va_alist)
char *fmt; va_dcl
{ {
_error(LEXERROR, NILEXPR, fmt, &args); va_list ap;
va_start(ap);
_error(LEXERROR, NILEXPR, ap);
va_end(ap);
} }
#ifndef NOPP #ifndef NOPP
/*VARARGS1*/ /*VARARGS1*/
lexwarning(fmt, args) char *fmt; { lexwarning(va_alist)
_error(LEXWARNING, NILEXPR, fmt, &args); va_dcl
{
va_list ap;
va_start(ap);
_error(LEXWARNING, NILEXPR, ap);
va_end(ap);
} }
#endif NOPP #endif NOPP
/*VARARGS1*/ /*VARARGS1*/
crash(fmt, args) crash(va_alist)
char *fmt; va_dcl
int args;
{ {
_error(CRASH, NILEXPR, fmt, &args); va_list ap;
va_start(ap);
_error(CRASH, NILEXPR, ap);
va_end(ap);
C_close(); C_close();
#ifdef DEBUG #ifdef DEBUG
sys_stop(S_ABORT); sys_stop(S_ABORT);
@ -111,20 +145,22 @@ crash(fmt, args)
} }
/*VARARGS1*/ /*VARARGS1*/
fatal(fmt, args) fatal(va_alist)
char *fmt; va_dcl
int args;
{ {
va_list ap;
va_start(ap);
if (C_busy()) C_close(); if (C_busy()) C_close();
_error(FATAL, NILEXPR, fmt, &args); _error(FATAL, NILEXPR, ap);
va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
_error(class, expr, fmt, argv) _error(class, expr, ap)
int class; int class;
struct expr *expr; struct expr *expr;
char *fmt; 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.
@ -135,6 +171,7 @@ _error(class, expr, fmt, argv)
char *fn = 0; char *fn = 0;
unsigned int ln = 0; unsigned int ln = 0;
char *remark = 0; char *remark = 0;
char *fmt = va_arg(ap, char *);
/* 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
@ -209,6 +246,6 @@ _error(class, expr, fmt, argv)
fprint(ERROUT, "\"%s\", line %u: ", fn, ln); fprint(ERROUT, "\"%s\", line %u: ", fn, ln);
if (remark) if (remark)
fprint(ERROUT, "%s ", 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");
} }