use stdarg when compiling with ANSI C compiler

This commit is contained in:
ceriel 1995-08-17 15:20:35 +00:00
parent 0509996f7f
commit b7396a7cd4

View file

@ -15,7 +15,11 @@
number of arguments! number of arguments!
*/ */
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h> #include <varargs.h>
#endif
#include <system.h> #include <system.h>
#include "input.h" #include "input.h"
#include "f_info.h" #include "f_info.h"
@ -42,14 +46,76 @@ extern char *symbol2str();
node, whereas other errors use the information in the token. node, whereas other errors use the information in the token.
*/ */
#if __STDC__
/*VARARGS1*/
error(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_error(ERROR, fmt, ap);
va_end(ap);
}
/*VARARGS1*/
Gerror(char *fmt, ...)
{
va_list ap;
char *fn = FileName;
FileName = 0;
va_start(ap, fmt);
_error(ERROR, fmt, ap);
va_end(ap);
FileName = fn;
}
/*VARARGS1*/
lexerror(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_error(LEXERROR, fmt, ap);
va_end(ap);
}
/*VARARGS1*/
fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_error(FATAL, fmt, ap);
va_end(ap);
sys_stop(S_EXIT);
}
/*VARARGS1*/
crash(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_error(CRASH, fmt, ap);
va_end(ap);
#ifdef DEBUG
sys_stop(S_ABORT);
#else
sys_stop(S_EXIT);
#endif
}
#else
/*VARARGS1*/ /*VARARGS1*/
error(va_alist) error(va_alist)
va_dcl va_dcl
{ {
va_list ap; va_list ap;
char *fmt;
va_start(ap); va_start(ap);
_error(ERROR, ap); fmt = va_arg(ap, char *);
_error(ERROR, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -58,11 +124,13 @@ Gerror(va_alist)
va_dcl va_dcl
{ {
va_list ap; va_list ap;
char *fmt;
char *fn = FileName; char *fn = FileName;
FileName = 0; FileName = 0;
va_start(ap); va_start(ap);
_error(ERROR, ap); fmt = va_arg(ap, char *);
_error(ERROR, fmt, ap);
va_end(ap); va_end(ap);
FileName = fn; FileName = fn;
} }
@ -72,9 +140,11 @@ lexerror(va_alist)
va_dcl va_dcl
{ {
va_list ap; va_list ap;
char *fmt;
va_start(ap); va_start(ap);
_error(LEXERROR, ap); fmt = va_arg(ap, char *);
_error(LEXERROR, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -83,9 +153,11 @@ fatal(va_alist)
va_dcl va_dcl
{ {
va_list ap; va_list ap;
char *fmt;
va_start(ap); va_start(ap);
_error(FATAL, ap); fmt = va_arg(ap, char *);
_error(FATAL, fmt, ap);
va_end(ap); va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
@ -95,9 +167,11 @@ crash(va_alist)
va_dcl va_dcl
{ {
va_list ap; va_list ap;
char *fmt;
va_start(ap); va_start(ap);
_error(CRASH, ap); fmt = va_arg(ap, char *);
_error(CRASH, fmt, ap);
va_end(ap); va_end(ap);
#ifdef DEBUG #ifdef DEBUG
sys_stop(S_ABORT); sys_stop(S_ABORT);
@ -105,9 +179,11 @@ crash(va_alist)
sys_stop(S_EXIT); sys_stop(S_EXIT);
#endif #endif
} }
#endif
_error(class, argv) _error(class, fmt, argv)
int class; int class;
char *fmt;
va_list argv; va_list argv;
{ {
/* _error attempts to limit the number of error messages /* _error attempts to limit the number of error messages
@ -115,7 +191,6 @@ _error(class, argv)
*/ */
unsigned int ln = 0; unsigned int ln = 0;
register char *remark = 0; register char *remark = 0;
char *fmt = va_arg(argv, 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