Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorJay Krell <jaykrell@microsoft.com>2018-01-16 11:58:06 +0300
committerMarek Safar <marek.safar@gmail.com>2018-01-18 16:35:36 +0300
commit6a04dc64516bd91b7b45d4587b66988b0e9b1285 (patch)
tree4eaf5e4208d5546e0e4bb4d0bb85e757e75584db /mcs
parent232af8c206d9253d6f284d8ca960c174f4d7b9c7 (diff)
Convert K&R warning farm to ANSI and add static/const.
Also smaller part fix C-vs.-C++-isms.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/jay/closure.c39
-rw-r--r--mcs/jay/defs.h159
-rw-r--r--mcs/jay/error.c162
-rw-r--r--mcs/jay/lalr.c130
-rw-r--r--mcs/jay/lr0.c113
-rw-r--r--mcs/jay/main.c68
-rw-r--r--mcs/jay/mkpar.c92
-rw-r--r--mcs/jay/output.c192
-rw-r--r--mcs/jay/reader.c208
-rw-r--r--mcs/jay/symtab.c32
-rw-r--r--mcs/jay/verbose.c82
-rw-r--r--mcs/jay/warshall.c10
12 files changed, 765 insertions, 522 deletions
diff --git a/mcs/jay/closure.c b/mcs/jay/closure.c
index 5f63c5f32cd..9dff2762bfd 100644
--- a/mcs/jay/closure.c
+++ b/mcs/jay/closure.c
@@ -47,8 +47,17 @@ unsigned *ruleset;
static unsigned *first_derives;
static unsigned *EFF;
+void
+print_first_derives (void);
-set_EFF()
+void
+print_closure (int n);
+
+void
+print_EFF (void);
+
+static void
+set_EFF (void)
{
register unsigned *row;
register int symbol;
@@ -83,8 +92,8 @@ set_EFF()
#endif
}
-
-set_first_derives()
+void
+set_first_derives (void)
{
register unsigned *rrow;
register unsigned *vrow;
@@ -138,10 +147,8 @@ set_first_derives()
FREE(EFF);
}
-
-closure(nucleus, n)
-short *nucleus;
-int n;
+void
+closure (short *nucleus, int n)
{
register int ruleno;
register unsigned word;
@@ -207,20 +214,18 @@ int n;
#endif
}
-
-
-finalize_closure()
+void
+finalize_closure (void)
{
FREE(itemset);
FREE(ruleset);
FREE(first_derives + ntokens * WORDSIZE(nrules));
}
-
#ifdef DEBUG
-print_closure(n)
-int n;
+void
+print_closure (int n)
{
register short *isp;
@@ -229,8 +234,8 @@ int n;
printf(" %d\n", *isp);
}
-
-print_EFF()
+void
+print_EFF (void)
{
register int i, j;
register unsigned *rowp;
@@ -260,8 +265,8 @@ print_EFF()
}
}
-
-print_first_derives()
+void
+print_first_derives (void)
{
register int i;
register int j;
diff --git a/mcs/jay/defs.h b/mcs/jay/defs.h
index 2aade48dac2..b5dfc4303b8 100644
--- a/mcs/jay/defs.h
+++ b/mcs/jay/defs.h
@@ -162,6 +162,7 @@ struct bucket
short value;
short index;
short prec;
+#define class clas
char class;
char assoc;
};
@@ -248,11 +249,10 @@ extern int nrules;
extern int nsyms;
extern int ntokens;
extern int nvars;
-extern int ntags;
extern int nmethods;
-extern char *line_format;
-extern char *default_line_format;
+extern const char *line_format;
+extern const char *default_line_format;
extern int start_symbol;
extern char **symbol_name;
@@ -300,8 +300,155 @@ extern short final_state;
/* global functions */
-extern char *allocate();
-extern bucket *lookup();
-extern bucket *make_bucket();
+char *
+allocate (unsigned);
+bucket *
+lookup (const char *);
+bucket *
+make_bucket (const char *);
+
+void
+reflexive_transitive_closure (unsigned *R, int n);
+
+void
+done (int);
+
+void
+fatal (const char*);
+
+void
+no_space (void);
+
+void
+finalize_closure (void);
+
+void
+closure (short *nucleus, int n);
+
+void
+set_first_derives (void);
+
+void
+open_error (const char *filename);
+
+void
+make_parser (void);
+
+void
+free_parser (void);
+
+void
+lr0 (void);
+
+void
+output (void);
+
+void
+verbose (void);
+
+void
+xxlr0 (void);
+
+void
+reader (void);
+
+void
+lalr (void);
+
+void
+free_symbols (void);
+
+void
+free_symbol_table (void);
+
+void
+create_symbol_table (void);
+
+void
+fatal (const char *msg);
+
+void
+no_space (void);
+
+void
+open_error (const char *filename);
+
+void
+unexpected_EOF (void);
+
+void
+syntax_error (int st_lineno, const char *st_line, const char *st_cptr);
+
+void
+unterminated_comment (int c_lineno, const char *c_line, const char *c_cptr);
+
+void
+unterminated_string (int s_lineno, const char *s_line, const char *s_cptr);
+
+void
+unterminated_text (int t_lineno, const char *t_line, const char *t_cptr);
+
+void
+illegal_tag (int t_lineno, const char *t_line, const char *t_cptr);
+
+void
+illegal_character (const char *c_cptr);
+
+void
+used_reserved (const char *s);
+
+void
+tokenized_start (const char *s);
+
+void
+retyped_warning (const char *s);
+
+void
+reprec_warning (const char *s);
+
+void
+revalued_warning (const char *s);
+
+void
+terminal_start (const char *s);
+
+void
+restarted_warning (void);
+
+void
+no_grammar (void);
+
+void
+terminal_lhs (int s_lineno);
+
+void
+prec_redeclared (void);
+
+void
+unterminated_action (int a_lineno, const char *a_line, const char *a_cptr);
+
+void
+dollar_warning (int a_lineno, int i);
+
+void
+dollar_error (int a_lineno, const char *a_line, char *a_cptr);
+
+void
+untyped_lhs (void);
+
+void
+untyped_rhs (int i, const char *s);
+
+void
+unknown_rhs (int i);
+
+void
+default_action_warning (void);
+
+void
+undefined_goal (const char *s);
+
+void
+undefined_symbol_warning (const char *s);
diff --git a/mcs/jay/error.c b/mcs/jay/error.c
index dd8bf291c20..243a260fe7e 100644
--- a/mcs/jay/error.c
+++ b/mcs/jay/error.c
@@ -42,43 +42,39 @@ static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
#include "defs.h"
-
-fatal(msg)
-char *msg;
+void
+fatal (const char *msg)
{
fprintf(stderr, "%s: f - %s\n", myname, msg);
done(2);
}
-
-no_space()
+void
+no_space (void)
{
fprintf(stderr, "%s: f - out of space\n", myname);
done(2);
}
-
-open_error(filename)
-char *filename;
+void
+open_error (const char *filename)
{
fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
done(2);
}
-
-unexpected_EOF()
+void
+unexpected_EOF (void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
myname, lineno, input_file_name);
done(1);
}
-
-print_pos(st_line, st_cptr)
-char *st_line;
-char *st_cptr;
+static void
+print_pos (const char *st_line, const char *st_cptr)
{
- register char *s;
+ const char *s;
if (st_line == 0) return;
for (s = st_line; *s != '\n'; ++s)
@@ -100,11 +96,8 @@ char *st_cptr;
putc('\n', stderr);
}
-
-syntax_error(st_lineno, st_line, st_cptr)
-int st_lineno;
-char *st_line;
-char *st_cptr;
+void
+syntax_error (int st_lineno, const char *st_line, const char *st_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
myname, st_lineno, input_file_name);
@@ -112,11 +105,8 @@ char *st_cptr;
done(1);
}
-
-unterminated_comment(c_lineno, c_line, c_cptr)
-int c_lineno;
-char *c_line;
-char *c_cptr;
+void
+unterminated_comment (int c_lineno, const char *c_line, const char *c_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
myname, c_lineno, input_file_name);
@@ -124,11 +114,8 @@ char *c_cptr;
done(1);
}
-
-unterminated_string(s_lineno, s_line, s_cptr)
-int s_lineno;
-char *s_line;
-char *s_cptr;
+void
+unterminated_string (int s_lineno, const char *s_line, const char *s_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
myname, s_lineno, input_file_name);
@@ -136,11 +123,8 @@ char *s_cptr;
done(1);
}
-
-unterminated_text(t_lineno, t_line, t_cptr)
-int t_lineno;
-char *t_line;
-char *t_cptr;
+void
+unterminated_text (int t_lineno, const char *t_line, const char *t_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
myname, t_lineno, input_file_name);
@@ -148,11 +132,8 @@ char *t_cptr;
done(1);
}
-
-illegal_tag(t_lineno, t_line, t_cptr)
-int t_lineno;
-char *t_line;
-char *t_cptr;
+void
+illegal_tag (int t_lineno, const char *t_line, const char *t_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
myname, t_lineno, input_file_name);
@@ -160,9 +141,8 @@ char *t_cptr;
done(1);
}
-
-illegal_character(c_cptr)
-char *c_cptr;
+void
+illegal_character (const char *c_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
myname, lineno, input_file_name);
@@ -170,93 +150,83 @@ char *c_cptr;
done(1);
}
-
-used_reserved(s)
-char *s;
+void
+used_reserved (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
%s\n", myname, lineno, input_file_name, s);
done(1);
}
-
-tokenized_start(s)
-char *s;
+void
+tokenized_start (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
declared to be a token\n", myname, lineno, input_file_name, s);
done(1);
}
-
-retyped_warning(s)
-char *s;
+void
+retyped_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
-
-reprec_warning(s)
-char *s;
+void
+reprec_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
-
-revalued_warning(s)
-char *s;
+void
+revalued_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
-
-terminal_start(s)
-char *s;
+void
+terminal_start (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
token\n", myname, lineno, input_file_name, s);
done(1);
}
-
-restarted_warning()
+void
+restarted_warning (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
redeclared\n", myname, lineno, input_file_name);
}
-
-no_grammar()
+void
+no_grammar (void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
specified\n", myname, lineno, input_file_name);
done(1);
}
-
-terminal_lhs(s_lineno)
-int s_lineno;
+void
+terminal_lhs (int s_lineno)
{
fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
of a production\n", myname, s_lineno, input_file_name);
done(1);
}
-
-prec_redeclared()
+void
+prec_redeclared (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
specifiers\n", myname, lineno, input_file_name);
}
-
-unterminated_action(a_lineno, a_line, a_cptr)
-int a_lineno;
-char *a_line;
-char *a_cptr;
+void
+unterminated_action (int a_lineno, const char *a_line, const char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
myname, a_lineno, input_file_name);
@@ -264,20 +234,15 @@ char *a_cptr;
done(1);
}
-
-dollar_warning(a_lineno, i)
-int a_lineno;
-int i;
+void
+dollar_warning (int a_lineno, int i)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
end of the current rule\n", myname, a_lineno, input_file_name, i);
}
-
-dollar_error(a_lineno, a_line, a_cptr)
-int a_lineno;
-char *a_line;
-char *a_cptr;
+void
+dollar_error (int a_lineno, const char *a_line, char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
myname, a_lineno, input_file_name);
@@ -285,51 +250,46 @@ char *a_cptr;
done(1);
}
-
-untyped_lhs()
+void
+untyped_lhs (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n",
myname, lineno, input_file_name);
/** done(1); */
}
-
-untyped_rhs(i, s)
-int i;
-char *s;
+void
+untyped_rhs (int i, const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
myname, lineno, input_file_name, i, s);
/** done(1); */
}
-
-unknown_rhs(i)
-int i;
+void
+unknown_rhs (int i)
{
fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
myname, lineno, input_file_name, i);
done(1);
}
-
-default_action_warning()
+void
+default_action_warning (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
undefined value to $$\n", myname, lineno, input_file_name);
}
-
-undefined_goal(s)
-char *s;
+void
+undefined_goal (const char *s)
{
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
done(1);
}
-
-undefined_symbol_warning(s)
-char *s;
+void
+undefined_symbol_warning (const char *s)
{
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
}
diff --git a/mcs/jay/lalr.c b/mcs/jay/lalr.c
index bf9aec846b7..81656753bc5 100644
--- a/mcs/jay/lalr.c
+++ b/mcs/jay/lalr.c
@@ -60,7 +60,8 @@ short *goto_map;
short *from_state;
short *to_state;
-short **transpose();
+static short **
+transpose (short **R, int n);
static int infinity;
static int maxrhs;
@@ -73,8 +74,50 @@ static short *INDEX;
static short *VERTICES;
static int top;
+static void
+set_state_table (void);
-lalr()
+static void
+set_accessing_symbol (void);
+
+static void
+set_shift_table (void);
+
+static void
+set_reduction_table (void);
+
+static void
+set_maxrhs (void);
+
+static void
+initialize_LA (void);
+
+static void
+set_goto_map (void);
+
+static void
+initialize_F (void);
+
+static void
+build_relations (void);
+
+static void
+compute_FOLLOWS (void);
+
+static void
+compute_lookaheads (void);
+
+static void
+traverse (int i);
+
+static void
+digraph (short **relation);
+
+static void
+add_lookback_edge (int stateno, int ruleno, int gotono);
+
+void
+lalr (void)
{
tokensetsize = WORDSIZE(ntokens);
@@ -91,9 +134,8 @@ lalr()
compute_lookaheads();
}
-
-
-set_state_table()
+static void
+set_state_table (void)
{
register core *sp;
@@ -102,9 +144,8 @@ set_state_table()
state_table[sp->number] = sp;
}
-
-
-set_accessing_symbol()
+static void
+set_accessing_symbol (void)
{
register core *sp;
@@ -113,9 +154,8 @@ set_accessing_symbol()
accessing_symbol[sp->number] = sp->accessing_symbol;
}
-
-
-set_shift_table()
+static void
+set_shift_table (void)
{
register shifts *sp;
@@ -124,9 +164,8 @@ set_shift_table()
shift_table[sp->number] = sp;
}
-
-
-set_reduction_table()
+static void
+set_reduction_table (void)
{
register reductions *rp;
@@ -135,9 +174,8 @@ set_reduction_table()
reduction_table[rp->number] = rp;
}
-
-
-set_maxrhs()
+static void
+set_maxrhs (void)
{
register short *itemp;
register short *item_end;
@@ -163,9 +201,8 @@ set_maxrhs()
maxrhs = max;
}
-
-
-initialize_LA()
+static void
+initialize_LA (void)
{
register int i, j, k;
register reductions *rp;
@@ -201,8 +238,8 @@ initialize_LA()
}
}
-
-set_goto_map()
+static void
+set_goto_map (void)
{
register shifts *sp;
register int i;
@@ -271,10 +308,8 @@ set_goto_map()
/* Map_goto maps a state/symbol pair into its numeric representation. */
-int
-map_goto(state, symbol)
-int state;
-int symbol;
+static int
+map_goto (int state, int symbol)
{
register int high;
register int low;
@@ -298,9 +333,8 @@ int symbol;
}
}
-
-
-initialize_F()
+static void
+initialize_F (void)
{
register int i;
register int j;
@@ -375,9 +409,8 @@ initialize_F()
FREE(edge);
}
-
-
-build_relations()
+static void
+build_relations (void)
{
register int i;
register int j;
@@ -468,9 +501,8 @@ build_relations()
FREE(states);
}
-
-add_lookback_edge(stateno, ruleno, gotono)
-int stateno, ruleno, gotono;
+static void
+add_lookback_edge (int stateno, int ruleno, int gotono)
{
register int i, k;
register int found;
@@ -494,12 +526,8 @@ int stateno, ruleno, gotono;
lookback[i] = sp;
}
-
-
-short **
-transpose(R, n)
-short **R;
-int n;
+static short **
+transpose (short **R, int n)
{
register short **new_R;
register short **temp_R;
@@ -552,15 +580,14 @@ int n;
return (new_R);
}
-
-
-compute_FOLLOWS()
+static void
+compute_FOLLOWS (void)
{
digraph(includes);
}
-
-compute_lookaheads()
+static void
+compute_lookaheads (void)
{
register int i, n;
register unsigned *fp1, *fp2, *fp3;
@@ -593,9 +620,8 @@ compute_lookaheads()
FREE(F);
}
-
-digraph(relation)
-short **relation;
+static void
+digraph (short **relation)
{
register int i;
@@ -619,10 +645,8 @@ short **relation;
FREE(VERTICES);
}
-
-
-traverse(i)
-register int i;
+static void
+traverse (int i)
{
register unsigned *fp1;
register unsigned *fp2;
diff --git a/mcs/jay/lr0.c b/mcs/jay/lr0.c
index 43106ea6cf3..8e2e8a0305f 100644
--- a/mcs/jay/lr0.c
+++ b/mcs/jay/lr0.c
@@ -49,8 +49,11 @@ core *first_state;
shifts *first_shift;
reductions *first_reduction;
-int get_state();
-core *new_state();
+static int
+get_state (int symbol);
+
+static core *
+new_state (int symbol);
static core **state_set;
static core *this_state;
@@ -68,8 +71,25 @@ static short **kernel_base;
static short **kernel_end;
static short *kernel_items;
+#ifdef DEBUG
+static void
+print_derives (void);
+#endif
+
+static void
+save_reductions (void);
-allocate_itemsets()
+static void
+save_shifts (void);
+
+static void
+new_itemsets (void);
+
+static void
+initialize_states (void);
+
+static void
+allocate_itemsets (void)
{
register short *itemp;
register short *item_end;
@@ -110,8 +130,8 @@ allocate_itemsets()
kernel_end = NEW2(nsyms, short *);
}
-
-allocate_storage()
+static void
+allocate_storage (void)
{
allocate_itemsets();
shiftset = NEW2(nsyms, short);
@@ -119,8 +139,8 @@ allocate_storage()
state_set = NEW2(nitems, core *);
}
-
-append_states()
+static void
+append_states (void)
{
register int i;
register int j;
@@ -148,8 +168,8 @@ append_states()
}
}
-
-free_storage()
+static void
+free_storage (void)
{
FREE(shift_symbol);
FREE(redset);
@@ -160,9 +180,8 @@ free_storage()
FREE(state_set);
}
-
-
-generate_states()
+static void
+generate_states (void)
{
allocate_storage();
itemset = NEW2(nitems, short);
@@ -187,11 +206,8 @@ generate_states()
free_storage();
}
-
-
int
-get_state(symbol)
-int symbol;
+get_state (int symbol)
{
register int key;
register short *isp1;
@@ -252,9 +268,8 @@ int symbol;
return (sp->number);
}
-
-
-initialize_states()
+static void
+initialize_states (void)
{
register int i;
register short *start_derives;
@@ -280,8 +295,8 @@ initialize_states()
nstates = 1;
}
-
-new_itemsets()
+static void
+new_itemsets (void)
{
register int i;
register int shiftcount;
@@ -315,11 +330,8 @@ new_itemsets()
nshifts = shiftcount;
}
-
-
-core *
-new_state(symbol)
-int symbol;
+static core *
+new_state (int symbol)
{
register int n;
register core *p;
@@ -355,10 +367,10 @@ int symbol;
return (p);
}
-
/* show_cores is used for debugging */
-show_cores()
+void
+show_cores (void)
{
core *p;
int i, j, k, n;
@@ -393,7 +405,8 @@ show_cores()
/* show_ritems is used for debugging */
-show_ritems()
+void
+show_ritems (void)
{
int i;
@@ -401,9 +414,9 @@ show_ritems()
printf("ritem[%d] = %d\n", i, ritem[i]);
}
-
/* show_rrhs is used for debugging */
-show_rrhs()
+void
+show_rrhs (void)
{
int i;
@@ -414,7 +427,8 @@ show_rrhs()
/* show_shifts is used for debugging */
-show_shifts()
+void
+show_shifts (void)
{
shifts *p;
int i, j, k;
@@ -431,8 +445,8 @@ show_shifts()
}
}
-
-save_shifts()
+static void
+save_shifts (void)
{
register shifts *p;
register short *sp1;
@@ -464,9 +478,8 @@ save_shifts()
}
}
-
-
-save_reductions()
+static void
+save_reductions (void)
{
register short *isp;
register short *rp1;
@@ -514,8 +527,8 @@ save_reductions()
}
}
-
-set_derives()
+static void
+set_derives (void)
{
register int i, k;
register int lhs;
@@ -545,14 +558,18 @@ set_derives()
#endif
}
-free_derives()
+#if 0
+void
+free_derives (void)
{
FREE(derives[start_symbol]);
FREE(derives);
}
+#endif
#ifdef DEBUG
-print_derives()
+static void
+print_derives (void)
{
register int i;
register short *sp;
@@ -573,14 +590,14 @@ print_derives()
}
#endif
-
-set_nullable()
+static void
+set_nullable (void)
{
register int i, j;
register int empty;
int done;
- nullable = MALLOC(nsyms);
+ nullable = (char*)MALLOC(nsyms);
if (nullable == 0) no_space();
for (i = 0; i < nsyms; ++i)
@@ -622,14 +639,14 @@ set_nullable()
#endif
}
-
-free_nullable()
+void
+free_nullable (void)
{
FREE(nullable);
}
-
-lr0()
+void
+lr0 (void)
{
set_derives();
set_nullable();
diff --git a/mcs/jay/main.c b/mcs/jay/main.c
index fcac218b1df..e0397635719 100644
--- a/mcs/jay/main.c
+++ b/mcs/jay/main.c
@@ -47,19 +47,26 @@ static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
#include <signal.h>
#include "defs.h"
+// FIXME autoconf or use remove instead of unlink
+#ifdef _MSC_VER
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
char tflag;
char vflag;
int csharp = 0;
-char *file_prefix = "y";
-char *myname = "yacc";
-char *temp_form = "yacc.XXXXXXX";
+const char *file_prefix = (char*)"y";
+char *myname = (char*)"yacc";
+const char *temp_form = "yacc.XXXXXXX";
int lineno;
int outline;
char *action_file_name;
-char *input_file_name = "";
+char *input_file_name = (char*)"";
char *prolog_file_name;
char *local_file_name;
char *verbose_file_name;
@@ -100,8 +107,8 @@ extern char* mktemp();
extern char *getenv();
-done(k)
-int k;
+void
+done (int k)
{
if (action_file) { fclose(action_file); unlink(action_file_name); }
if (prolog_file) { fclose(prolog_file); unlink(prolog_file_name); }
@@ -109,16 +116,15 @@ int k;
exit(k);
}
-
-void
-onintr(signo)
- int signo;
+static void
+onintr (int signo)
{
+ (void)signo; // unused
done(1);
}
-
-set_signals()
+static void
+set_signals (void)
{
#ifdef SIGINT
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
@@ -134,23 +140,22 @@ set_signals()
#endif
}
-
-usage()
+static void
+usage (void)
{
fprintf(stderr, "usage: %s [-tvcp] [-b file_prefix] filename\n", myname);
exit(1);
}
-void
+static void
print_skel_dir(void)
{
printf ("%s\n", SKEL_DIRECTORY);
exit (0);
}
-getargs(argc, argv)
-int argc;
-char *argv[];
+static void
+getargs (int argc, char *argv[])
{
register int i;
register char *s;
@@ -240,17 +245,15 @@ no_more_options:;
input_file_name = argv[i];
}
-
char *
-allocate(n)
-unsigned n;
+allocate (unsigned n)
{
register char *p;
p = NULL;
if (n)
{
- p = CALLOC(1, n);
+ p = (char*)CALLOC(1, n);
if (!p) no_space();
}
return (p);
@@ -262,10 +265,11 @@ unsigned n;
#define GNUC_UNUSED
#endif
-create_file_names()
+static void
+create_file_names (void)
{
int i, len;
- char *tmpdir;
+ const char *tmpdir;
int mkstemp_res GNUC_UNUSED;
#if defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
@@ -282,11 +286,11 @@ create_file_names()
if (len && tmpdir[len-1] != '/')
++i;
- action_file_name = MALLOC(i);
+ action_file_name = (char*)MALLOC(i);
if (action_file_name == 0) no_space();
- prolog_file_name = MALLOC(i);
+ prolog_file_name = (char*)MALLOC(i);
if (prolog_file_name == 0) no_space();
- local_file_name = MALLOC(i);
+ local_file_name = (char*)MALLOC(i);
if (local_file_name == 0) no_space();
strcpy(action_file_name, tmpdir);
@@ -317,7 +321,7 @@ create_file_names()
if (vflag)
{
- verbose_file_name = MALLOC(len + 8);
+ verbose_file_name = (char*)MALLOC(len + 8);
if (verbose_file_name == 0)
no_space();
strcpy(verbose_file_name, file_prefix);
@@ -325,8 +329,8 @@ create_file_names()
}
}
-
-open_files()
+static void
+open_files (void)
{
create_file_names();
@@ -359,9 +363,7 @@ open_files()
int
-main(argc, argv)
-int argc;
-char *argv[];
+main (int argc, char *argv[])
{
set_signals();
getargs(argc, argv);
diff --git a/mcs/jay/mkpar.c b/mcs/jay/mkpar.c
index 42ead14514d..ea570a25561 100644
--- a/mcs/jay/mkpar.c
+++ b/mcs/jay/mkpar.c
@@ -53,13 +53,35 @@ short final_state;
static int SRcount;
static int RRcount;
-extern action *parse_actions();
-extern action *get_shifts();
-extern action *add_reductions();
-extern action *add_reduce();
+static action *
+parse_actions (int stateno);
+static action *
+get_shifts (int stateno);
-make_parser()
+static action *
+add_reductions (int stateno, action *actions);
+
+static action *
+add_reduce (action *actions, int ruleno, int symbol);
+
+static void
+defreds (void);
+
+static void
+remove_conflicts (void);
+
+static void
+total_conflicts (void);
+
+static void
+find_final_state (void);
+
+static void
+unused_rules (void);
+
+void
+make_parser (void)
{
register int i;
@@ -74,10 +96,8 @@ make_parser()
defreds();
}
-
-action *
-parse_actions(stateno)
-register int stateno;
+static action *
+parse_actions (int stateno)
{
register action *actions;
@@ -86,10 +106,8 @@ register int stateno;
return (actions);
}
-
-action *
-get_shifts(stateno)
-int stateno;
+static action *
+get_shifts (int stateno)
{
register action *actions, *temp;
register shifts *sp;
@@ -122,10 +140,8 @@ int stateno;
return (actions);
}
-action *
-add_reductions(stateno, actions)
-int stateno;
-register action *actions;
+static action *
+add_reductions (int stateno, action *actions)
{
register int i, j, m, n;
register int ruleno, tokensetsize;
@@ -147,11 +163,8 @@ register action *actions;
return (actions);
}
-
-action *
-add_reduce(actions, ruleno, symbol)
-register action *actions;
-register int ruleno, symbol;
+static action *
+add_reduce (action *actions, int ruleno, int symbol)
{
register action *temp, *prev, *next;
@@ -188,8 +201,8 @@ register int ruleno, symbol;
return (actions);
}
-
-find_final_state()
+static void
+find_final_state (void)
{
register int goal, i;
register short *to_state;
@@ -205,8 +218,8 @@ find_final_state()
}
}
-
-unused_rules()
+static void
+unused_rules (void)
{
register int i;
register action *p;
@@ -231,14 +244,16 @@ unused_rules()
if (!rules_used[i]) ++nunused;
if (nunused)
+ {
if (nunused == 1)
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
else
fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
+ }
}
-
-remove_conflicts()
+static void
+remove_conflicts (void)
{
register int i;
register int symbol;
@@ -312,8 +327,8 @@ remove_conflicts()
}
}
-
-total_conflicts()
+static void
+total_conflicts (void)
{
fprintf(stderr, "%s: ", myname);
if (SRtotal == 1)
@@ -332,10 +347,8 @@ total_conflicts()
fprintf(stderr, ".\n");
}
-
-int
-sole_reduction(stateno)
-int stateno;
+static int
+sole_reduction (int stateno)
{
register int count, ruleno;
register action *p;
@@ -361,8 +374,8 @@ int stateno;
return (ruleno);
}
-
-defreds()
+static void
+defreds (void)
{
register int i;
@@ -371,8 +384,8 @@ defreds()
defred[i] = sole_reduction(i);
}
-free_action_row(p)
-register action *p;
+static void
+free_action_row (action *p)
{
register action *q;
@@ -384,7 +397,8 @@ register action *p;
}
}
-free_parser()
+void
+free_parser (void)
{
register int i;
diff --git a/mcs/jay/output.c b/mcs/jay/output.c
index d1e2c14a1b2..9e883a7504d 100644
--- a/mcs/jay/output.c
+++ b/mcs/jay/output.c
@@ -58,7 +58,75 @@ static int lowzero;
static int high;
extern int csharp;
-output () {
+static void
+free_itemsets (void);
+
+static void
+free_reductions (void);
+
+static void
+free_shifts (void);
+
+static void
+goto_actions (void);
+
+static void
+output_actions (void);
+
+static void
+output_base (void);
+
+static void
+output_check (void);
+
+static void
+output_debug (void);
+
+static void
+output_defines (const char *prefix);
+
+static void
+output_rule_data (void);
+
+static void
+output_semantic_actions (void);
+
+static void
+output_stored_text (FILE *file, const char *name);
+
+static void
+output_table (void);
+
+static void
+output_trailing_text (void);
+
+static void
+save_column (int symbol, int default_state);
+
+static void
+sort_actions (void);
+
+static void
+output_yydefred (void);
+
+static int
+default_goto (int symbol);
+
+static int
+matching_vector (int vector);
+
+static int
+pack_vector (int vector);
+
+static void
+token_actions (void);
+
+static void
+pack_table (void);
+
+void
+output (void)
+{
int lno = 0;
char buf [128];
@@ -77,7 +145,7 @@ output () {
case '.': break;
default:
cp = strtok(buf, " \t\r\n");
- if (cp)
+ if (cp) {
if (strcmp(cp, "actions") == 0) output_semantic_actions();
else if (strcmp(cp, "debug") == 0) output_debug();
else if (strcmp(cp, "epilog") == 0) output_trailing_text();
@@ -91,6 +159,7 @@ output () {
output_defines(strtok(NULL, "\r\n"));
else
fprintf(stderr, "jay: unknown call (%s) in line %d\n", cp, lno);
+ }
continue;
}
fputs(buf+1, stdout), ++ outline;
@@ -98,7 +167,8 @@ output () {
free_parser();
}
-output_rule_data()
+static void
+output_rule_data (void)
{
register int i;
register int j;
@@ -160,8 +230,8 @@ output_rule_data()
printf("\n };\n");
}
-
-output_yydefred()
+static void
+output_yydefred (void)
{
register int i, j;
@@ -189,8 +259,8 @@ output_yydefred()
printf("\n };\n");
}
-
-output_actions()
+static void
+output_actions (void)
{
nvectors = 2*nstates + nvars;
@@ -217,8 +287,8 @@ output_actions()
output_check();
}
-
-token_actions()
+static void
+token_actions (void)
{
register int i, j;
register int shiftcount, reducecount;
@@ -302,7 +372,8 @@ token_actions()
FREE(actionrow);
}
-goto_actions()
+static void
+goto_actions (void)
{
register int i, j, k;
@@ -334,9 +405,8 @@ goto_actions()
FREE(state_count);
}
-int
-default_goto(symbol)
-int symbol;
+static int
+default_goto (int symbol)
{
register int i;
register int m;
@@ -369,11 +439,8 @@ int symbol;
return (default_state);
}
-
-
-save_column(symbol, default_state)
-int symbol;
-int default_state;
+static void
+save_column (int symbol, int default_state)
{
register int i;
register int m;
@@ -413,7 +480,8 @@ int default_state;
width[symno] = sp1[-1] - sp[0] + 1;
}
-sort_actions()
+static void
+sort_actions (void)
{
register int i;
register int j;
@@ -447,8 +515,8 @@ sort_actions()
}
}
-
-pack_table()
+static void
+pack_table (void)
{
register int i;
register int place;
@@ -510,9 +578,8 @@ pack_table()
/* faster. Also, it depends on the vectors being in a specific */
/* order. */
-int
-matching_vector(vector)
-int vector;
+static int
+matching_vector (int vector)
{
register int i;
register int j;
@@ -549,11 +616,8 @@ int vector;
return (-1);
}
-
-
-int
-pack_vector(vector)
-int vector;
+static int
+pack_vector (int vector)
{
register int i, j, k, l;
register int t;
@@ -627,9 +691,8 @@ int vector;
}
}
-
-
-output_base()
+static void
+output_base (void)
{
register int i, j;
@@ -695,9 +758,8 @@ output_base()
FREE(base);
}
-
-
-output_table()
+static void
+output_table (void)
{
register int i;
register int j;
@@ -724,9 +786,8 @@ output_table()
FREE(table);
}
-
-
-output_check()
+static void
+output_check (void)
{
register int i;
register int j;
@@ -755,12 +816,10 @@ output_check()
FREE(check);
}
-
-int
-is_C_identifier(name)
-char *name;
+static int
+is_C_identifier (const char *name)
{
- register char *s;
+ const char *s;
register int c;
s = name;
@@ -780,7 +839,7 @@ char *name;
if (!isalpha(c) && c != '_' && c != '$')
return (0);
- while (c = *++s)
+ while ((c = *++s))
{
if (!isalnum(c) && c != '_' && c != '$')
return (0);
@@ -788,12 +847,11 @@ char *name;
return (1);
}
-
-output_defines(prefix)
-char *prefix;
+static void
+output_defines (const char *prefix)
{
register int c, i;
- register char *s;
+ const char *s;
for (i = 2; i < ntokens; ++i)
{
@@ -816,7 +874,7 @@ char *prefix;
{
putchar(c);
}
- while (c = *++s);
+ while ((c = *++s));
}
++outline;
printf(" = %d%s\n", symbol_value[i], csharp ? ";" : ";");
@@ -827,10 +885,8 @@ char *prefix;
printf(" %s yyErrorCode = %d%s\n", prefix ? prefix : "", symbol_value[1], csharp ? ";" : ";");
}
-
-output_stored_text(file, name)
-FILE *file;
-char *name;
+static void
+output_stored_text (FILE *file, const char *name)
{
register int c;
register FILE *in;
@@ -854,12 +910,12 @@ char *name;
fclose(in);
}
-
-output_debug()
+static void
+output_debug (void)
{
register int i, j, k, max;
char **symnam, *s;
- char * prefix = tflag ? "" : "//t";
+ const char * prefix = tflag ? "" : "//t";
++outline;
printf(" protected %s int yyFinal = %d;\n", csharp ? "const" : "static final", final_state);
@@ -941,12 +997,12 @@ output_debug()
symnam[i] = 0;
for (i = ntokens - 1; i >= 2; --i)
symnam[symbol_value[i]] = symbol_name[i];
- symnam[0] = "end-of-file";
+ symnam[0] = (char*)"end-of-file";
j = 70; fputs(" ", stdout);
for (i = 0; i <= max; ++i)
{
- if (s = symnam[i])
+ if ((s = symnam[i]))
{
if (s[0] == '"')
{
@@ -1068,7 +1124,8 @@ output_debug()
FREE(symnam);
}
-output_trailing_text()
+static void
+output_trailing_text (void)
{
register int c, last;
register FILE *in;
@@ -1116,8 +1173,8 @@ output_trailing_text()
printf(default_line_format, ++outline + 1);
}
-
-output_semantic_actions()
+static void
+output_semantic_actions (void)
{
register int c, last;
@@ -1150,8 +1207,8 @@ output_semantic_actions()
printf(default_line_format, ++outline + 1);
}
-
-free_itemsets()
+static void
+free_itemsets (void)
{
register core *cp, *next;
@@ -1163,8 +1220,8 @@ free_itemsets()
}
}
-
-free_shifts()
+static void
+free_shifts (void)
{
register shifts *sp, *next;
@@ -1176,9 +1233,8 @@ free_shifts()
}
}
-
-
-free_reductions()
+static void
+free_reductions (void)
{
register reductions *rp, *next;
diff --git a/mcs/jay/reader.c b/mcs/jay/reader.c
index 9d8fdcb4f24..96bcac4634e 100644
--- a/mcs/jay/reader.c
+++ b/mcs/jay/reader.c
@@ -52,52 +52,71 @@ static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
#define LINESIZE 100
+static
char *cache;
+static
int cinc, cache_size;
+static
int ntags, tagmax;
+static
char **tag_table;
+static
char saw_eof;
char *cptr, *line;
+static
int linesize;
+static
bucket *goal;
+static
int prec;
+static
int gensym;
+static
char last_was_action;
+static
int maxitems;
+static
bucket **pitem;
+static
int maxrules;
+static
bucket **plhs;
+static
int maxmethods;
+static
int name_pool_size;
+static
char *name_pool;
-char *line_format = "\t\t\t\t\t// line %d \"%s\"\n";
-char *default_line_format = "\t\t\t\t\t// line %d\n";
+const char *line_format = "\t\t\t\t\t// line %d \"%s\"\n";
+const char *default_line_format = "\t\t\t\t\t// line %d\n";
+static void
+start_rule (bucket *bp, int s_lineno);
-cachec(c)
-int c;
+static void
+cachec (int c)
{
assert(cinc >= 0);
if (cinc >= cache_size)
{
cache_size += 256;
- cache = REALLOC(cache, cache_size);
+ cache = (char*)REALLOC(cache, cache_size);
if (cache == 0) no_space();
}
cache[cinc] = c;
++cinc;
}
-
-get_line()
+static void
+get_line (void)
{
register FILE *f = input_file;
register int c;
@@ -115,7 +134,7 @@ get_line()
{
if (line) FREE(line);
linesize = LINESIZE + 1;
- line = MALLOC(linesize);
+ line = (char*)MALLOC(linesize);
if (line == 0) no_space();
}
@@ -128,7 +147,7 @@ get_line()
if (++i >= linesize)
{
linesize += LINESIZE;
- line = REALLOC(line, linesize);
+ line = (char*)REALLOC(line, linesize);
if (line == 0) no_space();
}
c = getc(f);
@@ -142,16 +161,15 @@ get_line()
}
}
-
-char *
-dup_line()
+static char *
+dup_line (void)
{
register char *p, *s, *t;
if (line == 0) return (0);
s = line;
while (*s != '\n') ++s;
- p = MALLOC(s - line + 1);
+ p = (char*)MALLOC(s - line + 1);
if (p == 0) no_space();
s = line;
@@ -160,8 +178,8 @@ dup_line()
return (p);
}
-
-skip_comment()
+static void
+skip_comment (void)
{
register char *s;
@@ -190,9 +208,8 @@ skip_comment()
}
}
-
-int
-nextc()
+static int
+nextc (void)
{
register char *s;
@@ -252,9 +269,8 @@ nextc()
}
}
-
-int
-keyword()
+static int
+keyword (void)
{
register int c;
char *t_cptr = cptr;
@@ -311,9 +327,8 @@ keyword()
/*NOTREACHED*/
}
-
-copy_text(f)
-FILE *f;
+static void
+copy_text (FILE *f)
{
register int c;
int quote;
@@ -434,9 +449,8 @@ loop:
}
}
-int
-hexval(c)
-int c;
+static int
+hexval (int c)
{
if (c >= '0' && c <= '9')
return (c - '0');
@@ -447,9 +461,8 @@ int c;
return (-1);
}
-
-bucket *
-get_literal()
+static bucket *
+get_literal (void)
{
register int c, quote;
register int i;
@@ -528,7 +541,7 @@ get_literal()
FREE(s_line);
n = cinc;
- s = MALLOC(n);
+ s = (char*)MALLOC(n);
if (s == 0) no_space();
for (i = 0; i < n; ++i)
@@ -586,12 +599,10 @@ get_literal()
return (bp);
}
-
-int
-is_reserved(name)
-char *name;
+static int
+is_reserved (const char *name)
{
- char *s;
+ const char *s;
if (strcmp(name, ".") == 0 ||
strcmp(name, "$accept") == 0 ||
@@ -608,9 +619,8 @@ char *name;
return (0);
}
-
-bucket *
-get_name()
+static bucket *
+get_name (void)
{
register int c;
@@ -624,9 +634,8 @@ get_name()
return (lookup(cache));
}
-
-int
-get_number()
+static int
+get_number (void)
{
register int c;
register int n;
@@ -638,9 +647,8 @@ get_number()
return (n);
}
-
-char *
-get_tag(int emptyOk)
+static char *
+get_tag (int emptyOk)
{
register int c;
register int i;
@@ -683,7 +691,7 @@ get_tag(int emptyOk)
if (tag_table == 0) no_space();
}
- s = MALLOC(cinc);
+ s = (char*)MALLOC(cinc);
if (s == 0) no_space();
strcpy(s, cache);
tag_table[ntags] = s;
@@ -692,9 +700,8 @@ get_tag(int emptyOk)
return (s);
}
-
-declare_tokens(assoc)
-int assoc;
+static void
+declare_tokens (int assoc)
{
register int c;
register bucket *bp;
@@ -754,8 +761,8 @@ int assoc;
}
}
-
-declare_types()
+static void
+declare_types (void)
{
register int c;
register bucket *bp;
@@ -782,8 +789,8 @@ declare_types()
}
}
-
-declare_start()
+static void
+declare_start (void)
{
register int c;
register bucket *bp;
@@ -800,13 +807,13 @@ declare_start()
goal = bp;
}
-
-read_declarations()
+static void
+read_declarations (void)
{
register int c, k;
cache_size = 256;
- cache = MALLOC(cache_size);
+ cache = (char*)MALLOC(cache_size);
if (cache == 0) no_space();
for (;;)
@@ -841,8 +848,8 @@ read_declarations()
}
}
-
-initialize_grammar()
+static void
+initialize_grammar (void)
{
nitems = 4;
maxitems = 300;
@@ -873,8 +880,8 @@ initialize_grammar()
rassoc[2] = TOKEN;
}
-
-expand_items()
+static void
+expand_items (void)
{
maxitems += 300;
pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *));
@@ -882,8 +889,8 @@ expand_items()
memset(pitem+maxitems-300, 0, 300*sizeof(bucket *));
}
-
-expand_rules()
+static void
+expand_rules (void)
{
maxrules += 100;
plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *));
@@ -894,8 +901,8 @@ expand_rules()
if (rassoc == 0) no_space();
}
-
-advance_to_start()
+static void
+advance_to_start (void)
{
register int c;
register bucket *bp;
@@ -944,10 +951,8 @@ advance_to_start()
++cptr;
}
-
-start_rule(bp, s_lineno)
-register bucket *bp;
-int s_lineno;
+static void
+start_rule (bucket *bp, int s_lineno)
{
if (bp->class == TERM)
terminal_lhs(s_lineno);
@@ -959,8 +964,8 @@ int s_lineno;
rassoc[nrules] = TOKEN;
}
-
-end_rule()
+static void
+end_rule (void)
{
register int i;
@@ -979,8 +984,8 @@ end_rule()
++nrules;
}
-
-insert_empty_rule()
+static void
+insert_empty_rule (void)
{
register bucket *bp, **bpp;
@@ -996,7 +1001,7 @@ insert_empty_rule()
expand_items();
bpp = pitem + nitems - 1;
*bpp-- = bp;
- while (bpp[0] = bpp[-1]) --bpp;
+ while ((bpp[0] = bpp[-1])) --bpp;
if (++nrules >= maxrules)
expand_rules();
@@ -1008,8 +1013,8 @@ insert_empty_rule()
rassoc[nrules-1] = TOKEN;
}
-
-add_symbol()
+static void
+add_symbol (void)
{
register int c;
register bucket *bp;
@@ -1039,8 +1044,8 @@ add_symbol()
pitem[nitems-1] = bp;
}
-
-copy_action()
+static void
+copy_action (void)
{
register int c;
register int i, n;
@@ -1303,7 +1308,7 @@ loop:
else if (nmethods == maxmethods)
{
maxmethods += 500;
- methods = REALLOC (methods, maxmethods*sizeof(char *));
+ methods = (char**)REALLOC (methods, maxmethods*sizeof(char *));
}
line_define = NEW2(snprintf(NULL, 0, line_format, a_lineno, input_file_name)+1, char);
@@ -1329,12 +1334,11 @@ loop:
fprintf(f, "\n break;\n");
}
-
-int
-mark_symbol()
+static int
+mark_symbol (void)
{
register int c;
- register bucket *bp;
+ register bucket *bp = NULL;
c = cptr[1];
if (c == '%' || c == '\\')
@@ -1373,8 +1377,8 @@ mark_symbol()
return (0);
}
-
-read_grammar()
+static void
+read_grammar (void)
{
register int c;
@@ -1406,8 +1410,8 @@ read_grammar()
end_rule();
}
-
-free_tags()
+static void
+free_tags (void)
{
register int i;
@@ -1421,8 +1425,8 @@ free_tags()
FREE(tag_table);
}
-
-pack_names()
+static void
+pack_names (void)
{
register bucket *bp;
register char *p, *s, *t;
@@ -1430,7 +1434,7 @@ pack_names()
name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
for (bp = first_symbol; bp; bp = bp->next)
name_pool_size += strlen(bp->name) + 1;
- name_pool = MALLOC(name_pool_size);
+ name_pool = (char*)MALLOC(name_pool_size);
if (name_pool == 0) no_space();
strcpy(name_pool, "$accept");
@@ -1440,14 +1444,14 @@ pack_names()
{
p = t;
s = bp->name;
- while (*t++ = *s++) continue;
+ while ((*t++ = *s++)) continue;
FREE(bp->name);
bp->name = p;
}
}
-
-check_symbols()
+static void
+check_symbols (void)
{
register bucket *bp;
@@ -1464,8 +1468,8 @@ check_symbols()
}
}
-
-pack_symbols()
+static void
+pack_symbols (void)
{
register bucket *bp;
register bucket **v;
@@ -1487,7 +1491,7 @@ pack_symbols()
if (symbol_value == 0) no_space();
symbol_prec = (short *) MALLOC(nsyms*sizeof(short));
if (symbol_prec == 0) no_space();
- symbol_assoc = MALLOC(nsyms);
+ symbol_assoc = (char*)MALLOC(nsyms);
if (symbol_assoc == 0) no_space();
v = (bucket **) MALLOC(nsyms*sizeof(bucket *));
@@ -1588,8 +1592,8 @@ pack_symbols()
FREE(v);
}
-
-pack_grammar()
+static void
+pack_grammar (void)
{
register int i, j;
int assoc, prec;
@@ -1602,7 +1606,7 @@ pack_grammar()
if (rrhs == 0) no_space();
rprec = (short *) REALLOC(rprec, nrules*sizeof(short));
if (rprec == 0) no_space();
- rassoc = REALLOC(rassoc, nrules);
+ rassoc = (char*)REALLOC(rassoc, nrules);
if (rassoc == 0) no_space();
ritem[0] = -1;
@@ -1647,8 +1651,8 @@ pack_grammar()
FREE(pitem);
}
-
-print_grammar()
+static void
+print_grammar (void)
{
register int i, j, k;
int spacing;
@@ -1683,8 +1687,8 @@ print_grammar()
}
}
-
-reader()
+void
+reader (void)
{
create_symbol_table();
read_declarations();
diff --git a/mcs/jay/symtab.c b/mcs/jay/symtab.c
index 0c5f55c535b..aa14654f53c 100644
--- a/mcs/jay/symtab.c
+++ b/mcs/jay/symtab.c
@@ -50,27 +50,23 @@ bucket **symbol_table;
bucket *first_symbol;
bucket *last_symbol;
-
-int
-hash(name)
-char *name;
+static int
+hash (const char *name)
{
- register char *s;
+ const char *s;
register int c, k;
assert(name && *name);
s = name;
k = *s;
- while (c = *++s)
+ while ((c = *++s))
k = (31*k + c) & (TABLE_SIZE - 1);
return (k);
}
-
bucket *
-make_bucket(name)
-char *name;
+make_bucket (const char *name)
{
register bucket *bp;
@@ -79,7 +75,7 @@ char *name;
if (bp == 0) no_space();
bp->link = 0;
bp->next = 0;
- bp->name = MALLOC(strlen(name) + 1);
+ bp->name = (char*)MALLOC(strlen(name) + 1);
if (bp->name == 0) no_space();
bp->tag = 0;
bp->value = UNDEFINED;
@@ -94,10 +90,8 @@ char *name;
return (bp);
}
-
bucket *
-lookup(name)
-char *name;
+lookup (const char *name)
{
register bucket *bp, **bpp;
@@ -118,8 +112,8 @@ char *name;
return (bp);
}
-
-create_symbol_table()
+void
+create_symbol_table (void)
{
register int i;
register bucket *bp;
@@ -138,15 +132,15 @@ create_symbol_table()
symbol_table[hash("error")] = bp;
}
-
-free_symbol_table()
+void
+free_symbol_table (void)
{
FREE(symbol_table);
symbol_table = 0;
}
-
-free_symbols()
+void
+free_symbols (void)
{
register bucket *p, *q;
diff --git a/mcs/jay/verbose.c b/mcs/jay/verbose.c
index 33ae265ee2e..36cc036c682 100644
--- a/mcs/jay/verbose.c
+++ b/mcs/jay/verbose.c
@@ -42,7 +42,38 @@ static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91";
static short *null_rules;
-verbose()
+static void
+print_gotos (int stateno);
+
+static void
+print_shifts (action *p);
+
+static void
+print_reductions (action *p, int defred);
+
+static void
+print_core (int state);
+
+static void
+print_actions (int stateno);
+
+static void
+print_nulls (int state);
+
+static void
+log_unused (void);
+
+static void
+print_conflicts (int state);
+
+static void
+print_state (int state);
+
+static void
+log_conflicts (void);
+
+void
+verbose (void)
{
register int i;
@@ -65,8 +96,8 @@ verbose()
fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates);
}
-
-log_unused()
+static void
+log_unused (void)
{
register int i;
register short *p;
@@ -84,8 +115,8 @@ log_unused()
}
}
-
-log_conflicts()
+static void
+log_conflicts (void)
{
register int i;
@@ -112,9 +143,8 @@ log_conflicts()
}
}
-
-print_state(state)
-int state;
+static void
+print_state (int state)
{
if (state)
fprintf(verbose_file, "\n\n");
@@ -126,9 +156,8 @@ int state;
print_actions(state);
}
-
-print_conflicts(state)
-int state;
+static void
+print_conflicts (int state)
{
register int symbol, act, number;
register action *p;
@@ -174,9 +203,8 @@ int state;
}
}
-
-print_core(state)
-int state;
+static void
+print_core (int state)
{
register int i;
register int k;
@@ -210,9 +238,8 @@ int state;
}
}
-
-print_nulls(state)
-int state;
+static void
+print_nulls (int state)
{
register action *p;
register int i, j, k, nnulls;
@@ -254,9 +281,8 @@ int state;
fprintf(verbose_file, "\n");
}
-
-print_actions(stateno)
-int stateno;
+static void
+print_actions (int stateno)
{
register action *p;
register shifts *sp;
@@ -281,9 +307,8 @@ int stateno;
}
}
-
-print_shifts(p)
-register action *p;
+static void
+print_shifts (action *p)
{
register int count;
register action *q;
@@ -306,10 +331,8 @@ register action *p;
}
}
-
-print_reductions(p, defred)
-register action *p;
-register int defred;
+static void
+print_reductions (action *p, int defred)
{
register int k, anyreds;
register action *q;
@@ -344,9 +367,8 @@ register int defred;
}
}
-
-print_gotos(stateno)
-int stateno;
+static void
+print_gotos (int stateno)
{
register int i, k;
register int as;
diff --git a/mcs/jay/warshall.c b/mcs/jay/warshall.c
index 4672244e368..8c7ab167189 100644
--- a/mcs/jay/warshall.c
+++ b/mcs/jay/warshall.c
@@ -40,9 +40,8 @@ static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93";
#include "defs.h"
-transitive_closure(R, n)
-unsigned *R;
-int n;
+static void
+transitive_closure (unsigned *R, int n)
{
register int rowsize;
register unsigned i;
@@ -92,9 +91,8 @@ int n;
}
}
-reflexive_transitive_closure(R, n)
-unsigned *R;
-int n;
+void
+reflexive_transitive_closure (unsigned *R, int n)
{
register int rowsize;
register unsigned i;