summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1995-12-22 00:57:09 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1995-12-22 00:57:09 +0000
commite24e6c9e281c7607a333a3a116682560e71f62e0 (patch)
treea37a5494034f28defc988a69b85dfb9449636a24 /usr.bin
parentd68c8b115af31385353126126df0b6109ea5c485 (diff)
Imported from Cygnus byacc, David 'Zoo' Zuhn: add support for a -o
flag, to be command line compatible with bison, for most FSF programs that use a parser.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/yacc/main.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c
index 200086b320d..82b6d409c80 100644
--- a/usr.bin/yacc/main.c
+++ b/usr.bin/yacc/main.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.1 1995/10/18 08:47:05 deraadt Exp $";
+static char rcsid[] = "$Id: main.c,v 1.2 1995/12/22 00:57:08 niklas Exp $";
#endif /* not lint */
#include <signal.h>
@@ -19,6 +19,8 @@ char *temp_form = "yacc.XXXXXXX";
int lineno;
int outline;
+int explicit_file_name;
+
char *action_file_name;
char *code_file_name;
char *defines_file_name;
@@ -101,7 +103,7 @@ set_signals()
usage()
{
- fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n", myname);
+ fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] [-p symbol_prefix] filename\n", myname);
exit(1);
}
@@ -146,6 +148,16 @@ char *argv[];
lflag = 1;
break;
+ case 'o':
+ if (*++s)
+ output_file_name = s;
+ else if (++i < argc)
+ output_file_name = argv[i];
+ else
+ usage();
+ explicit_file_name = 1;
+ continue;
+
case 'p':
if (*++s)
symbol_prefix = s;
@@ -273,11 +285,14 @@ create_file_names()
len = strlen(file_prefix);
- output_file_name = MALLOC(len + 7);
- if (output_file_name == 0)
- no_space();
- strcpy(output_file_name, file_prefix);
- strcpy(output_file_name + len, OUTPUT_SUFFIX);
+ if (!output_file_name)
+ {
+ output_file_name = MALLOC(len + 7);
+ if (output_file_name == 0)
+ no_space();
+ strcpy(output_file_name, file_prefix);
+ strcpy(output_file_name + len, OUTPUT_SUFFIX);
+ }
if (rflag)
{
@@ -292,11 +307,23 @@ create_file_names()
if (dflag)
{
- defines_file_name = MALLOC(len + 7);
- if (defines_file_name == 0)
- no_space();
- strcpy(defines_file_name, file_prefix);
- strcpy(defines_file_name + len, DEFINES_SUFFIX);
+ if (explicit_file_name)
+ {
+ defines_file_name = MALLOC(strlen(output_file_name));
+ if (defines_file_name == 0)
+ no_space();
+ strcpy(defines_file_name, output_file_name);
+ if (!strcmp(output_file_name + (strlen(output_file_name)-2), ".c"))
+ defines_file_name [strlen(output_file_name)-1] = 'h';
+ }
+ else
+ {
+ defines_file_name = MALLOC(len + 7);
+ if (defines_file_name == 0)
+ no_space();
+ strcpy(defines_file_name, file_prefix);
+ strcpy(defines_file_name + len, DEFINES_SUFFIX);
+ }
}
if (vflag)