diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-03-13 01:18:23 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-03-13 01:18:23 +0000 |
commit | 93ff803031ce4e8faa440f10206a7c772ebb919a (patch) | |
tree | 3df027802b7e94aa0d347d30adda1355364828f0 /usr.bin | |
parent | e6fd37871e59a0a101e0133296ad38b5b4f2964f (diff) |
collapse variable declarations
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/yacc/closure.c | 50 | ||||
-rw-r--r-- | usr.bin/yacc/lalr.c | 79 | ||||
-rw-r--r-- | usr.bin/yacc/lr0.c | 46 | ||||
-rw-r--r-- | usr.bin/yacc/output.c | 36 | ||||
-rw-r--r-- | usr.bin/yacc/reader.c | 28 | ||||
-rw-r--r-- | usr.bin/yacc/warshall.c | 17 |
6 files changed, 77 insertions, 179 deletions
diff --git a/usr.bin/yacc/closure.c b/usr.bin/yacc/closure.c index 44205154f04..05858178348 100644 --- a/usr.bin/yacc/closure.c +++ b/usr.bin/yacc/closure.c @@ -1,4 +1,4 @@ -/* $OpenBSD: closure.c,v 1.12 2014/03/08 00:44:14 tedu Exp $ */ +/* $OpenBSD: closure.c,v 1.13 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: closure.c,v 1.4 1996/03/19 03:21:29 jtc Exp $ */ /* @@ -46,12 +46,9 @@ static unsigned *EFF; void set_EFF(void) { - unsigned *row; - int symbol; + unsigned int *row; + int symbol, rowsize, i, rule; short *sp; - int rowsize; - int i; - int rule; rowsize = WORDSIZE(nvars); EFF = NEW2(nvars * rowsize, unsigned); @@ -80,18 +77,11 @@ set_EFF(void) void set_first_derives(void) { - unsigned *rrow; - unsigned *vrow; - int j; - unsigned k; - unsigned cword = 0; + unsigned int *rrow, *vrow; + unsigned int k, cword = 0; + int i, j, rule, rulesetsize, varsetsize; short *rp; - int rule; - int i; - int rulesetsize; - int varsetsize; - rulesetsize = WORDSIZE(nrules); varsetsize = WORDSIZE(nvars); first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize; @@ -131,18 +121,11 @@ set_first_derives(void) void closure(short *nucleus, int n) { - int ruleno; - unsigned word; - unsigned i; - short *csp; - unsigned *dsp; - unsigned *rsp; + unsigned int i, word; + short *csp, *csend; + unsigned int *dsp, *rsp, *rsend; int rulesetsize; - - short *csend; - unsigned *rsend; - int symbol; - int itemno; + int ruleno, symbol, itemno; rulesetsize = WORDSIZE(nrules); rsend = ruleset + rulesetsize; @@ -214,9 +197,8 @@ void print_EFF(void) { int i, j; - unsigned *rowp; - unsigned word; - unsigned k; + unsigned int *rowp; + unsigned int k, word; printf("\n\nEpsilon Free Firsts\n"); @@ -241,11 +223,9 @@ print_EFF(void) void print_first_derives(void) { - int i; - int j; - unsigned *rp; - unsigned cword = 0; - unsigned k; + int i, j; + unsigned int *rp; + unsigned int k, cword = 0; printf("\n\n\nFirst Derives\n"); diff --git a/usr.bin/yacc/lalr.c b/usr.bin/yacc/lalr.c index 8e5d75d3a8c..201fbcc6fd8 100644 --- a/usr.bin/yacc/lalr.c +++ b/usr.bin/yacc/lalr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lalr.c,v 1.15 2014/03/08 01:05:39 tedu Exp $ */ +/* $OpenBSD: lalr.c,v 1.16 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: lalr.c,v 1.4 1996/03/19 03:21:33 jtc Exp $ */ /* @@ -148,10 +148,8 @@ set_reduction_table(void) void set_maxrhs(void) { - short *itemp; - short *item_end; - int length; - int max; + short *itemp, *item_end; + int length, max; length = 0; max = 0; @@ -206,12 +204,9 @@ void set_goto_map(void) { shifts *sp; - int i; - int symbol; - int k; + int i, j, k, symbol; + int state1, state2; short *temp_map; - int state2; - int state1; goto_map = NEW2(nvars + 1, short) - ntokens; temp_map = NEW2(nvars + 1, short) - ntokens; @@ -270,10 +265,7 @@ set_goto_map(void) int map_goto(int state, int symbol) { - int high; - int low; - int middle; - int s; + int high, low, middle, s; low = goto_map[symbol]; high = goto_map[symbol + 1]; @@ -295,18 +287,11 @@ map_goto(int state, int symbol) void initialize_F(void) { - int i; - int j; - int k; + int i, j, k; shifts *sp; - short *edge; - unsigned *rowp; - short *rp; - short **reads; - int nedges; - int stateno; - int symbol; - int nwords; + short *edge, *rp, **reads; + unsigned int *rowp; + int nedges, stateno, symbol, nwords; nwords = ngotos * tokensetsize; F = NEW2(nwords, unsigned); @@ -366,22 +351,12 @@ initialize_F(void) void build_relations(void) { - int i; - int j; - int k; - short *rulep; - short *rp; + int i, j, k; + short *rulep, *rp; shifts *sp; - int length; - int nedges; - int done; - int state1; - int stateno; - int symbol1; - int symbol2; - short *shortp; - short *edge; - short *states; + int length, nedges, done; + int state1, stateno, symbol1, symbol2; + short *shortp, *edge, *states; short **new_includes; includes = NEW2(ngotos, short *); @@ -453,8 +428,7 @@ build_relations(void) void add_lookback_edge(int stateno, int ruleno, int gotono) { - int i, k; - int found; + int i, k, found; shorts *sp; i = lookaheads[stateno]; @@ -479,12 +453,8 @@ add_lookback_edge(int stateno, int ruleno, int gotono) short ** transpose(short **R, int n) { - short **new_R; - short **temp_R; - short *nedges; - short *sp; - int i; - int k; + short **new_R, **temp_R, *nedges, *sp; + int i, k; nedges = NEW2(n, short); @@ -535,9 +505,9 @@ void compute_lookaheads(void) { int i, n; - unsigned *fp1, *fp2, *fp3; + unsigned int *fp1, *fp2, *fp3; shorts *sp, *next; - unsigned *rowp; + unsigned int *rowp; rowp = LA; n = lookaheads[nstates]; @@ -586,15 +556,10 @@ digraph(short **relation) void traverse(int i) { - unsigned *fp1; - unsigned *fp2; - unsigned *fp3; - int j; + unsigned int *base, *fp1, *fp2, *fp3; + int j, height; short *rp; - int height; - unsigned *base; - VERTICES[++top] = i; INDEX[i] = height = top; diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c index 8ac14d0a8f7..c22da118e3d 100644 --- a/usr.bin/yacc/lr0.c +++ b/usr.bin/yacc/lr0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lr0.c,v 1.17 2014/03/13 00:59:34 tedu Exp $ */ +/* $OpenBSD: lr0.c,v 1.18 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: lr0.c,v 1.4 1996/03/19 03:21:35 jtc Exp $ */ /* @@ -79,12 +79,8 @@ static short *kernel_items; void allocate_itemsets(void) { - short *itemp; - short *item_end; - int symbol; - int i; - int count; - int max; + short *itemp, *item_end; + int i, count, max, symbol; short *symbol_count; count = 0; @@ -127,9 +123,7 @@ allocate_storage(void) void append_states(void) { - int i; - int j; - int symbol; + int i, j, symbol; #ifdef TRACE fprintf(stderr, "Entering append_states()\n"); @@ -193,13 +187,9 @@ generate_states(void) short get_state(int symbol) { - int key; - short *isp1; - short *isp2; - short *iend; + int n, found, key; + short *isp1, *isp2, *iend; core *sp; - int found; - int n; #ifdef TRACE fprintf(stderr, "Entering get_state(%d)\n", symbol); @@ -273,10 +263,8 @@ initialize_states(void) void new_itemsets(void) { - int i; - int shiftcount; - short *isp; - short *ksp; + int i, shiftcount; + short *isp, *ksp; int symbol; memset(kernel_end, 0, nsyms * sizeof(short *)); @@ -307,9 +295,7 @@ new_state(int symbol) { int n; core *p; - short *isp1; - short *isp2; - short *iend; + short *isp1, *isp2, *iend; #ifdef TRACE fprintf(stderr, "Entering new_state(%d)\n", symbol); @@ -344,9 +330,7 @@ void save_shifts(void) { shifts *p; - short *sp1; - short *sp2; - short *send; + short *sp1, *sp2, *send; p = allocate(sizeof(shifts) + (nshifts - 1) * sizeof(short)); @@ -373,11 +357,8 @@ save_shifts(void) void save_reductions(void) { - short *isp; - short *rp1; - short *rp2; - int item; - int count; + short *isp, *rp1, *rp2; + int item, count; reductions *p; short *rend; @@ -415,8 +396,7 @@ save_reductions(void) void set_derives(void) { - int i, k; - int lhs; + int i, k, lhs; short *rules; derives = NEW2(nsyms, short *); diff --git a/usr.bin/yacc/output.c b/usr.bin/yacc/output.c index 2fe47472581..890f605400d 100644 --- a/usr.bin/yacc/output.c +++ b/usr.bin/yacc/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.22 2014/03/07 19:44:07 tedu Exp $ */ +/* $OpenBSD: output.c,v 1.23 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: output.c,v 1.4 1996/03/19 03:21:41 jtc Exp $ */ /* @@ -547,13 +547,7 @@ pack_table(void) int matching_vector(int vector) { - int i; - int j; - int k; - int t; - int w; - int match; - int prev; + int i, j, k, t, w, match, prev; i = order[vector]; if (i >= 2*nstates) @@ -587,11 +581,8 @@ int pack_vector(int vector) { int i, j, k, l; - int t; - int loc; - int ok; - short *from; - short *to; + int t, loc, ok; + short *from, *to; int newmax; i = order[vector]; @@ -619,11 +610,11 @@ pack_vector(int vector) do { newmax += 200; } while (newmax <= loc); - table = realloc(table, newmax*sizeof(short)); - if (table == 0) + table = realloc(table, newmax * sizeof(short)); + if (table == NULL) no_space(); - check = realloc(check, newmax*sizeof(short)); - if (check == 0) + check = realloc(check, newmax * sizeof(short)); + if (check == NULL) no_space(); for (l = maxtable; l < newmax; ++l) { table[l] = 0; @@ -724,8 +715,7 @@ output_base(void) void output_table(void) { - int i; - int j; + int i, j; ++outline; fprintf(code_file, "#define YYTABLESIZE %d\n", high); @@ -754,8 +744,7 @@ output_table(void) void output_check(void) { - int i; - int j; + int i, j; fprintf(output_file, "const short %scheck[] =\n" "\t{%40d,", symbol_prefix, check[0]); @@ -908,8 +897,9 @@ output_debug(void) ++outline; fprintf(code_file, "#define YYMAXTOKEN %d\n", max); - symnam = (char **) calloc(max+1, sizeof(char *)); - if (symnam == 0) no_space(); + symnam = calloc(max+1, sizeof(char *)); + if (symnam == NULL) + no_space(); for (i = ntokens - 1; i >= 2; --i) symnam[symbol_value[i]] = symbol_name[i]; diff --git a/usr.bin/yacc/reader.c b/usr.bin/yacc/reader.c index 34581c5f273..bf40f465287 100644 --- a/usr.bin/yacc/reader.c +++ b/usr.bin/yacc/reader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reader.c,v 1.27 2014/03/13 00:33:55 tedu Exp $ */ +/* $OpenBSD: reader.c,v 1.28 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: reader.c,v 1.5 1996/03/19 03:21:43 jtc Exp $ */ /* @@ -124,8 +124,7 @@ void get_line(void) { FILE *f = input_file; - int c; - int i; + int c, i; if (saw_eof || (c = getc(f)) == EOF) { if (line) { @@ -155,7 +154,7 @@ get_line(void) if (++i >= linesize) { linesize += LINESIZE; line = realloc(line, linesize); - if (line == 0) + if (line == NULL) no_space(); } c = getc(f); @@ -195,7 +194,6 @@ void skip_comment(void) { char *s; - int st_lineno = lineno; char *st_line = dup_line(); char *st_cptr = st_line + (cptr - line); @@ -489,9 +487,7 @@ next_line: void copy_union(void) { - int c; - int quote; - int depth; + int c, quote, depth; int u_lineno = lineno; char *u_line = dup_line(); char *u_cptr = u_line + (cptr - line - 6); @@ -636,9 +632,7 @@ next_line: bucket * get_literal(void) { - int c, quote; - int i; - int n; + int c, quote, i, n; char *s; bucket *bp; int s_lineno = lineno; @@ -826,8 +820,7 @@ get_name(void) int get_number(void) { - int c; - int n; + int c, n; n = 0; for (c = (unsigned char) *cptr; isdigit(c); c = (unsigned char) *++cptr) @@ -840,8 +833,7 @@ get_number(void) char * get_tag(void) { - int c; - int i; + int c, i; char *s; int t_lineno = lineno; char *t_line = dup_line(); @@ -1133,6 +1125,7 @@ void expand_items(void) { int olditems = maxitems; + maxitems += 300; pitem = realloc(pitem, maxitems * sizeof(bucket *)); if (pitem == NULL) @@ -1306,10 +1299,7 @@ add_symbol(void) void copy_action(void) { - int c; - int i, n; - int depth; - int quote; + int c, i, n, depth, quote; char *tag; FILE *f = action_file; int a_lineno = lineno; diff --git a/usr.bin/yacc/warshall.c b/usr.bin/yacc/warshall.c index 56e13ccd725..55611edc843 100644 --- a/usr.bin/yacc/warshall.c +++ b/usr.bin/yacc/warshall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: warshall.c,v 1.10 2014/03/13 00:56:39 tedu Exp $ */ +/* $OpenBSD: warshall.c,v 1.11 2014/03/13 01:18:22 tedu Exp $ */ /* $NetBSD: warshall.c,v 1.4 1996/03/19 03:21:51 jtc Exp $ */ /* @@ -41,14 +41,8 @@ void transitive_closure(unsigned int *R, int n) { int rowsize; - unsigned i; - unsigned *rowj; - unsigned *rp; - unsigned *rend; - unsigned *ccol; - unsigned *relend; - unsigned *cword; - unsigned *rowi; + unsigned int i; + unsigned int *rowj, *rp, *rend, *ccol, *relend, *cword, *rowi; rowsize = WORDSIZE(n); relend = R + n * rowsize; @@ -85,9 +79,8 @@ void reflexive_transitive_closure(unsigned int *R, int n) { int rowsize; - unsigned i; - unsigned *rp; - unsigned *relend; + unsigned int i; + unsigned int *rp, *relend; transitive_closure(R, n); |