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>
|
1988-09-30 15:20:24 +00:00
|
|
|
#include "private.h"
|
1991-03-08 15:54:05 +00:00
|
|
|
#include "../lpass1/l_class.h"
|
1988-09-30 15:20:24 +00:00
|
|
|
#include "class.h"
|
1988-08-07 22:55:20 +00:00
|
|
|
#include "inpdef.h"
|
|
|
|
|
1991-03-08 15:54:05 +00:00
|
|
|
#define MSGOUT STDERR /* file descr. on which to write the messages */
|
|
|
|
#define ERROUT STDERR /* file descr. on which to write the panics */
|
1988-08-07 22:55:20 +00:00
|
|
|
|
1988-10-12 15:49:11 +00:00
|
|
|
extern int LineNr;
|
|
|
|
|
1988-09-30 15:20:24 +00:00
|
|
|
PRIVATE rep_loc();
|
|
|
|
|
1988-08-07 22:55:20 +00:00
|
|
|
/* 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
|
1988-09-30 15:20:24 +00:00
|
|
|
a global file name not ending in .c; if so,
|
|
|
|
skip this message.
|
1988-08-07 22:55:20 +00:00
|
|
|
*/
|
|
|
|
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 *);
|
1988-09-30 15:20:24 +00:00
|
|
|
rep_loc(id);
|
1988-08-07 22:55:20 +00:00
|
|
|
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:
|
1991-03-08 15:54:05 +00:00
|
|
|
panic("internal error: bad format %s",
|
|
|
|
fmt);
|
1988-08-07 22:55:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprint(MSGOUT, "%c", fc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprint(MSGOUT, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
1988-09-30 15:20:24 +00:00
|
|
|
PRIVATE
|
|
|
|
rep_loc(id)
|
|
|
|
struct inpdef *id;
|
|
|
|
{
|
1988-10-12 15:49:11 +00:00
|
|
|
/* a definition can come from a number of places */
|
|
|
|
if (!id) {
|
|
|
|
fprint(MSGOUT, "format");
|
|
|
|
}
|
|
|
|
else
|
1988-09-30 15:20:24 +00:00
|
|
|
if (is_class(id, CL_LIB)) {
|
1989-10-04 15:36:56 +00:00
|
|
|
fprint(MSGOUT, "library");
|
1988-09-30 15:20:24 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprint(MSGOUT, "\"%s\", line %d",
|
|
|
|
id->id_file, id->id_line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1989-10-04 16:04:02 +00:00
|
|
|
/* VARARGS */
|
|
|
|
panic(va_alist) /* fmt, args */
|
|
|
|
va_dcl
|
1988-08-07 22:55:20 +00:00
|
|
|
{
|
1989-10-04 16:04:02 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap);
|
|
|
|
{
|
|
|
|
char *fmt = va_arg(ap, char *);
|
|
|
|
|
|
|
|
fprint(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr);
|
|
|
|
doprnt(ERROUT, fmt, ap);
|
|
|
|
fprint(ERROUT, "\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
1988-08-07 22:55:20 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|