ack/util/ncgg/error.c

76 lines
1.1 KiB
C
Raw Normal View History

1987-03-09 19:15:41 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1985-01-08 09:59:28 +00:00
#ifndef NORCSID
1994-06-24 11:31:16 +00:00
static char rcsid[]= "$Id$";
1985-01-08 09:59:28 +00:00
#endif
#include <stdlib.h>
1985-01-08 09:59:28 +00:00
#include <stdio.h>
#include <stdarg.h>
#include "extern.h"
1985-01-08 09:59:28 +00:00
int nerrors=0;
yyerror(s) char *s; {
error("Parser gives %s",s);
}
goodbye() {
error("This was fatal, goodbye!");
#ifndef NDEBUG
abort();
#endif
}
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);
1985-01-08 09:59:28 +00:00
errorexit();
goodbye();
exit(-1);
}
void error(const char* s, ...)
{
va_list ap;
1985-01-08 09:59:28 +00:00
va_start(ap, s);
errorv(s, ap);
va_end(ap);
1985-01-08 09:59:28 +00:00
}
#ifndef NDEBUG
badassertion(string,file,line) char *string,*file; {
fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n",
file,line,string);
goodbye();
}
#endif
tabovf(string) char *string; {
fatal("%s overflow",string);
}