diff options
author | Steve Price <steve@FreeBSD.org> | 1997-01-06 02:05:28 +0000 |
---|---|---|
committer | Steve Price <steve@FreeBSD.org> | 1997-01-06 02:05:28 +0000 |
commit | 55f61394b60ff4eecfa245302a42dd9d148b08e9 (patch) | |
tree | ba6b15cd22ccae1d52e1052906a088f0bf89574e /usr.bin | |
parent | 938ddab485b4e9dcbbc5db535a92610dd2daa497 (diff) | |
download | src-55f61394b60ff4eecfa245302a42dd9d148b08e9.tar.gz src-55f61394b60ff4eecfa245302a42dd9d148b08e9.zip |
Implement and document a '-o output_file_name' option to
allow the generated code to be written to a file other
than the default, y.tab.c.
Inspired by: bde and brian@mediacity.com
Notes
Notes:
svn path=/head/; revision=21353
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/yacc/main.c | 13 | ||||
-rw-r--r-- | usr.bin/yacc/yacc.1 | 10 |
2 files changed, 22 insertions, 1 deletions
diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c index 79b332a237e7..8b7f36ff027f 100644 --- a/usr.bin/yacc/main.c +++ b/usr.bin/yacc/main.c @@ -144,7 +144,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 output_file_name] [-p symbol_prefix] filename\n", myname); exit(1); } @@ -189,6 +189,15 @@ char *argv[]; lflag = 1; break; + case 'o': + if (*++s) + output_file_name = s; + else if (++i < argc) + output_file_name = argv[i]; + else + usage(); + continue; + case 'p': if (*++s) symbol_prefix = s; @@ -316,11 +325,13 @@ create_file_names() len = strlen(file_prefix); + 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) { diff --git a/usr.bin/yacc/yacc.1 b/usr.bin/yacc/yacc.1 index 787dc0043fe0..3175a22cd35c 100644 --- a/usr.bin/yacc/yacc.1 +++ b/usr.bin/yacc/yacc.1 @@ -86,6 +86,16 @@ If the \fB-l\fR option is specified, will not insert the #line directives. Any #line directives specified by the user will be retained. .TP +\fB-o \fIoutput_file_name\fR +The +.B -o +option causes +.I yacc +to write the generated code to +.IR output_file_name +instead of the default file, +.IR y.tab.c . +.TP \fB-p \fIsymbol_prefix\fR The .B -p |