use stdarg when compiling with ANSI C compiler, and some other minor changes
authorceriel <none@none>
Thu, 17 Aug 1995 13:33:55 +0000 (13:33 +0000)
committerceriel <none@none>
Thu, 17 Aug 1995 13:33:55 +0000 (13:33 +0000)
util/cpp/error.c
util/cpp/input.c
util/cpp/main.c

index 99778db..11ffbf2 100644 (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       <system.h>
+#if __STDC__
+#include       <stdarg.h>
+#else
 #include       <varargs.h>
+#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
index 4e422e6..963da42 100644 (file)
@@ -9,6 +9,7 @@
 #define INP_VAR                finfo
 struct file_info       finfo;
 #include <inp_pkg.body>
+#include <alloc.h>
 
 char *
 getwdir(fn)
index 0acfbb4..d0471d7 100644 (file)
@@ -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);