use stdarg when compiling with ANSI C compiler, and some other minor changes

This commit is contained in:
ceriel 1995-08-17 13:33:55 +00:00
parent a96a9107c8
commit acdb874527
3 changed files with 59 additions and 1 deletions

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 */ /* 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 <system.h> #include <system.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h> #include <varargs.h>
#endif
#include "errout.h" #include "errout.h"
#include "LLlex.h" #include "LLlex.h"
@ -27,6 +31,58 @@ err_hdr(s)
else fprint(ERROUT, s); else fprint(ERROUT, s);
} }
#if __STDC__
/*VARARGS1*/
error(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("");
err_occurred = 1;
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
}
/*VARARGS1*/
warning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("(warning) ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
}
/*VARARGS1*/
crash(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("CRASH\007 ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
sys_stop(S_ABORT);
}
/*VARARGS1*/
fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("fatal error -- ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
sys_stop(S_EXIT);
}
#else /* __STDC__ */
/*VARARGS1*/ /*VARARGS1*/
error(va_alist) error(va_alist)
va_dcl va_dcl
@ -89,3 +145,4 @@ fatal(va_alist)
va_end(ap); va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
#endif

View file

@ -9,6 +9,7 @@
#define INP_VAR finfo #define INP_VAR finfo
struct file_info finfo; struct file_info finfo;
#include <inp_pkg.body> #include <inp_pkg.body>
#include <alloc.h>
char * char *
getwdir(fn) getwdir(fn)

View file

@ -84,7 +84,7 @@ compile(argc, argv)
} }
if (!InsertFile(source, (char **) 0, &dummy)) /* read the source file */ if (!InsertFile(source, (char **) 0, &dummy)) /* read the source file */
fatal("%s: no source file %s\n", prog_name, fatal("%s: no source file %s", prog_name,
source ? source : "stdin"); source ? source : "stdin");
if (source) WorkingDir = getwdir(dummy); if (source) WorkingDir = getwdir(dummy);
preprocess(source); preprocess(source);