From: George Koehler Date: Fri, 17 Feb 2017 01:26:53 +0000 (-0500) Subject: Switch error() and fatal() in mach/proto/ncg to stdarg. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=aa47f52166c662e7e54ad5b1d120eee106769fa8;p=ack.git Switch error() and fatal() in mach/proto/ncg to stdarg. 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. --- diff --git a/mach/proto/ncg/extern.h b/mach/proto/ncg/extern.h index 3f376d4d1..e289eb8af 100644 --- a/mach/proto/ncg/extern.h +++ b/mach/proto/ncg/extern.h @@ -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, ...); diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index 0f1b8edc4..69d4493be 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -2,8 +2,9 @@ static char rcsid[] = "$Id$"; #endif -#include +#include #include +#include #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();