Switch error() and fatal() in mach/proto/ncg to stdarg.
authorGeorge Koehler <xkernigh@netscape.net>
Fri, 17 Feb 2017 01:26:53 +0000 (20:26 -0500)
committerGeorge Koehler <xkernigh@netscape.net>
Fri, 17 Feb 2017 01:26:53 +0000 (20:26 -0500)
This is like David Given's change to util/ncgg in d89f172.  I need
this change in mach/proto/ncg to see fatal messages, because a 64-bit
pointer doesn't fit in an int.

mach/proto/ncg/extern.h
mach/proto/ncg/subr.c

index 3f376d4..e289eb8 100644 (file)
@@ -54,4 +54,6 @@ extern int *rvnumbers[];              /* lists of numbers */
 #endif
 
 extern FILE *codefile;
-extern FILE *freopen();
+
+extern void error(const char *s, ...);
+extern void fatal(const char *s, ...);
index 0f1b8ed..69d4493 100644 (file)
@@ -2,8 +2,9 @@
 static char rcsid[] = "$Id$";
 #endif
 
-#include <stdlib.h>
+#include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "assert.h"
 #include "param.h"
 #include "tables.h"
@@ -657,11 +658,12 @@ itokcost() {
                tdp->t_cost.ct_space = costcalc(tdp->t_cost);
 }
 
-/*VARARGS1*/
-error(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; {
+void error(const char *s, ...) {
+       va_list ap;
 
+       va_start(ap,s);
        fprintf(stderr,"Error: ");
-       fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8);
+       vfprintf(stderr,s,ap);
        fprintf(stderr,"\n");
 #ifdef TABLEDEBUG
        ruletrace();
@@ -670,11 +672,12 @@ error(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; {
        exit(-1);
 }
 
-/*VARARGS1*/
-fatal(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; {
+void fatal(const char *s, ...) {
+       va_list ap;
 
+       va_start(ap,s);
        fprintf(stderr,"Fatal: ");
-       fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8);
+       vfprintf(stderr,s,ap);
        fprintf(stderr,"\n");
 #ifdef TABLEDEBUG
        ruletrace();