1988-09-02 12:00:25 +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".
|
|
|
|
*/
|
|
|
|
/* $Header$ */
|
|
|
|
|
1988-08-07 22:55:20 +00:00
|
|
|
#include <varargs.h>
|
|
|
|
|
|
|
|
#include <system.h>
|
|
|
|
#include "inpdef.h"
|
|
|
|
|
|
|
|
#define MSGOUT STDERR /* filedes on which to write the messages */
|
|
|
|
#define ERROUT STDERR /* filedes on which to write the panics */
|
|
|
|
|
|
|
|
/* VARARGS */
|
|
|
|
report(va_alist)
|
|
|
|
va_dcl
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap);
|
|
|
|
{
|
|
|
|
char *fmt = va_arg(ap, char*);
|
|
|
|
register char *f = fmt;
|
|
|
|
register char fc;
|
|
|
|
|
|
|
|
/* First see if the first arg is an inpdef with
|
|
|
|
a global file name; if so, skip this message.
|
|
|
|
*/
|
|
|
|
if (f[0] == '%' && f[1] == 'L') {
|
|
|
|
/* it is an inpdef */
|
|
|
|
register struct inpdef *id =
|
|
|
|
va_arg(ap, struct inpdef *);
|
1988-09-02 12:00:25 +00:00
|
|
|
register char *fn = id->id_file;
|
1988-08-07 22:55:20 +00:00
|
|
|
|
|
|
|
f += 2;
|
1988-09-02 12:00:25 +00:00
|
|
|
|
|
|
|
if ( /* the file name global */
|
|
|
|
fn[0] == '/'
|
|
|
|
&& /* it is not a .c file */
|
|
|
|
strcmp(&fn[strlen(fn)-2], ".c") != 0
|
|
|
|
) {
|
|
|
|
/* we skip this message */
|
1988-08-07 22:55:20 +00:00
|
|
|
return;
|
1988-09-02 12:00:25 +00:00
|
|
|
}
|
|
|
|
/* otherwise, we have used up the argument,
|
1988-08-07 22:55:20 +00:00
|
|
|
so print it here
|
|
|
|
*/
|
|
|
|
fprint(MSGOUT, "\"%s\", line %d",
|
1988-09-02 12:00:25 +00:00
|
|
|
fn, id->id_line);
|
1988-08-07 22:55:20 +00:00
|
|
|
}
|
|
|
|
while ((fc = *f++)) {
|
|
|
|
if (fc == '%') {
|
|
|
|
switch (*f++) {
|
|
|
|
register struct inpdef *id;
|
|
|
|
register char *s;
|
|
|
|
register int i;
|
|
|
|
case 'L': /* a location item */
|
|
|
|
id = va_arg(ap, struct inpdef *);
|
|
|
|
fprint(MSGOUT, "\"%s\", line %d",
|
|
|
|
id->id_file, id->id_line);
|
|
|
|
break;
|
|
|
|
case 's': /* a string item */
|
|
|
|
s = va_arg(ap, char *);
|
|
|
|
fprint(MSGOUT, "%s", s);
|
|
|
|
break;
|
|
|
|
case 'd': /* an int item */
|
|
|
|
i = va_arg(ap, int);
|
|
|
|
fprint(MSGOUT, "%d", i);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("bad format %s", fmt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprint(MSGOUT, "%c", fc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprint(MSGOUT, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
|
|
|
panic(fmt, args)
|
|
|
|
char *fmt;
|
|
|
|
{
|
|
|
|
fprint(ERROUT, "PANIC, lint, pass2: ");
|
|
|
|
doprnt(ERROUT, fmt, &args);
|
|
|
|
fprint(ERROUT, "\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|