From: Paul Eggert Date: Mon, 3 Feb 2003 15:35:57 +0000 (+0000) Subject: Use more-consistent naming conventions for local vars. X-Git-Tag: BISON-2_0~406 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/a737b2163c275761f32589bf7c249016452bb730 Use more-consistent naming conventions for local vars. --- diff --git a/ChangeLog b/ChangeLog index 5e71261c..9aa6638c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,56 @@ +2003-02-03 Paul Eggert + + * src/gram.h (start_symbol): Remove unused decl. + + Use more-consistent naming conventions for local vars. + + * src/derives.c (derives_compute): Change type of local var from + int to rule_number. + * src/gram.c (grammar_rules_partial_print): Likewise. + * src/print.c (print_core): Likewise. + * src/reduce.c (reduce_grammar_tables): Likewise. + + * src/gram.c (grammar_dump): Change name of item_number * + local var from r to rp. + * src/nullable.c (nullable_compute): Likewise. + + * src/gram.h (ISTOKEN, ISVAR): Use i, not s, for int var. + + * src/gram.h (symbol_number_as_item_number): Use sym, not s, + for symbol or symbol_number var. + * src/reader.c (grammar_start_symbol_set): Likewise. + * src/reader.h (grammar_start_symbol_set, grammar_symbol_append): + Likewise. + * src/state.c (transitions_to): Likewise. + * src/state.h: Likewise. + * src/tables.c (symbol_number_to_vector_number): Likewise. + + * src/muscle_tab.h (MUSCLE_OBSTACK_SGROW): Use p, not s, for + char * var. + + * src/parse-gram.y (lloc_default): Use loc, not r, for YYLTYPE + var. + + * src/scan-gram.l (no_cr_read): Use bytes_read, not s, for size + var. + + * src/system.h (xstrndup, strchr, strspn, strnlen, memchr, memrchr): + Use str, not s, for char * var. Use ch, not c, for character var. + Use size for size var. + + * src/uniqstr.c (uniqstr_new, uniqstr_assert): Use str, not s, for + char * var. + (uniqstr_print, uniqst_print_processor): Use ustr, not s, for + uniqstr var. + * src/uniqstr.h: Likewise. + + * src/vcg.c (get_color_str, get_textmode_str, get_shape_str, + get_layoutalgorithm_str, get_decision_str, get_orientation_str, + get_node_alignment_str, get_arrow_mode_str, get_crossing_type_str, + get_view_str, get_linestyle_str, get_arrowstyle_str): Rename + param to have same name as that of enum, so that we don't use + "s" to stand for a non-state. + 2003-02-02 Akim Demaille * src/scan-skel.l: Scan more than one inert character per yylex diff --git a/src/derives.c b/src/derives.c index da881ecc..7e20fe5a 100644 --- a/src/derives.c +++ b/src/derives.c @@ -1,6 +1,6 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -65,7 +65,7 @@ void derives_compute (void) { symbol_number i; - int r; + rule_number r; rule **q; /* DSET[NTERM - NTOKENS] -- A linked list of the numbers of the rules diff --git a/src/gram.c b/src/gram.c index cf5a946d..86f75ec7 100644 --- a/src/gram.c +++ b/src/gram.c @@ -1,6 +1,7 @@ /* Allocate input grammar variables for Bison. - Copyright (C) 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2001, 2002, 2003 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -203,7 +204,7 @@ void grammar_rules_partial_print (FILE *out, const char *title, rule_filter filter) { - int r; + rule_number r; bool first = true; symbol *previous_lhs = NULL; @@ -270,11 +271,11 @@ grammar_dump (FILE *out, const char *title) for (i = 0; i < nrules + nuseless_productions; i++) { rule *rule_i = &rules[i]; - item_number *r = NULL; + item_number *rp = NULL; unsigned int rhs_itemno = rule_i->rhs - ritem; unsigned int rhs_count = 0; /* Find the last RHS index in ritems. */ - for (r = rule_i->rhs; *r >= 0; ++r) + for (rp = rule_i->rhs; *rp >= 0; ++rp) ++rhs_count; fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->", i, @@ -285,9 +286,9 @@ grammar_dump (FILE *out, const char *title) rhs_itemno + rhs_count - 1, rule_i->lhs->number); /* Dumped the RHS. */ - for (r = rule_i->rhs; *r >= 0; r++) - fprintf (out, " %3d", *r); - fprintf (out, " [%d]\n", item_number_as_rule_number (*r)); + for (rp = rule_i->rhs; *rp >= 0; rp++) + fprintf (out, " %3d", *rp); + fprintf (out, " [%d]\n", item_number_as_rule_number (*rp)); } } fprintf (out, "\n\n"); diff --git a/src/muscle_tab.h b/src/muscle_tab.h index 35038c78..4dd9b0be 100644 --- a/src/muscle_tab.h +++ b/src/muscle_tab.h @@ -1,5 +1,5 @@ /* Muscle table manager for Bison, - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -53,15 +53,15 @@ extern struct obstack muscle_obstack; #define MUSCLE_OBSTACK_SGROW(Obstack, Value) \ { \ - char const *s; \ - for (s = Value; *s; s++) \ - switch (*s) \ + char const *p; \ + for (p = Value; *p; p++) \ + switch (*p) \ { \ case '$': obstack_sgrow (Obstack, "$]["); break; \ case '@': obstack_sgrow (Obstack, "@@" ); break; \ case '[': obstack_sgrow (Obstack, "@{" ); break; \ case ']': obstack_sgrow (Obstack, "@}" ); break; \ - default: obstack_1grow (Obstack, *s); break; \ + default: obstack_1grow (Obstack, *p); break; \ } \ } diff --git a/src/nullable.c b/src/nullable.c index beedf2b1..cf6cfd68 100644 --- a/src/nullable.c +++ b/src/nullable.c @@ -1,6 +1,7 @@ /* Calculate which nonterminals can expand into the null string for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -81,21 +82,21 @@ nullable_compute (void) if (rules_ruleno->rhs[0] >= 0) { /* This rule has a non empty RHS. */ - item_number *r = NULL; + item_number *rp = NULL; int any_tokens = 0; - for (r = rules_ruleno->rhs; *r >= 0; ++r) - if (ISTOKEN (*r)) + for (rp = rules_ruleno->rhs; *rp >= 0; ++rp) + if (ISTOKEN (*rp)) any_tokens = 1; /* This rule has only nonterminals: schedule it for the second pass. */ if (!any_tokens) - for (r = rules_ruleno->rhs; *r >= 0; ++r) + for (rp = rules_ruleno->rhs; *rp >= 0; ++rp) { rcount[ruleno]++; - p->next = rsets[*r - ntokens]; + p->next = rsets[*rp - ntokens]; p->value = rules_ruleno; - rsets[*r - ntokens] = p; + rsets[*rp - ntokens] = p; p++; } } diff --git a/src/parse-gram.y b/src/parse-gram.y index c5d8024f..668d9db3 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -1,5 +1,6 @@ /* Bison Grammar Parser -*- C -*- - Copyright (C) 2002 Free Software Foundation, Inc. + + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -413,8 +414,8 @@ static YYLTYPE lloc_default (YYLTYPE const *rhs, int n) { int i; - YYLTYPE r; - r.start = r.end = rhs[n].end; + YYLTYPE loc; + loc.start = loc.end = rhs[n].end; /* Ignore empty nonterminals the start of the the right-hand side. Do not bother to ignore them at the end of the right-hand side, @@ -422,11 +423,11 @@ lloc_default (YYLTYPE const *rhs, int n) for (i = 1; i <= n; i++) if (! equal_boundaries (rhs[i].start, rhs[i].end)) { - r.start = rhs[i].start; + loc.start = rhs[i].start; break; } - return r; + return loc; } diff --git a/src/print.c b/src/print.c index ce9529b7..dcf7df3a 100644 --- a/src/print.c +++ b/src/print.c @@ -1,5 +1,6 @@ /* Print information on generated parser, for bison, - Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 + + Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -92,7 +93,7 @@ print_core (FILE *out, state *s) { item_number *sp; item_number *sp1; - int r; + rule_number r; sp1 = sp = ritem + sitems[i]; diff --git a/src/reader.c b/src/reader.c index 8b0e0359..3f8cab8b 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1,6 +1,6 @@ /* Input parser for Bison - Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002 + Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -47,14 +47,14 @@ int typed = 0; `-----------------------*/ void -grammar_start_symbol_set (symbol *s, location loc) +grammar_start_symbol_set (symbol *sym, location loc) { if (start_flag) complain_at (loc, _("multiple %s declarations"), "%start"); else { start_flag = 1; - startsymbol = s; + startsymbol = sym; startsymbol_location = loc; } } diff --git a/src/reader.h b/src/reader.h index 28f6404f..56c4f5c3 100644 --- a/src/reader.h +++ b/src/reader.h @@ -1,6 +1,6 @@ /* Input parser for Bison - Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -53,10 +53,10 @@ char const *token_name (int); /* From reader.c. */ -void grammar_start_symbol_set (symbol *s, location loc); +void grammar_start_symbol_set (symbol *sym, location loc); void prologue_augment (const char *prologue, location loc); void epilogue_augment (const char *epilogue, location loc); -void grammar_symbol_append (symbol *s, location loc); +void grammar_symbol_append (symbol *sym, location loc); void grammar_rule_begin (symbol *lhs, location loc); void grammar_rule_end (location loc); void grammar_midrule_action (void); diff --git a/src/reduce.c b/src/reduce.c index 94df548e..b9b6a3dd 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -1,6 +1,7 @@ /* Grammar reduction for Bison. - Copyright (C) 1988, 1989, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -267,7 +268,7 @@ reduce_grammar_tables (void) /* Adjust NRITEMS. */ { - int r; + rule_number r; int length; for (r = nrules; r < nrules + nuseless_productions; ++r) { diff --git a/src/scan-gram.l b/src/scan-gram.l index a2c61fd6..5f7ac60e 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -1,6 +1,6 @@ /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -682,14 +682,14 @@ adjust_location (location *loc, char const *token, size_t size) static size_t no_cr_read (FILE *fp, char *buf, size_t size) { - size_t s = fread (buf, 1, size, fp); - if (s) + size_t bytes_read = fread (buf, 1, size, fp); + if (bytes_read) { - char *w = memchr (buf, '\r', s); + char *w = memchr (buf, '\r', bytes_read); if (w) { char const *r = ++w; - char const *lim = buf + s; + char const *lim = buf + bytes_read; for (;;) { @@ -718,7 +718,7 @@ no_cr_read (FILE *fp, char *buf, size_t size) } } - return s; + return bytes_read; } diff --git a/src/state.c b/src/state.c index 3afe46cf..730427f3 100644 --- a/src/state.c +++ b/src/state.c @@ -1,6 +1,6 @@ /* Type definitions for nondeterministic finite state machine for Bison. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -49,17 +49,17 @@ transitions_new (int num, state **the_states) } -/*-------------------------------------------------------------------. -| Return the state such these TRANSITIONS contain a shift/goto to it | -| on S. Abort if none found. | -`-------------------------------------------------------------------*/ +/*-------------------------------------------------------. +| Return the state such that SHIFTS contain a shift/goto | +| to it on SYM. Abort if none found. | +`-------------------------------------------------------*/ state * -transitions_to (transitions *shifts, symbol_number s) +transitions_to (transitions *shifts, symbol_number sym) { int j; for (j = 0; j < shifts->num; j++) - if (TRANSITION_SYMBOL (shifts, j) == s) + if (TRANSITION_SYMBOL (shifts, j) == sym) return shifts->states[j]; abort (); } diff --git a/src/state.h b/src/state.h index 1e49bb38..b7591289 100644 --- a/src/state.h +++ b/src/state.h @@ -1,6 +1,6 @@ /* Type definitions for nondeterministic finite state machine for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -160,9 +160,9 @@ typedef struct if (!TRANSITION_IS_DISABLED (Transitions, Iter)) -/* Return the state such SHIFTS contain a shift/goto to it on S. +/* Return the state such SHIFTS contain a shift/goto to it on SYM. Abort if none found. */ -struct state *transitions_to (transitions *shifts, symbol_number s); +struct state *transitions_to (transitions *shifts, symbol_number sym); /*-------. diff --git a/src/system.h b/src/system.h index 068b308a..0b11dbe6 100644 --- a/src/system.h +++ b/src/system.h @@ -86,7 +86,7 @@ typedef size_t uintptr_t; #define REALLOC(P, N) ((P) = xrealloc (P, (N) * sizeof *(P))) /* From xstrndup.c. */ -char *xstrndup (const char *s, size_t n); +char *xstrndup (const char *str, size_t size); /*---------------------. @@ -98,23 +98,23 @@ char *stpcpy (char *dest, const char *src); #endif #if defined HAVE_DECL_STRCHR && !HAVE_DECL_STRCHR -char *strchr (const char *s, int c); +char *strchr (const char *str, int ch); #endif #if defined HAVE_DECL_STRSPN && !HAVE_DECL_STRSPN -size_t strspn (const char *s, const char *accept); +size_t strspn (const char *str, const char *accept); #endif #if defined HAVE_DECL_STRNLEN && !HAVE_DECL_STRNLEN -size_t strnlen (const char *s, size_t maxlen); +size_t strnlen (const char *str, size_t maxlen); #endif #if defined HAVE_DECL_MEMCHR && !HAVE_DECL_MEMCHR -void *memchr (const void *s, int c, size_t n); +void *memchr (const void *str, int ch, size_t size); #endif #if defined HAVE_DECL_MEMRCHR && !HAVE_DECL_MEMRCHR -void *memrchr (const void *s, int c, size_t n); +void *memrchr (const void *str, int ch, size_t size); #endif diff --git a/src/tables.c b/src/tables.c index 1e65e365..0b43ce1c 100644 --- a/src/tables.c +++ b/src/tables.c @@ -1,6 +1,6 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002 + Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -51,9 +51,9 @@ state_number_to_vector_number (state_number s) } static inline vector_number -symbol_number_to_vector_number (symbol_number s) +symbol_number_to_vector_number (symbol_number sym) { - return state_number_as_int (nstates) + s - ntokens; + return state_number_as_int (nstates) + sym - ntokens; } int nvectors; diff --git a/src/uniqstr.c b/src/uniqstr.c index c93157d7..fb316cb3 100644 --- a/src/uniqstr.c +++ b/src/uniqstr.c @@ -1,6 +1,6 @@ /* Keep a unique copy of strings. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -41,13 +41,13 @@ static struct hash_table *uniqstrs_table = NULL; `-------------------------------------*/ uniqstr -uniqstr_new (char const *s) +uniqstr_new (char const *str) { - uniqstr res = hash_lookup (uniqstrs_table, s); + uniqstr res = hash_lookup (uniqstrs_table, str); if (!res) { /* First insertion in the hash. */ - res = xstrdup (s); + res = xstrdup (str); hash_insert (uniqstrs_table, res); } return res; @@ -59,11 +59,11 @@ uniqstr_new (char const *s) `------------------------------*/ void -uniqstr_assert (char const *s) +uniqstr_assert (char const *str) { - if (!hash_lookup (uniqstrs_table, s)) + if (!hash_lookup (uniqstrs_table, str)) { - error (0, 0, "not a uniqstr: %s", quotearg (s)); + error (0, 0, "not a uniqstr: %s", quotearg (str)); abort (); } } @@ -74,16 +74,16 @@ uniqstr_assert (char const *s) `--------------------*/ static inline bool -uniqstr_print (uniqstr s) +uniqstr_print (uniqstr ustr) { - fprintf (stderr, "%s\n", s); + fprintf (stderr, "%s\n", ustr); return true; } static bool -uniqstr_print_processor (void *s, void *null ATTRIBUTE_UNUSED) +uniqstr_print_processor (void *ustr, void *null ATTRIBUTE_UNUSED) { - return uniqstr_print (s); + return uniqstr_print (ustr); } diff --git a/src/uniqstr.h b/src/uniqstr.h index 90961d9c..8f941141 100644 --- a/src/uniqstr.h +++ b/src/uniqstr.h @@ -1,5 +1,6 @@ /* Keeping a unique copy of strings. - Copyright (C) 2002 Free Software Foundation, Inc. + + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -27,11 +28,11 @@ typedef char const *uniqstr; -/* Return the uniqstr for S. */ -uniqstr uniqstr_new (char const *s); +/* Return the uniqstr for STR. */ +uniqstr uniqstr_new (char const *str); -/* Two uniqstr have the same value iff they are the same. */ -#define UNIQSTR_EQ(S1, S2) ((S1) == (S2)) +/* Two uniqstr values have the same value iff they are the same. */ +#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2)) /*--------------------------------------. | Initializing, destroying, debugging. | @@ -40,8 +41,8 @@ uniqstr uniqstr_new (char const *s); /* Create the string table. */ void uniqstrs_new (void); -/* Die if S is not a uniqstr. */ -void uniqstr_assert (char const *s); +/* Die if STR is not a uniqstr. */ +void uniqstr_assert (char const *str); /* Free all the memory allocated for symbols. */ void uniqstrs_free (void); diff --git a/src/vcg.c b/src/vcg.c index 88755b28..c68233de 100644 --- a/src/vcg.c +++ b/src/vcg.c @@ -1,6 +1,6 @@ /* VCG description handler for Bison. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -210,9 +210,9 @@ new_edge (edge *e) `----------------------------------------------*/ static const char * -get_color_str (enum color c) +get_color_str (enum color color) { - switch (c) + switch (color) { case white: return "white"; case blue: return "blue"; @@ -251,9 +251,9 @@ get_color_str (enum color c) } static const char * -get_textmode_str (enum textmode t) +get_textmode_str (enum textmode textmode) { - switch (t) + switch (textmode) { case centered: return "center"; case left_justify: return "left_justify"; @@ -263,9 +263,9 @@ get_textmode_str (enum textmode t) } static const char * -get_shape_str (enum shape s) +get_shape_str (enum shape shape) { - switch (s) + switch (shape) { case box: return "box"; case rhomb: return "rhomb"; @@ -276,9 +276,9 @@ get_shape_str (enum shape s) } static const char * -get_layoutalgorithm_str (enum layoutalgorithm l) +get_layoutalgorithm_str (enum layoutalgorithm layoutalgorithm) { - switch (l) + switch (layoutalgorithm) { case normal: return "normal"; case maxdepth: return "maxdepth"; @@ -299,9 +299,9 @@ get_layoutalgorithm_str (enum layoutalgorithm l) } static const char * -get_decision_str (enum decision d) +get_decision_str (enum decision decision) { - switch (d) + switch (decision) { case no: return "no"; case yes: return "yes"; @@ -310,9 +310,9 @@ get_decision_str (enum decision d) } static const char * -get_orientation_str (enum orientation o) +get_orientation_str (enum orientation orientation) { - switch (o) + switch (orientation) { case top_to_bottom: return "top_to_bottom"; case bottom_to_top: return "bottom_to_top"; @@ -323,9 +323,9 @@ get_orientation_str (enum orientation o) } static const char * -get_node_alignment_str (enum alignment a) +get_node_alignment_str (enum alignment alignment) { - switch (a) + switch (alignment) { case center: return "center"; case top: return "top"; @@ -335,9 +335,9 @@ get_node_alignment_str (enum alignment a) } static const char * -get_arrow_mode_str (enum arrow_mode a) +get_arrow_mode_str (enum arrow_mode arrow_mode) { - switch (a) + switch (arrow_mode) { case fixed: return "fixed"; case free_a: return "free"; @@ -346,9 +346,9 @@ get_arrow_mode_str (enum arrow_mode a) } static const char * -get_crossing_type_str (enum crossing_type c) +get_crossing_type_str (enum crossing_type crossing_type) { - switch (c) + switch (crossing_type) { case bary: return "bary"; case median: return "median"; @@ -359,9 +359,9 @@ get_crossing_type_str (enum crossing_type c) } static const char * -get_view_str (enum view v) +get_view_str (enum view view) { - switch (v) + switch (view) { case normal_view: return "normal_view"; case cfish: return "cfish"; @@ -373,9 +373,9 @@ get_view_str (enum view v) } static const char * -get_linestyle_str (enum linestyle l) +get_linestyle_str (enum linestyle linestyle) { - switch (l) + switch (linestyle) { case continuous: return "continuous"; case dashed: return "dashed"; @@ -386,9 +386,9 @@ get_linestyle_str (enum linestyle l) } static const char * -get_arrowstyle_str (enum arrowstyle a) +get_arrowstyle_str (enum arrowstyle arrowstyle) { - switch (a) + switch (arrowstyle) { case solid: return "solid"; case line: return "line";