Change fatal() and error() to use varargs.

This commit is contained in:
David Given 2013-05-10 12:04:21 +01:00
parent d91a1dc1a6
commit d89f172841
8 changed files with 37 additions and 11 deletions

View file

@ -10,6 +10,7 @@ static char rcsid[]= "$Id$";
#include <string.h>
#include "param.h"
#include "expr.h"
#include "extern.h"
#include <em_spec.h>
#include <em_flag.h>

View file

@ -8,6 +8,8 @@ static char rcsid[]= "$Id$";
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "extern.h"
int nerrors=0;
@ -24,24 +26,38 @@ goodbye() {
#endif
}
/*VARARGS1*/
fatal(s,a,b,c,d) char *s; {
void errorv(const char* s, va_list ap)
{
extern int lineno;
extern char *filename;
fprintf(stderr, "\"%s\", line %d:", filename, lineno);
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
nerrors++;
}
void fatal(const char* s, ...)
{
va_list ap;
va_start(ap, s);
errorv(s, ap);
va_end(ap);
error(s,a,b,c,d);
errorexit();
goodbye();
exit(-1);
}
/*VARARGS1*/
error(s,a,b,c,d) char *s; {
extern int lineno;
extern char *filename;
void error(const char* s, ...)
{
va_list ap;
fprintf(stderr,"\"%s\", line %d:",filename,lineno);
fprintf(stderr,s,a,b,c,d);
fprintf(stderr,"\n");
nerrors++;
va_start(ap, s);
errorv(s, ap);
va_end(ap);
}
#ifndef NDEBUG

View file

@ -40,3 +40,7 @@ extern int use_tes;
extern char *mystrcpy();
extern char *myalloc();
extern void error(const char* s, ...);
extern void fatal(const char* s, ...);

View file

@ -9,6 +9,7 @@ static char rcsid[]= "$Id$";
#include "assert.h"
#include "param.h"
#include "set.h"
#include "extern.h"
#include <stdio.h>
/*

View file

@ -9,6 +9,7 @@ static char rcsid[]= "$Id$";
#include "assert.h"
#include "param.h"
#include "lookup.h"
#include "extern.h"
char *myalloc();
char *mystrcpy();

View file

@ -8,6 +8,7 @@ static char rcsid[]= "$Id$";
#include <stdlib.h>
#include <stdio.h>
#include "extern.h"
char *filename;
char *beg_sbrk;

View file

@ -7,6 +7,7 @@ static char rcsid[]= "$Id$";
#endif
#include "param.h"
#include "extern.h"
int nstrings=0;
char *l_strings[MAXSTRINGS];

View file

@ -13,6 +13,7 @@ static char rcsid[]= "$Id$";
#include "set.h"
#include "instruct.h"
#include "lookup.h"
#include "extern.h"
#include <cgg_cg.h>
int wordsize;