diff options
-rw-r--r-- | usr.bin/yacc/defs.h | 4 | ||||
-rw-r--r-- | usr.bin/yacc/error.c | 66 | ||||
-rw-r--r-- | usr.bin/yacc/main.c | 33 | ||||
-rw-r--r-- | usr.bin/yacc/mkpar.c | 15 | ||||
-rw-r--r-- | usr.bin/yacc/yacc.1 | 14 |
5 files changed, 64 insertions, 68 deletions
diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h index 00116e1ea42..3af2bf12291 100644 --- a/usr.bin/yacc/defs.h +++ b/usr.bin/yacc/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.5 1996/04/21 23:45:06 deraadt Exp $ */ +/* $OpenBSD: defs.h,v 1.6 1999/08/04 18:31:25 millert Exp $ */ /* $NetBSD: defs.h,v 1.6 1996/03/19 03:21:30 jtc Exp $ */ /* @@ -228,7 +228,6 @@ extern char tflag; extern char vflag; extern char *symbol_prefix; -extern char *myname; extern char *cptr; extern char *line; extern int lineno; @@ -322,6 +321,7 @@ extern bucket *make_bucket(); /* system variables */ extern int errno; +extern char *__progname; /* system functions */ diff --git a/usr.bin/yacc/error.c b/usr.bin/yacc/error.c index 8929c5bd08d..0eefc474978 100644 --- a/usr.bin/yacc/error.c +++ b/usr.bin/yacc/error.c @@ -1,4 +1,4 @@ -/* $OpenBSD: error.c,v 1.3 1996/06/26 05:44:36 deraadt Exp $ */ +/* $OpenBSD: error.c,v 1.4 1999/08/04 18:31:26 millert Exp $ */ /* $NetBSD: error.c,v 1.4 1996/03/19 03:21:32 jtc Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90"; #else -static char rcsid[] = "$OpenBSD: error.c,v 1.3 1996/06/26 05:44:36 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: error.c,v 1.4 1999/08/04 18:31:26 millert Exp $"; #endif #endif /* not lint */ @@ -53,14 +53,14 @@ static char rcsid[] = "$OpenBSD: error.c,v 1.3 1996/06/26 05:44:36 deraadt Exp $ fatal(msg) char *msg; { - fprintf(stderr, "%s: f - %s\n", myname, msg); + fprintf(stderr, "%s: f - %s\n", __progname, msg); done(2); } no_space() { - fprintf(stderr, "%s: f - out of space\n", myname); + fprintf(stderr, "%s: f - out of space\n", __progname); done(2); } @@ -68,7 +68,7 @@ no_space() open_error(filename) char *filename; { - fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename); + fprintf(stderr, "%s: f - cannot open \"%s\"\n", __progname, filename); done(2); } @@ -76,7 +76,7 @@ char *filename; unexpected_EOF() { fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n", - myname, lineno, input_file_name); + __progname, lineno, input_file_name); done(1); } @@ -114,7 +114,7 @@ char *st_line; char *st_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n", - myname, st_lineno, input_file_name); + __progname, st_lineno, input_file_name); print_pos(st_line, st_cptr); done(1); } @@ -126,7 +126,7 @@ char *c_line; char *c_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", - myname, c_lineno, input_file_name); + __progname, c_lineno, input_file_name); print_pos(c_line, c_cptr); done(1); } @@ -138,7 +138,7 @@ char *s_line; char *s_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", - myname, s_lineno, input_file_name); + __progname, s_lineno, input_file_name); print_pos(s_line, s_cptr); done(1); } @@ -150,7 +150,7 @@ char *t_line; char *t_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", - myname, t_lineno, input_file_name); + __progname, t_lineno, input_file_name); print_pos(t_line, t_cptr); done(1); } @@ -162,7 +162,7 @@ char *u_line; char *u_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \ -declaration\n", myname, u_lineno, input_file_name); +declaration\n", __progname, u_lineno, input_file_name); print_pos(u_line, u_cptr); done(1); } @@ -172,7 +172,7 @@ over_unionized(u_cptr) char *u_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \ -declarations\n", myname, lineno, input_file_name); +declarations\n", __progname, lineno, input_file_name); print_pos(line, u_cptr); done(1); } @@ -184,7 +184,7 @@ char *t_line; char *t_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n", - myname, t_lineno, input_file_name); + __progname, t_lineno, input_file_name); print_pos(t_line, t_cptr); done(1); } @@ -194,7 +194,7 @@ illegal_character(c_cptr) char *c_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n", - myname, lineno, input_file_name); + __progname, lineno, input_file_name); print_pos(line, c_cptr); done(1); } @@ -204,7 +204,7 @@ used_reserved(s) char *s; { fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \ -%s\n", myname, lineno, input_file_name, s); +%s\n", __progname, lineno, input_file_name, s); done(1); } @@ -213,7 +213,7 @@ tokenized_start(s) char *s; { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \ -declared to be a token\n", myname, lineno, input_file_name, s); +declared to be a token\n", __progname, lineno, input_file_name, s); done(1); } @@ -222,7 +222,7 @@ retyped_warning(s) char *s; { fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); +redeclared\n", __progname, lineno, input_file_name, s); } @@ -230,7 +230,7 @@ reprec_warning(s) char *s; { fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); +redeclared\n", __progname, lineno, input_file_name, s); } @@ -238,7 +238,7 @@ revalued_warning(s) char *s; { fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); +redeclared\n", __progname, lineno, input_file_name, s); } @@ -246,7 +246,7 @@ terminal_start(s) char *s; { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \ -token\n", myname, lineno, input_file_name, s); +token\n", __progname, lineno, input_file_name, s); done(1); } @@ -254,14 +254,14 @@ token\n", myname, lineno, input_file_name, s); restarted_warning() { fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \ -redeclared\n", myname, lineno, input_file_name); +redeclared\n", __progname, lineno, input_file_name); } no_grammar() { fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \ -specified\n", myname, lineno, input_file_name); +specified\n", __progname, lineno, input_file_name); done(1); } @@ -270,7 +270,7 @@ terminal_lhs(s_lineno) int s_lineno; { fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \ -of a production\n", myname, s_lineno, input_file_name); +of a production\n", __progname, s_lineno, input_file_name); done(1); } @@ -278,7 +278,7 @@ of a production\n", myname, s_lineno, input_file_name); prec_redeclared() { fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \ -specifiers\n", myname, lineno, input_file_name); +specifiers\n", __progname, lineno, input_file_name); } @@ -288,7 +288,7 @@ char *a_line; char *a_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", - myname, a_lineno, input_file_name); + __progname, a_lineno, input_file_name); print_pos(a_line, a_cptr); done(1); } @@ -299,7 +299,7 @@ int a_lineno; int i; { fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \ -end of the current rule\n", myname, a_lineno, input_file_name, i); +end of the current rule\n", __progname, a_lineno, input_file_name, i); } @@ -309,7 +309,7 @@ char *a_line; char *a_cptr; { fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n", - myname, a_lineno, input_file_name); + __progname, a_lineno, input_file_name); print_pos(a_line, a_cptr); done(1); } @@ -318,7 +318,7 @@ char *a_cptr; untyped_lhs() { fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n", - myname, lineno, input_file_name); + __progname, lineno, input_file_name); done(1); } @@ -328,7 +328,7 @@ int i; char *s; { fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n", - myname, lineno, input_file_name, i, s); + __progname, lineno, input_file_name, i, s); done(1); } @@ -337,7 +337,7 @@ unknown_rhs(i) int i; { fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n", - myname, lineno, input_file_name, i); + __progname, lineno, input_file_name, i); done(1); } @@ -345,14 +345,14 @@ int i; default_action_warning() { fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \ -undefined value to $$\n", myname, lineno, input_file_name); +undefined value to $$\n", __progname, lineno, input_file_name); } undefined_goal(s) char *s; { - fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s); + fprintf(stderr, "%s: e - the start symbol %s is undefined\n", __progname, s); done(1); } @@ -360,5 +360,5 @@ char *s; undefined_symbol_warning(s) char *s; { - fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); + fprintf(stderr, "%s: w - the symbol %s is undefined\n", __progname, s); } diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c index 75615561d05..82e8840ba4b 100644 --- a/usr.bin/yacc/main.c +++ b/usr.bin/yacc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.9 1998/05/28 16:48:47 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.10 1999/08/04 18:31:26 millert Exp $ */ /* $NetBSD: main.c,v 1.5 1996/03/19 03:21:38 jtc Exp $ */ /* @@ -47,12 +47,13 @@ char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.9 1998/05/28 16:48:47 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.10 1999/08/04 18:31:26 millert Exp $"; #endif #endif /* not lint */ #include <sys/types.h> #include <fcntl.h> +#include <paths.h> #include <stdlib.h> #include <signal.h> #include "defs.h" @@ -65,8 +66,7 @@ char vflag; char *symbol_prefix; char *file_prefix = "y"; -char *myname = "yacc"; -char *temp_form = "yacc.XXXXXXXXXX"; +char *temp_form = "yacc.XXXXXXXXXXX"; int lineno; int outline; @@ -152,7 +152,7 @@ set_signals() usage() { - fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] [-p symbol_prefix] filename\n", myname); + fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] [-p symbol_prefix] filename\n", __progname); exit(1); } @@ -164,7 +164,6 @@ char *argv[]; register int i; register char *s; - if (argc > 0) myname = argv[0]; for (i = 1; i < argc; ++i) { s = argv[i]; @@ -293,8 +292,8 @@ create_file_names() int i, len; char *tmpdir; - tmpdir = getenv("TMPDIR"); - if (tmpdir == 0) tmpdir = "/tmp"; + if (!(tmpdir = getenv("TMPDIR"))) + tmpdir = _PATH_TMP; len = strlen(tmpdir); i = len + strlen(temp_form) + 1; @@ -328,10 +327,6 @@ create_file_names() text_file_name[len + 5] = 't'; union_file_name[len + 5] = 'u'; - mktemp(action_file_name); - mktemp(text_file_name); - mktemp(union_file_name); - len = strlen(file_prefix); if (!output_file_name) @@ -380,7 +375,7 @@ create_file_names() } else { fprintf(stderr,"%s: suffix of output file name %s" " not recognized, no -d file generated.\n", - myname, output_file_name); + __progname, output_file_name); dflag = 0; free(defines_file_name); defines_file_name = 0; @@ -439,12 +434,12 @@ open_files() open_error(input_file_name); } - action_file = fsopen(action_file_name, "w"); - if (action_file == 0) + fd = mkstemp(action_file_name); + if (fd == -1 || (action_file = fdopen(fd, "w")) == NULL) open_error(action_file_name); - text_file = fsopen(text_file_name, "w"); - if (text_file == 0) + fd = mkstemp(text_file_name); + if (fd == -1 || (text_file = fdopen(fd, "w")) == NULL) open_error(text_file_name); if (vflag) @@ -459,8 +454,8 @@ open_files() defines_file = fopen(defines_file_name, "w"); if (defines_file == 0) open_error(defines_file_name); - union_file = fsopen(union_file_name, "w"); - if (union_file == 0) + fd = mkstemp(union_file_name); + if (fd == -1 || (union_file = fdopen(fd, "w")) == NULL) open_error(union_file_name); } diff --git a/usr.bin/yacc/mkpar.c b/usr.bin/yacc/mkpar.c index d044a0adb80..e367ed6154f 100644 --- a/usr.bin/yacc/mkpar.c +++ b/usr.bin/yacc/mkpar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkpar.c,v 1.4 1996/04/21 23:45:15 deraadt Exp $ */ +/* $OpenBSD: mkpar.c,v 1.5 1999/08/04 18:31:26 millert Exp $ */ /* $NetBSD: mkpar.c,v 1.4 1996/03/19 03:21:39 jtc Exp $ */ @@ -241,9 +241,10 @@ unused_rules() if (nunused) if (nunused == 1) - fprintf(stderr, "%s: 1 rule never reduced\n", myname); + fprintf(stderr, "%s: 1 rule never reduced\n", __progname); else - fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused); + fprintf(stderr, "%s: %d rules never reduced\n", __progname, + nunused); } @@ -328,16 +329,16 @@ total_conflicts() if ((SRtotal != SRexpect) || RRtotal) { if (SRtotal == 1) - fprintf(stderr, "%s: 1 shift/reduce conflict\n", myname); + fprintf(stderr, "%s: 1 shift/reduce conflict\n", __progname); else if (SRtotal > 1) - fprintf(stderr, "%s: %d shift/reduce conflicts\n", myname, + fprintf(stderr, "%s: %d shift/reduce conflicts\n", __progname, SRtotal); } if (RRtotal == 1) - fprintf(stderr, "%s: 1 reduce/reduce conflict\n", myname); + fprintf(stderr, "%s: 1 reduce/reduce conflict\n", __progname); else if (RRtotal > 1) - fprintf(stderr, "%s: %d reduce/reduce conflicts\n", myname, + fprintf(stderr, "%s: %d reduce/reduce conflicts\n", __progname, RRtotal); } diff --git a/usr.bin/yacc/yacc.1 b/usr.bin/yacc/yacc.1 index 2d180ec7342..181bde6bea5 100644 --- a/usr.bin/yacc/yacc.1 +++ b/usr.bin/yacc/yacc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: yacc.1,v 1.6 1999/07/09 13:35:30 aaron Exp $ +.\" $OpenBSD: yacc.1,v 1.7 1999/08/04 18:31:27 millert Exp $ .\" Copyright (c) 1989, 1990 The Regents of the University of California. .\" All rights reserved. .\" @@ -163,14 +163,14 @@ are created if .Dv YYDEBUG is defined and non-zero. .Sh FILES -.Bl -tag -width /tmp/yacc.uXXXXXXXX -compact +.Bl -tag -width /tmp/yacc.uXXXXXXXXXX -compact .It Pa y.code.c .It Pa y.tab.c .It Pa y.tab.h .It Pa y.output -.It Pa /tmp/yacc.aXXXXXX -.It Pa /tmp/yacc.tXXXXXX -.It Pa /tmp/yacc.uXXXXXX +.It Pa /tmp/yacc.aXXXXXXXXXX +.It Pa /tmp/yacc.tXXXXXXXXXX +.It Pa /tmp/yacc.uXXXXXXXXXX .El .Sh DIAGNOSTICS If there are rules that are never reduced, the number of such rules is @@ -179,8 +179,8 @@ If there are any .Tn LALR(1) conflicts, the number of conflicts is also written to the standard error. -.\" .Sh SEE ALSO -.\" .Xr yyfix 1 +.Sh SEE ALSO +.Xr yyfix 1 .Sh STANDARDS The .Nm yacc |