summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/yacc/error.c112
1 files changed, 59 insertions, 53 deletions
diff --git a/usr.bin/yacc/error.c b/usr.bin/yacc/error.c
index 5826d66..f34eac2 100644
--- a/usr.bin/yacc/error.c
+++ b/usr.bin/yacc/error.c
@@ -39,12 +39,13 @@
static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
#endif
#endif
-
#include <sys/cdefs.h>
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
#endif
+#include <stdlib.h>
+
/* routines for printing error messages */
#include "defs.h"
@@ -55,7 +56,7 @@ void
fatal(msg)
const char *msg;
{
- warnx("f - %s", msg);
+ warnx("%s: f - %s", getprogname(), msg);
done(2);
}
@@ -63,7 +64,7 @@ const char *msg;
void
no_space()
{
- warnx("f - out of space");
+ warnx("%s: f - out of space", getprogname());
done(2);
}
@@ -72,7 +73,7 @@ void
open_error(filename)
const char *filename;
{
- warnx("f - cannot open \"%s\"", filename);
+ warnx("%s: f - cannot open \"%s\"", getprogname(), filename);
done(2);
}
@@ -80,8 +81,8 @@ const char *filename;
void
unexpected_EOF()
{
- warnx("e - line %d of \"%s\", unexpected end-of-file",
- lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unexpected end-of-file",
+ getprogname(), lineno, input_file_name);
done(1);
}
@@ -120,8 +121,8 @@ int st_lineno;
char *st_line;
char *st_cptr;
{
- warnx("e - line %d of \"%s\", syntax error",
- st_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", syntax error",
+ getprogname(), st_lineno, input_file_name);
print_pos(st_line, st_cptr);
done(1);
}
@@ -133,8 +134,8 @@ int c_lineno;
char *c_line;
char *c_cptr;
{
- warnx("e - line %d of \"%s\", unmatched /*",
- c_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unmatched /*",
+ getprogname(), c_lineno, input_file_name);
print_pos(c_line, c_cptr);
done(1);
}
@@ -146,8 +147,8 @@ int s_lineno;
char *s_line;
char *s_cptr;
{
- warnx("e - line %d of \"%s\", unterminated string",
- s_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unterminated string",
+ getprogname(), s_lineno, input_file_name);
print_pos(s_line, s_cptr);
done(1);
}
@@ -159,8 +160,8 @@ int t_lineno;
char *t_line;
char *t_cptr;
{
- warnx("e - line %d of \"%s\", unmatched %%{",
- t_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unmatched %%{",
+ getprogname(), t_lineno, input_file_name);
print_pos(t_line, t_cptr);
done(1);
}
@@ -172,8 +173,8 @@ int u_lineno;
char *u_line;
char *u_cptr;
{
- warnx("e - line %d of \"%s\", unterminated %%union declaration",
- u_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unterminated %%union declaration",
+ getprogname(), u_lineno, input_file_name);
print_pos(u_line, u_cptr);
done(1);
}
@@ -183,8 +184,8 @@ void
over_unionized(u_cptr)
char *u_cptr;
{
- warnx("e - line %d of \"%s\", too many %%union declarations",
- lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", too many %%union declarations",
+ getprogname(), lineno, input_file_name);
print_pos(line, u_cptr);
done(1);
}
@@ -196,7 +197,8 @@ int t_lineno;
char *t_line;
char *t_cptr;
{
- warnx("e - line %d of \"%s\", illegal tag", t_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", illegal tag", getprogname(), t_lineno,
+ input_file_name);
print_pos(t_line, t_cptr);
done(1);
}
@@ -206,7 +208,8 @@ void
illegal_character(c_cptr)
char *c_cptr;
{
- warnx("e - line %d of \"%s\", illegal character", lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", illegal character", getprogname(),
+ lineno, input_file_name);
print_pos(line, c_cptr);
done(1);
}
@@ -216,8 +219,8 @@ void
used_reserved(s)
char *s;
{
- warnx("e - line %d of \"%s\", illegal use of reserved symbol %s",
- lineno, input_file_name, s);
+ warnx("%s: e - line %d of \"%s\", illegal use of reserved symbol %s",
+ getprogname(), lineno, input_file_name, s);
done(1);
}
@@ -226,8 +229,8 @@ void
tokenized_start(s)
char *s;
{
- warnx("e - line %d of \"%s\", the start symbol %s cannot be \
-declared to be a token", lineno, input_file_name, s);
+ warnx("%s: e - line %d of \"%s\", the start symbol %s cannot be \
+declared to be a token", getprogname(), lineno, input_file_name, s);
done(1);
}
@@ -236,8 +239,8 @@ void
retyped_warning(s)
char *s;
{
- warnx("w - line %d of \"%s\", the type of %s has been redeclared",
- lineno, input_file_name, s);
+ warnx("%s: w - line %d of \"%s\", the type of %s has been redeclared",
+ getprogname(), lineno, input_file_name, s);
}
@@ -245,8 +248,8 @@ void
reprec_warning(s)
char *s;
{
- warnx("w - line %d of \"%s\", the precedence of %s has been redeclared",
- lineno, input_file_name, s);
+ warnx("%s: w - line %d of \"%s\", the precedence of %s has been redeclared",
+ getprogname(), lineno, input_file_name, s);
}
@@ -254,8 +257,8 @@ void
revalued_warning(s)
char *s;
{
- warnx("w - line %d of \"%s\", the value of %s has been redeclared",
- lineno, input_file_name, s);
+ warnx("%s: w - line %d of \"%s\", the value of %s has been redeclared",
+ getprogname(), lineno, input_file_name, s);
}
@@ -263,8 +266,8 @@ void
terminal_start(s)
char *s;
{
- warnx("e - line %d of \"%s\", the start symbol %s is a token",
- lineno, input_file_name, s);
+ warnx("%s: e - line %d of \"%s\", the start symbol %s is a token",
+ getprogname(), lineno, input_file_name, s);
done(1);
}
@@ -272,16 +275,16 @@ char *s;
void
restarted_warning()
{
- warnx("w - line %d of \"%s\", the start symbol has been redeclared",
- lineno, input_file_name);
+ warnx("%s: w - line %d of \"%s\", the start symbol has been redeclared",
+ getprogname(), lineno, input_file_name);
}
void
no_grammar()
{
- warnx("e - line %d of \"%s\", no grammar has been specified",
- lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", no grammar has been specified",
+ getprogname(), lineno, input_file_name);
done(1);
}
@@ -290,8 +293,8 @@ void
terminal_lhs(s_lineno)
int s_lineno;
{
- warnx("e - line %d of \"%s\", a token appears on the lhs of a production",
- s_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", a token appears on the lhs of a production",
+ getprogname(), s_lineno, input_file_name);
done(1);
}
@@ -299,8 +302,8 @@ int s_lineno;
void
prec_redeclared()
{
- warnx("w - line %d of \"%s\", conflicting %%prec specifiers",
- lineno, input_file_name);
+ warnx("%s: w - line %d of \"%s\", conflicting %%prec specifiers",
+ getprogname(), lineno, input_file_name);
}
@@ -310,8 +313,8 @@ int a_lineno;
char *a_line;
char *a_cptr;
{
- warnx("e - line %d of \"%s\", unterminated action",
- a_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", unterminated action",
+ getprogname(), a_lineno, input_file_name);
print_pos(a_line, a_cptr);
done(1);
}
@@ -322,8 +325,8 @@ dollar_warning(a_lineno, i)
int a_lineno;
int i;
{
- warnx("w - line %d of \"%s\", $%d references beyond the \
-end of the current rule", a_lineno, input_file_name, i);
+ warnx("%s: w - line %d of \"%s\", $%d references beyond the \
+end of the current rule", getprogname(), a_lineno, input_file_name, i);
}
@@ -333,7 +336,8 @@ int a_lineno;
char *a_line;
char *a_cptr;
{
- warnx("e - line %d of \"%s\", illegal $-name", a_lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", illegal $-name", getprogname(), a_lineno,
+ input_file_name);
print_pos(a_line, a_cptr);
done(1);
}
@@ -342,7 +346,8 @@ char *a_cptr;
void
untyped_lhs()
{
- warnx("e - line %d of \"%s\", $$ is untyped", lineno, input_file_name);
+ warnx("%s: e - line %d of \"%s\", $$ is untyped", getprogname(), lineno,
+ input_file_name);
done(1);
}
@@ -352,8 +357,8 @@ untyped_rhs(i, s)
int i;
char *s;
{
- warnx("e - line %d of \"%s\", $%d (%s) is untyped",
- lineno, input_file_name, i, s);
+ warnx("%s: e - line %d of \"%s\", $%d (%s) is untyped",
+ getprogname(), lineno, input_file_name, i, s);
done(1);
}
@@ -362,7 +367,8 @@ void
unknown_rhs(i)
int i;
{
- warnx("e - line %d of \"%s\", $%d is untyped", lineno, input_file_name, i);
+ warnx("%s: e - line %d of \"%s\", $%d is untyped", getprogname(), lineno,
+ input_file_name, i);
done(1);
}
@@ -370,8 +376,8 @@ int i;
void
default_action_warning()
{
- warnx("w - line %d of \"%s\", the default action assigns an \
-undefined value to $$", lineno, input_file_name);
+ warnx("%s: w - line %d of \"%s\", the default action assigns an \
+undefined value to $$", getprogname(), lineno, input_file_name);
}
@@ -379,7 +385,7 @@ void
undefined_goal(s)
char *s;
{
- warnx("e - the start symbol %s is undefined", s);
+ warnx("%s: e - the start symbol %s is undefined", getprogname(), s);
done(1);
}
@@ -388,5 +394,5 @@ void
undefined_symbol_warning(s)
char *s;
{
- warnx("w - the symbol %s is undefined", s);
+ warnx("%s: w - the symbol %s is undefined", getprogname(), s);
}
OpenPOWER on IntegriCloud