[PATCH 1/8] style: more uses of const

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
* src/print.c, src/state.h, src/state.c: here.
---
 src/print.c | 16 ++++++++--------
 src/state.c |  8 ++++----
 src/state.h |  8 ++++----
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/print.c b/src/print.c
index 91b44cb3..4d679e82 100644
--- a/src/print.c
+++ b/src/print.c
@@ -60,9 +60,9 @@ max_length (size_t *width, const char *str)
 `--------------------------------*/
 
 static void
-print_core (FILE *out, state *s)
+print_core (FILE *out, const state *s)
 {
-  item_index *sitems = s->items;
+  const item_index *sitems = s->items;
   size_t snritems = s->nitems;
   /* Output all the items of a state, not only its kernel.  */
   if (report_flag & report_itemsets)
@@ -100,7 +100,7 @@ print_core (FILE *out, state *s)
 `------------------------------------------------------------*/
 
 static void
-print_transitions (state *s, FILE *out, bool display_transitions_p)
+print_transitions (const state *s, FILE *out, bool display_transitions_p)
 {
   transitions *trans = s->transitions;
   size_t width = 0;
@@ -128,7 +128,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
       {
         symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
         const char *tag = sym->tag;
-        state *s1 = trans->states[i];
+        const state *s1 = trans->states[i];
 
         fprintf (out, "    %s", tag);
         for (int j = width - mbswidth (tag, 0); j > 0; --j)
@@ -146,7 +146,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
 `--------------------------------------------------------*/
 
 static void
-print_errs (FILE *out, state *s)
+print_errs (FILE *out, const state *s)
 {
   errs *errp = s->errs;
   size_t width = 0;
@@ -208,7 +208,7 @@ print_reduction (FILE *out, size_t width,
 `-------------------------------------------*/
 
 static void
-print_reductions (FILE *out, state *s)
+print_reductions (FILE *out, const state *s)
 {
   reductions *reds = s->reductions;
   if (reds->num == 0)
@@ -324,7 +324,7 @@ print_reductions (FILE *out, state *s)
 `--------------------------------------------------------------*/
 
 static void
-print_actions (FILE *out, state *s)
+print_actions (FILE *out, const state *s)
 {
   /* Print shifts.  */
   print_transitions (s, out, true);
@@ -340,7 +340,7 @@ print_actions (FILE *out, state *s)
 `----------------------------------*/
 
 static void
-print_state (FILE *out, state *s)
+print_state (FILE *out, const state *s)
 {
   fputs ("\n\n", out);
   fprintf (out, _("State %d"), s->number);
diff --git a/src/state.c b/src/state.c
index 8f17a00c..bc45460d 100644
--- a/src/state.c
+++ b/src/state.c
@@ -231,7 +231,7 @@ state_reductions_set (state *s, int num, rule **reds)
 
 
 int
-state_reduction_find (state *s, rule const *r)
+state_reduction_find (state const *s, rule const *r)
 {
   reductions *reds = s->reductions;
   for (int i = 0; i < reds->num; ++i)
@@ -260,7 +260,7 @@ state_errs_set (state *s, int num, symbol **tokens)
 `--------------------------------------------------*/
 
 void
-state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out)
+state_rule_lookahead_tokens_print (state const *s, rule const *r, FILE *out)
 {
   /* Find the reduction we are handling.  */
   reductions *reds = s->reductions;
@@ -283,7 +283,7 @@ state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out)
 }
 
 void
-state_rule_lookahead_tokens_print_xml (state *s, rule const *r,
+state_rule_lookahead_tokens_print_xml (state const *s, rule const *r,
                                        FILE *out, int level)
 {
   /* Find the reduction we are handling.  */
@@ -395,7 +395,7 @@ state_hash_insert (state *s)
 `------------------------------------------------------------------*/
 
 state *
-state_hash_lookup (size_t nitems, item_index *core)
+state_hash_lookup (size_t nitems, const item_index *core)
 {
   size_t items_size = nitems * sizeof *core;
   state *probe = xmalloc (offsetof (state, items) + items_size);
diff --git a/src/state.h b/src/state.h
index 4f0cfd10..a274e611 100644
--- a/src/state.h
+++ b/src/state.h
@@ -247,15 +247,15 @@ void state_reductions_set (state *s, int num, rule **reds);
 
 /* The index of the reduction of state S that corresponds to rule R.
    Aborts if there is no reduction of R in S.  */
-int state_reduction_find (state *s, rule const *r);
+int state_reduction_find (state const *s, rule const *r);
 
 /* Set the errs of STATE.  */
 void state_errs_set (state *s, int num, symbol **errors);
 
 /* Print on OUT all the lookahead tokens such that this STATE wants to
    reduce R.  */
-void state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out);
-void state_rule_lookahead_tokens_print_xml (state *s, rule const *r,
+void state_rule_lookahead_tokens_print (state const *s, rule const *r, FILE *out);
+void state_rule_lookahead_tokens_print_xml (state const *s, rule const *r,
                                             FILE *out, int level);
 
 /* Create/destroy the states hash table.  */
@@ -264,7 +264,7 @@ void state_hash_free (void);
 
 /* Find the state associated to the CORE, and return it.  If it does
    not exist yet, return NULL.  */
-state *state_hash_lookup (size_t core_size, item_index *core);
+state *state_hash_lookup (size_t core_size, const item_index *core);
 
 /* Insert STATE in the state hash table.  */
 void state_hash_insert (state *s);
-- 
2.27.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.