From acdb874527df9642bb88cbd96e700a3040fcb68f Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 17 Aug 1995 13:33:55 +0000 Subject: [PATCH] use stdarg when compiling with ANSI C compiler, and some other minor changes --- util/cpp/error.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ util/cpp/input.c | 1 + util/cpp/main.c | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/util/cpp/error.c b/util/cpp/error.c index 99778dbfd..11ffbf276 100644 --- a/util/cpp/error.c +++ b/util/cpp/error.c @@ -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 +#if __STDC__ +#include +#else #include +#endif #include "errout.h" #include "LLlex.h" @@ -27,6 +31,58 @@ err_hdr(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*/ error(va_alist) va_dcl @@ -89,3 +145,4 @@ fatal(va_alist) va_end(ap); sys_stop(S_EXIT); } +#endif diff --git a/util/cpp/input.c b/util/cpp/input.c index 4e422e67a..963da429d 100644 --- a/util/cpp/input.c +++ b/util/cpp/input.c @@ -9,6 +9,7 @@ #define INP_VAR finfo struct file_info finfo; #include +#include char * getwdir(fn) diff --git a/util/cpp/main.c b/util/cpp/main.c index 0acfbb411..d0471d7d5 100644 --- a/util/cpp/main.c +++ b/util/cpp/main.c @@ -84,7 +84,7 @@ compile(argc, argv) } 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"); if (source) WorkingDir = getwdir(dummy); preprocess(source); -- 2.34.1