Subject: bin/1857: Make yacc somewhat more bison-compatible
To: None <gnats-bugs@gnats.netbsd.org>
From: None <niklas@appli.se>
List: netbsd-bugs
Date: 12/25/1995 23:40:38
>Number: 1857
>Category: bin
>Synopsis: Making yacc more Bison-compatible will make FSF SW builds easier
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Dec 25 18:20:01 1995
>Last-Modified:
>Originator: Niklas Hallqvist &
>Organization:
Applitron Datasystem AB
>Release: NetBSD-current 951218
>Environment:
All NetBSD machines
System: NetBSD nettan.appli.se 1.1_ALPHA NetBSD 1.1_ALPHA (NETTAN-O) #6: Thu Nov 23 12:33:43 PST 1995 root@flower.appli.se:/usr/src/sys/arch/i386/compile/NETTAN-O i386
>Description:
NetBSD's yacc don't support a -o flag for output file specification.
And then there are some YY* macros that yacc doesn't generate as well.
>How-To-Repeat:
Try building standard FSF release of GCC with BISON=yacc
>Fix:
The following patch is partly from Cygnus' byacc port (the -o part)
apply it in src/usr.bin/yacc.
*** main.c 1995/10/18 08:47:05 1.1.1.1
--- main.c 1995/12/22 00:57:08 1.2
***************
*** 19,24 ****
--- 19,26 ----
int lineno;
int outline;
+ int explicit_file_name;
+
char *action_file_name;
char *code_file_name;
char *defines_file_name;
***************
*** 101,107 ****
usage()
{
! fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n", myname);
exit(1);
}
--- 103,109 ----
usage()
{
! fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] [-p symbol_prefix] filename\n", myname);
exit(1);
}
***************
*** 146,151 ****
--- 148,163 ----
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,283 ****
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 (rflag)
{
--- 285,298 ----
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)
{
***************
*** 292,302 ****
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 (vflag)
--- 307,329 ----
if (dflag)
{
! 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)
Index: skeleton.c
===================================================================
RCS file: /cvs/src/usr.bin/yacc/skeleton.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** skeleton.c 1995/10/18 08:47:06 1.1.1.1
--- skeleton.c 1995/12/22 01:41:55 1.2
***************
*** 16,27 ****
{
"#ifndef lint",
"/*static char yysccsid[] = \"from: @(#)yaccpar 1.9 (Berkeley) 02/21/93\";*/",
! "static char yyrcsid[] = \"$Id: skeleton.c,v 1.1.1.1 1995/10/18 08:47:06 deraadt Exp $\";",
"#endif",
"#define YYBYACC 1",
"#define YYMAJOR 1",
"#define YYMINOR 9",
! "#define yyclearin (yychar=(-1))",
"#define yyerrok (yyerrflag=0)",
"#define YYRECOVERING (yyerrflag!=0)",
0
--- 16,29 ----
{
"#ifndef lint",
"/*static char yysccsid[] = \"from: @(#)yaccpar 1.9 (Berkeley) 02/21/93\";*/",
! "static char yyrcsid[] = \"$Id: skeleton.c,v 1.2 1995/12/22 01:41:55 niklas Exp $\";",
"#endif",
"#define YYBYACC 1",
"#define YYMAJOR 1",
"#define YYMINOR 9",
! "#define YYLEX yylex()",
! "#define YYEMPTY -1",
! "#define yyclearin (yychar=(YYEMPTY))",
"#define yyerrok (yyerrflag=0)",
"#define YYRECOVERING (yyerrflag!=0)",
0
>Audit-Trail:
>Unformatted: