ack/util/ncgg/error.c

68 lines
972 B
C
Raw Permalink 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;
void yyerror(char *s)
{
1985-01-08 09:59:28 +00:00
error("Parser gives %s",s);
}
void goodbye(void) {
1985-01-08 09:59:28 +00:00
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
}
int tabovf(char *string)
{
1985-01-08 09:59:28 +00:00
fatal("%s overflow",string);
return 0;
1985-01-08 09:59:28 +00:00
}