diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-12-03 21:34:22 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-12-03 21:34:22 +0000 |
commit | ebfd89cf2b1e87c514e07b1a49c5d918ba636472 (patch) | |
tree | e7af84aeabb012e8adfa8eb6092e62e53525341e /usr.bin/yacc | |
parent | 60737099f4bed8212a7fa65fa9fb263c10220686 (diff) |
constify the not yet constified tables, use defined(__STDC__) instead of ifdef __STC__ where appropriate; millert@ ok
Diffstat (limited to 'usr.bin/yacc')
-rw-r--r-- | usr.bin/yacc/output.c | 104 | ||||
-rw-r--r-- | usr.bin/yacc/skeleton.c | 35 |
2 files changed, 107 insertions, 32 deletions
diff --git a/usr.bin/yacc/output.c b/usr.bin/yacc/output.c index 1b47b0f5baf..ce6094027e9 100644 --- a/usr.bin/yacc/output.c +++ b/usr.bin/yacc/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.8 2002/02/16 21:28:00 millert Exp $ */ +/* $OpenBSD: output.c,v 1.9 2002/12/03 21:34:21 mickey Exp $ */ /* $NetBSD: output.c,v 1.4 1996/03/19 03:21:41 jtc Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93"; #else -static char rcsid[] = "$OpenBSD: output.c,v 1.8 2002/02/16 21:28:00 millert Exp $"; +static char rcsid[] = "$OpenBSD: output.c,v 1.9 2002/12/03 21:34:21 mickey Exp $"; #endif #endif /* not lint */ @@ -184,9 +184,14 @@ output_rule_data() int i; int j; - - fprintf(output_file, "short %slhs[] = {%42d,", symbol_prefix, - symbol_value[start_symbol]); + + 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]); j = 10; for (i = 3; i < nrules; i++) @@ -205,7 +210,13 @@ output_rule_data() if (!rflag) outline += 2; fprintf(output_file, "\n};\n"); - fprintf(output_file, "short %slen[] = {%42d,", symbol_prefix, 2); + 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); j = 10; for (i = 3; i < nrules; i++) @@ -231,8 +242,14 @@ output_yydefred() { int i, j; - fprintf(output_file, "short %sdefred[] = {%39d,", symbol_prefix, - (defred[0] ? defred[0] - 2 : 0)); + 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)); j = 10; for (i = 1; i < nstates; i++) @@ -376,7 +393,13 @@ goto_actions() state_count = NEW2(nstates, short); k = default_goto(start_symbol + 1); - fprintf(output_file, "short %sdgoto[] = {%40d,", symbol_prefix, k); + 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); save_column(start_symbol + 1, k); j = 10; @@ -704,7 +727,13 @@ output_base() { int i, j; - fprintf(output_file, "short %ssindex[] = {%39d,", symbol_prefix, base[0]); + 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]); j = 10; for (i = 1; i < nstates; i++) @@ -722,8 +751,14 @@ output_base() } if (!rflag) outline += 2; - fprintf(output_file, "\n};\nshort %srindex[] = {%39d,", symbol_prefix, - base[nstates]); + 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]); j = 10; for (i = nstates + 1; i < 2*nstates; i++) @@ -741,8 +776,14 @@ output_base() } if (!rflag) outline += 2; - fprintf(output_file, "\n};\nshort %sgindex[] = {%39d,", symbol_prefix, - base[2*nstates]); + 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]); j = 10; for (i = 2*nstates + 1; i < nvectors - 1; i++) @@ -774,8 +815,13 @@ output_table() ++outline; fprintf(code_file, "#define YYTABLESIZE %d\n", high); - fprintf(output_file, "short %stable[] = {%40d,", symbol_prefix, - table[0]); + 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]); j = 10; for (i = 1; i <= high; i++) @@ -805,8 +851,13 @@ output_check() int i; int j; - fprintf(output_file, "short %scheck[] = {%40d,", symbol_prefix, - check[0]); + 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]); j = 10; for (i = 1; i <= high; i++) @@ -977,7 +1028,14 @@ output_debug() symnam[0] = "end-of-file"; if (!rflag) ++outline; - fprintf(output_file, "#if YYDEBUG\n#if defined(__cplusplus) || __STDC__\nconst char * const %sname[] =\n#else\nchar *%sname[] =\n#endif\n\t{", symbol_prefix, symbol_prefix); + 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); j = 80; for (i = 0; i <= max; ++i) { @@ -1103,7 +1161,13 @@ output_debug() FREE(symnam); if (!rflag) ++outline; - fprintf(output_file, "#if defined(__cplusplus) || __STDC__\nconst char * const %srule[] =\n#else\nchar *%srule[] =\n#endif\n\t{", symbol_prefix, symbol_prefix); + 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); for (i = 2; i < nrules; ++i) { fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]); diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c index befa6759c67..7b0eda01d3e 100644 --- a/usr.bin/yacc/skeleton.c +++ b/usr.bin/yacc/skeleton.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeleton.c,v 1.18 2001/11/19 19:02:18 mpech Exp $ */ +/* $OpenBSD: skeleton.c,v 1.19 2002/12/03 21:34:21 mickey Exp $ */ /* $NetBSD: skeleton.c,v 1.10 1996/03/25 00:36:18 mrg Exp $ */ /* @@ -67,7 +67,7 @@ char *banner[] = "#if __GNUC__ == 2", " __attribute__ ((unused))", "#endif /* __GNUC__ == 2 */", - " = \"$OpenBSD: skeleton.c,v 1.18 2001/11/19 19:02:18 mpech Exp $\";", + " = \"$OpenBSD: skeleton.c,v 1.19 2002/12/03 21:34:21 mickey Exp $\";", "#endif", "#include <stdlib.h>", "#define YYBYACC 1", @@ -84,6 +84,21 @@ char *banner[] = char *tables[] = { + "#if defined(__cplusplus) || defined(__STDC__)", + "extern const short yylhs[];", + "extern const short yylen[];", + "extern const short yydefred[];", + "extern const short yydgoto[];", + "extern const short yysindex[];", + "extern const short yyrindex[];", + "extern const short yygindex[];", + "extern const short yytable[];", + "extern const short yycheck[];", + "#if YYDEBUG", + "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[];", @@ -94,14 +109,10 @@ char *tables[] = "extern short yytable[];", "extern short yycheck[];", "#if YYDEBUG", - "#if defined(__cplusplus) || __STDC__", - "extern const char * const yyname[];", - "extern const char * const yyrule[];", - "#else /* !(defined(__cplusplus) || __STDC__) */", "extern char *yyname[];", "extern char *yyrule[];", - "#endif /* !(defined(__cplusplus) || __STDC__) */", "#endif /* YYDEBUG */", + "#endif /* !(defined(__cplusplus) || defined(__STDC__)) */", 0 }; @@ -139,7 +150,7 @@ char *header[] = char *body[] = { "/* allocate initial stack or double stack size, up to YYMAXDEPTH */", - "#if defined(__cplusplus) || __STDC__", + "#if defined(__cplusplus) || defined(__STDC__)", "static int yygrowstack(void)", "#else", "static int yygrowstack()", @@ -187,7 +198,7 @@ char *body[] = "#define YYACCEPT goto yyaccept", "#define YYERROR goto yyerrlab", "int", - "#if defined(__cplusplus) || __STDC__", + "#if defined(__cplusplus) || defined(__STDC__)", "yyparse(void)", "#else", "yyparse()", @@ -195,11 +206,11 @@ char *body[] = "{", " int yym, yyn, yystate;", "#if YYDEBUG", - "#if defined(__cplusplus) || __STDC__", + "#if defined(__cplusplus) || defined(__STDC__)", " const char *yys;", - "#else /* !(defined(__cplusplus) || __STDC__) */", + "#else /* !(defined(__cplusplus) || defined(__STDC__)) */", " char *yys;", - "#endif /* !(defined(__cplusplus) || __STDC__) */", + "#endif /* !(defined(__cplusplus) || defined(__STDC__)) */", "", " if ((yys = getenv(\"YYDEBUG\")))", " {", |