It's only been 25 years. I think we can depend on prototypes and
const now.

Index: output.c
===================================================================
RCS file: /cvs/src/usr.bin/yacc/output.c,v
retrieving revision 1.19
diff -u -p -r1.19 output.c
--- output.c    8 Jan 2014 22:55:59 -0000       1.19
+++ output.c    16 Feb 2014 03:28:03 -0000
@@ -173,12 +173,8 @@ output_rule_data(void)
     int j;
 
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %slhs[] =\n"
-       "#else\n"
-       "short %slhs[] =\n"
-       "#endif\n"
-       "\t{%42d,", symbol_prefix, symbol_prefix, symbol_value[start_symbol]);
+       "\t{%42d,", symbol_prefix, symbol_value[start_symbol]);
 
     j = 10;
     for (i = 3; i < nrules; i++)
@@ -198,12 +194,8 @@ output_rule_data(void)
     fprintf(output_file, "\n};\n");
 
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %slen[] =\n"
-       "#else\n"
-       "short %slen[] =\n"
-       "#endif\n"
-       "\t{%42d,", symbol_prefix, symbol_prefix, 2);
+       "\t{%42d,", symbol_prefix, 2);
 
     j = 10;
     for (i = 3; i < nrules; i++)
@@ -230,13 +222,9 @@ output_yydefred(void)
     int i, j;
 
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %sdefred[] =\n"
-       "#else\n"
-       "short %sdefred[] =\n"
-       "#endif\n"
        "\t{%39d,",
-       symbol_prefix, symbol_prefix, (defred[0] ? defred[0] - 2 : 0));
+       symbol_prefix, (defred[0] ? defred[0] - 2 : 0));
 
     j = 10;
     for (i = 1; i < nstates; i++)
@@ -381,12 +369,8 @@ goto_actions(void)
 
     k = default_goto(start_symbol + 1);
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %sdgoto[] =\n"
-       "#else\n"
-       "short %sdgoto[] =\n"
-       "#endif\n"
-       "\t{%40d,", symbol_prefix, symbol_prefix, k);
+       "\t{%40d,", symbol_prefix, k);
     save_column(start_symbol + 1, k);
 
     j = 10;
@@ -709,12 +693,8 @@ output_base(void)
     int i, j;
 
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %ssindex[] =\n"
-       "#else\n"
-       "short %ssindex[] =\n"
-       "#endif\n"
-       "\t{%39d,", symbol_prefix, symbol_prefix, base[0]);
+       "\t{%39d,", symbol_prefix, base[0]);
 
     j = 10;
     for (i = 1; i < nstates; i++)
@@ -734,12 +714,8 @@ output_base(void)
     if (!rflag) outline += 2;
     fprintf(output_file,
        "};\n"
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %srindex[] =\n"
-       "#else\n"
-       "short %srindex[] =\n"
-       "#endif\n"
-       "\t{%39d,", symbol_prefix, symbol_prefix, base[nstates]);
+       "\t{%39d,", symbol_prefix, base[nstates]);
 
     j = 10;
     for (i = nstates + 1; i < 2*nstates; i++)
@@ -759,12 +735,8 @@ output_base(void)
     if (!rflag) outline += 2;
     fprintf(output_file,
        "};\n"
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %sgindex[] =\n"
-       "#else\n"
-       "short %sgindex[] =\n"
-       "#endif\n"
-       "\t{%39d,", symbol_prefix, symbol_prefix, base[2*nstates]);
+       "\t{%39d,", symbol_prefix, base[2*nstates]);
 
     j = 10;
     for (i = 2*nstates + 1; i < nvectors - 1; i++)
@@ -796,12 +768,8 @@ output_table(void)
     ++outline;
     fprintf(code_file, "#define YYTABLESIZE %d\n", high);
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %stable[] =\n"
-       "#else\n"
-       "short %stable[] =\n"
-       "#endif\n"
-       "\t{%40d,", symbol_prefix, symbol_prefix, table[0]);
+       "\t{%40d,", symbol_prefix, table[0]);
 
     j = 10;
     for (i = 1; i <= high; i++)
@@ -831,12 +799,8 @@ output_check(void)
     int j;
 
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const short %scheck[] =\n"
-       "#else\n"
-       "short %scheck[] =\n"
-       "#endif\n"
-       "\t{%40d,", symbol_prefix, symbol_prefix, check[0]);
+       "\t{%40d,", symbol_prefix, check[0]);
 
     j = 10;
     for (i = 1; i <= high; i++)
@@ -1006,12 +970,8 @@ output_debug(void)
     if (!rflag) ++outline;
     fprintf(output_file,
        "#if YYDEBUG\n"
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const char * const %sname[] =\n"
-       "#else\n"
-       "char *%sname[] =\n"
-       "#endif\n"
-       "\t{", symbol_prefix, symbol_prefix);
+       "\t{", symbol_prefix);
     j = 80;
     for (i = 0; i <= max; ++i)
     {
@@ -1138,12 +1098,8 @@ output_debug(void)
 
     if (!rflag) ++outline;
     fprintf(output_file,
-       "#if defined(__cplusplus) || defined(__STDC__)\n"
        "const char * const %srule[] =\n"
-       "#else\n"
-       "char *%srule[] =\n"
-       "#endif\n"
-       "\t{", symbol_prefix, symbol_prefix);
+       "\t{", symbol_prefix);
     for (i = 2; i < nrules; ++i)
     {
        fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]);
Index: skeleton.c
===================================================================
RCS file: /cvs/src/usr.bin/yacc/skeleton.c,v
retrieving revision 1.31
diff -u -p -r1.31 skeleton.c
--- skeleton.c  30 Oct 2013 20:33:00 -0000      1.31
+++ skeleton.c  16 Feb 2014 03:32:15 -0000
@@ -59,13 +59,12 @@ char *banner[] =
     "#define yyclearin (yychar=(YYEMPTY))",
     "#define yyerrok (yyerrflag=0)",
     "#define YYRECOVERING() (yyerrflag!=0)",
-    0
+    NULL
 };
 
 
 char *tables[] =
 {
-    "#if defined(__cplusplus) || defined(__STDC__)",
     "extern const short yylhs[];",
     "extern const short yylen[];",
     "extern const short yydefred[];",
@@ -79,22 +78,7 @@ char *tables[] =
     "extern const char *const yyname[];",
     "extern const char *const yyrule[];",
     "#endif",
-    "#else /* !(defined(__cplusplus) || defined(__STDC__)) */",
-    "extern short yylhs[];",
-    "extern short yylen[];",
-    "extern short yydefred[];",
-    "extern short yydgoto[];",
-    "extern short yysindex[];",
-    "extern short yyrindex[];",
-    "extern short yygindex[];",
-    "extern short yytable[];",
-    "extern short yycheck[];",
-    "#if YYDEBUG",
-    "extern char *yyname[];",
-    "extern char *yyrule[];",
-    "#endif /* YYDEBUG */",
-    "#endif /* !(defined(__cplusplus) || defined(__STDC__)) */",
-    0
+    NULL
 };
 
 
@@ -125,18 +109,14 @@ char *header[] =
     "short *yysslim;",
     "YYSTYPE *yyvs;",
     "unsigned int yystacksize;",
-    0
+    NULL
 };
 
 
 char *body[] =
 {
     "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
-    "#if defined(__cplusplus) || defined(__STDC__)",
     "static int yygrowstack(void)",
-    "#else",
-    "static int yygrowstack()",
-    "#endif",
     "{",
     "    unsigned int newsize;",
     "    long sslen;",
@@ -190,19 +170,11 @@ char *body[] =
     "#define YYACCEPT goto yyaccept",
     "#define YYERROR goto yyerrlab",
     "int",
-    "#if defined(__cplusplus) || defined(__STDC__)",
     "yyparse(void)",
-    "#else",
-    "yyparse()",
-    "#endif",
     "{",
     "    int yym, yyn, yystate;",
     "#if YYDEBUG",
-    "#if defined(__cplusplus) || defined(__STDC__)",
     "    const char *yys;",
-    "#else /* !(defined(__cplusplus) || defined(__STDC__)) */",
-    "    char *yys;",
-    "#endif /* !(defined(__cplusplus) || defined(__STDC__)) */",
     "",
     "    if ((yys = getenv(\"YYDEBUG\")))",
     "    {",
@@ -338,7 +310,7 @@ char *body[] =
     "        memset(&yyval, 0, sizeof yyval);",
     "    switch (yyn)",
     "    {",
-    0
+    NULL
 };
 
 
@@ -414,7 +386,7 @@ char *trailer[] =
     "    yystacksize = 0;",
     "    return (0);",
     "}",
-    0
+    NULL
 };
 
 

Reply via email to