ack/util/cpp/error.c

149 lines
2.2 KiB
C
Raw Normal View History

1994-06-24 11:31:16 +00:00
/* $Id$ */
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".
*/
1987-01-06 15:16:53 +00:00
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */
#include <system.h>
#if __STDC__
#include <stdarg.h>
#else
1988-04-15 15:43:52 +00:00
#include <varargs.h>
#endif
1987-01-06 15:16:53 +00:00
#include "errout.h"
#include "LLlex.h"
/* This file contains the (non-portable) error-message and diagnostic
functions. Beware, they are called with a variable number of
arguments!
*/
int err_occurred;
err_hdr(s)
char *s;
{
1987-09-21 13:21:50 +00:00
if (FileName) {
fprint(ERROUT, "\"%s\", line %d: %s", FileName, LineNumber, s);
}
else fprint(ERROUT, s);
1987-01-06 15:16:53 +00:00
}
#if __STDC__
/*VARARGS1*/
error(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("");
err_occurred = 1;
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
}
/*VARARGS1*/
warning(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("(warning) ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
}
/*VARARGS1*/
crash(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("CRASH\007 ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
sys_stop(S_ABORT);
}
/*VARARGS1*/
fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_hdr("fatal error -- ");
doprnt(ERROUT, fmt, ap);
fprint(ERROUT, "\n");
va_end(ap);
sys_stop(S_EXIT);
}
#else /* __STDC__ */
1987-01-06 15:16:53 +00:00
/*VARARGS1*/
1988-04-15 15:43:52 +00:00
error(va_alist)
va_dcl
1987-01-06 15:16:53 +00:00
{
1988-04-15 15:43:52 +00:00
char *fmt;
va_list ap;
1987-01-06 15:16:53 +00:00
err_hdr("");
err_occurred = 1;
1988-04-15 15:43:52 +00:00
va_start(ap);
fmt = va_arg(ap, char *);
doprnt(ERROUT, fmt, ap);
1987-01-06 15:16:53 +00:00
fprint(ERROUT, "\n");
1988-04-15 15:43:52 +00:00
va_end(ap);
1987-01-06 15:16:53 +00:00
}
/*VARARGS1*/
1988-04-15 15:43:52 +00:00
warning(va_alist)
va_dcl
1987-01-06 15:16:53 +00:00
{
1988-04-15 15:43:52 +00:00
char *fmt;
va_list ap;
1987-08-07 19:54:45 +00:00
err_hdr("(warning) ");
1988-04-15 15:43:52 +00:00
va_start(ap);
fmt = va_arg(ap, char *);
doprnt(ERROUT, fmt, ap);
1987-01-06 15:16:53 +00:00
fprint(ERROUT, "\n");
1988-04-15 15:43:52 +00:00
va_end(ap);
1987-01-06 15:16:53 +00:00
}
/*VARARGS1*/
1988-04-15 15:43:52 +00:00
crash(va_alist)
va_dcl
1987-01-06 15:16:53 +00:00
{
1988-04-15 15:43:52 +00:00
char *fmt;
va_list ap;
1987-08-07 19:54:45 +00:00
err_hdr("CRASH\007 ");
1988-04-15 15:43:52 +00:00
va_start(ap);
fmt = va_arg(ap, char *);
doprnt(ERROUT, fmt, ap);
1987-01-06 15:16:53 +00:00
fprint(ERROUT, "\n");
1988-04-15 15:43:52 +00:00
va_end(ap);
1987-01-06 15:16:53 +00:00
sys_stop(S_ABORT);
}
/*VARARGS1*/
1988-04-15 15:43:52 +00:00
fatal(va_alist)
va_dcl
1987-01-06 15:16:53 +00:00
{
1988-04-15 15:43:52 +00:00
char *fmt;
va_list ap;
1987-08-07 19:54:45 +00:00
err_hdr("fatal error -- ");
1988-04-15 15:43:52 +00:00
va_start(ap);
fmt = va_arg(ap, char *);
doprnt(ERROUT, fmt, ap);
1987-01-06 15:16:53 +00:00
fprint(ERROUT, "\n");
1988-04-15 15:43:52 +00:00
va_end(ap);
1987-01-06 15:16:53 +00:00
sys_stop(S_EXIT);
}
#endif