use stdarg when compiling with ANSI C compiler

This commit is contained in:
ceriel 1995-08-17 16:51:09 +00:00
parent 7b207deeb7
commit 4c73887050

View file

@ -6,7 +6,11 @@
/* 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 "lint.h"
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <system.h>
#ifndef LINT
#include <em.h>
@ -60,6 +64,218 @@ extern char loptions[];
static _error();
#if __STDC__
/*VARARGS*/
error(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(ERROR, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
expr_error(struct expr *expr, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(ERROR, expr->ex_file, expr->ex_line, fmt, ap);
expr->ex_flags |= EX_ERROR;
}
}
va_end(ap);
}
/*VARARGS*/
lexstrict(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(STRICT, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
strict(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(STRICT, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
expr_strict(struct expr *expr, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(STRICT, expr->ex_file, expr->ex_line, fmt, ap);
}
}
va_end(ap);
}
#ifdef DEBUG
/*VARARGS*/
debug(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(DO_DEBUG, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
#endif /* DEBUG */
/*VARARGS*/
warning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
expr_warning(struct expr *expr, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(WARNING, expr->ex_file, expr->ex_line, fmt, ap);
}
}
va_end(ap);
}
#ifdef LINT
/*VARARGS*/
def_warning(struct def *def, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(WARNING, def->df_file, def->df_line, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
hwarning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
if (loptions['h'])
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
awarning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
if (loptions['a'])
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
#endif /* LINT */
/*VARARGS*/
lexerror(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(ERROR, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
lexwarning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(WARNING, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
/*VARARGS*/
crash(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(CRASH, FileName, LineNumber, fmt, ap);
}
va_end(ap);
C_close();
#ifdef DEBUG
sys_stop(S_ABORT);
#else /* DEBUG */
sys_stop(S_EXIT);
#endif /* DEBUG */
/* NOTREACHED */
}
/*VARARGS*/
fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
_error(FATAL, FileName, LineNumber, fmt, ap);
}
va_end(ap);
if (C_busy()) C_close();
sys_stop(S_EXIT);
/*NOTREACHED*/
}
#else
/*VARARGS*/
error(va_alist) /* fmt, args */
va_dcl
@ -68,7 +284,8 @@ error(va_alist) /* fmt, args */
va_start(ap);
{
_error(ERROR, dot.tk_file, dot.tk_line, ap);
char *fmt = va_arg(ap, char *);
_error(ERROR, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -82,10 +299,11 @@ expr_error(va_alist) /* expr, fmt, args */
va_start(ap);
{
register struct expr *expr = va_arg(ap, struct expr *);
char *fmt = va_arg(ap, char *);
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(ERROR, expr->ex_file, expr->ex_line, ap);
_error(ERROR, expr->ex_file, expr->ex_line, fmt, ap);
expr->ex_flags |= EX_ERROR;
}
}
@ -100,7 +318,8 @@ lexstrict(va_alist)
va_start(ap);
{
_error(STRICT, FileName, LineNumber, ap);
char *fmt = va_arg(ap, char *);
_error(STRICT, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
@ -113,7 +332,8 @@ strict(va_alist)
va_start(ap);
{
_error(STRICT, dot.tk_file, dot.tk_line, ap);
char *fmt = va_arg(ap, char *);
_error(STRICT, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -127,10 +347,11 @@ expr_strict(va_alist) /* expr, fmt, args */
va_start(ap);
{
struct expr *expr = va_arg(ap, struct expr *);
char *fmt = va_arg(ap, char *);
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(STRICT, expr->ex_file, expr->ex_line, ap);
_error(STRICT, expr->ex_file, expr->ex_line, fmt, ap);
}
}
va_end(ap);
@ -145,9 +366,8 @@ debug(va_alist)
va_start(ap);
{
_error(DO_DEBUG, dot.tk_file, dot.tk_line, ap);
/* _error(DO_DEBUG, NILEXPR, ap);
*/
char *fmt = va_arg(ap, char *);
_error(DO_DEBUG, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -161,9 +381,8 @@ warning(va_alist)
va_start(ap);
{
_error(WARNING, dot.tk_file, dot.tk_line, ap);
/* _error(WARNING, NILEXPR, ap);
*/
char *fmt = va_arg(ap, char *);
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -177,10 +396,11 @@ expr_warning(va_alist) /* expr, fmt, args */
va_start(ap);
{
struct expr *expr = va_arg(ap, struct expr *);
char *fmt = va_arg(ap, char *);
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
_error(WARNING, expr->ex_file, expr->ex_line, ap);
_error(WARNING, expr->ex_file, expr->ex_line, fmt, ap);
}
}
va_end(ap);
@ -197,8 +417,9 @@ def_warning(va_alist) /* def, fmt, args */
va_start(ap);
{
register struct def *def = va_arg(ap, struct def *);
char *fmt = va_arg(ap, char *);
_error(WARNING, def->df_file, def->df_line, ap);
_error(WARNING, def->df_file, def->df_line, fmt, ap);
}
va_end(ap);
}
@ -212,8 +433,9 @@ hwarning(va_alist) /* fmt, args */
va_start(ap);
{
char *fmt = va_arg(ap, char *);
if (loptions['h'])
_error(WARNING, dot.tk_file, dot.tk_line, ap);
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -226,8 +448,9 @@ awarning(va_alist) /* fmt, args */
va_start(ap);
{
char *fmt = va_arg(ap, char *);
if (loptions['a'])
_error(WARNING, dot.tk_file, dot.tk_line, ap);
_error(WARNING, dot.tk_file, dot.tk_line, fmt, ap);
}
va_end(ap);
}
@ -242,7 +465,8 @@ lexerror(va_alist) /* fmt, args */
va_start(ap);
{
_error(ERROR, FileName, LineNumber, ap);
char *fmt = va_arg(ap, char *);
_error(ERROR, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
@ -255,7 +479,8 @@ lexwarning(va_alist) /* fmt, args */
va_start(ap);
{
_error(WARNING, FileName, LineNumber, ap);
char *fmt = va_arg(ap, char *);
_error(WARNING, FileName, LineNumber, fmt, ap);
}
va_end(ap);
}
@ -268,7 +493,8 @@ crash(va_alist) /* fmt, args */
va_start(ap);
{
_error(CRASH, FileName, LineNumber, ap);
char *fmt = va_arg(ap, char *);
_error(CRASH, FileName, LineNumber, fmt, ap);
}
va_end(ap);
@ -289,7 +515,8 @@ fatal(va_alist) /* fmt, args */
va_start(ap);
{
_error(FATAL, FileName, LineNumber, ap);
char *fmt = va_arg(ap, char *);
_error(FATAL, FileName, LineNumber, fmt, ap);
}
va_end(ap);
@ -297,16 +524,17 @@ fatal(va_alist) /* fmt, args */
sys_stop(S_EXIT);
/*NOTREACHED*/
}
#endif
static
_error(class, fn, ln, ap)
_error(class, fn, ln, fmt, ap)
int class;
char *fn;
unsigned int ln;
char *fmt;
va_list ap;
{
char *remark;
char *fmt = va_arg(ap, char *);
/* check visibility of message */
switch (class) {