ack/lang/cem/lint/lpass2/report.c
1988-09-02 12:00:25 +00:00

95 lines
1.9 KiB
C

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#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 *);
register char *fn = id->id_file;
f += 2;
if ( /* the file name global */
fn[0] == '/'
&& /* it is not a .c file */
strcmp(&fn[strlen(fn)-2], ".c") != 0
) {
/* we skip this message */
return;
}
/* otherwise, we have used up the argument,
so print it here
*/
fprint(MSGOUT, "\"%s\", line %d",
fn, id->id_line);
}
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);
}