bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/5] fix C90 compliance


From: Akim Demaille
Subject: [PATCH 3/5] fix C90 compliance
Date: Wed, 12 Dec 2012 14:15:28 +0100

* data/glr.c, src/graphviz.h, src/ielr.c, src/scan-gram.l,
* src/system.h, tests/actions.at, tests/glr-regression.at: Do not
use // comments.
Do not introduce variables after statements.
Provide "main" with a return value.
---
 NEWS                    |  2 ++
 data/glr.c              |  4 +++-
 src/graphviz.h          | 52 +++++++++++++++++++++++++++++--------------------
 src/ielr.c              |  8 ++++----
 src/scan-gram.l         |  2 +-
 src/system.h            |  2 +-
 tests/actions.at        |  5 +++--
 tests/glr-regression.at |  6 ++++--
 8 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/NEWS b/NEWS
index d16ac50..1c33b04 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ GNU Bison NEWS
 
   Warnings about uninitialized yylloc in yyparse have been fixed.
 
+  Restored C90 compliance (yet no report was ever made).
+
 ** Diagnostics are improved
 
 *** Changes in the format of error messages
diff --git a/data/glr.c b/data/glr.c
index e55a2df..02a76c2 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -287,7 +287,7 @@ b4_percent_code_get[]dnl
 # include <setjmp.h>
 # define YYJMP_BUF jmp_buf
 # define YYSETJMP(Env) setjmp (Env)
-// Pacify clang.
+/* Pacify clang.  */
 # define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
 #endif
 
@@ -2013,6 +2013,7 @@ yyreportSyntaxError (yyGLRStack* 
yystackp]b4_user_formals[)
 #if ! YYERROR_VERBOSE
   yyerror (]b4_lyyerror_args[YY_("syntax error"));
 #else
+  {
   yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
   size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
   size_t yysize = yysize0;
@@ -2133,6 +2134,7 @@ yyreportSyntaxError (yyGLRStack* 
yystackp]b4_user_formals[)
       yyerror (]b4_lyyerror_args[YY_("syntax error"));
       yyMemoryExhausted (yystackp);
     }
+  }
 #endif /* YYERROR_VERBOSE */
   yynerrs += 1;
 }
diff --git a/src/graphviz.h b/src/graphviz.h
index 371b15c..239cdd2 100644
--- a/src/graphviz.h
+++ b/src/graphviz.h
@@ -24,38 +24,48 @@
 
 #include "state.h"
 
-/// Begin a Dot graph.
-/// \param fout   output stream.
+/** Begin a Dot graph.
+ *
+ * \param fout   output stream.
+ */
 void start_graph (FILE *fout);
 
-/// Output a Dot node.
-/// \param id     identifier of the node
-/// \param label  human readable label of the node (no Dot escaping needed).
-/// \param fout   output stream.
+/** Output a Dot node.
+ *
+ * \param id     identifier of the node
+ * \param label  human readable label of the node (no Dot escaping needed).
+ * \param fout   output stream.
+ */
 void output_node (int id, char const *label, FILE *fout);
 
-/// Output a Dot edge.
-/// \param source       id of the source node
-/// \param destination  id of the target node
-/// \param label        human readable label of the edge
-///                     (no Dot escaping needed).  Can be 0.
-/// \param style        Dot style of the edge (e.g., "dotted" or "solid").
-/// \param fout         output stream.
+/** Output a Dot edge.
+ * \param source       id of the source node
+ * \param destination  id of the target node
+ * \param label        human readable label of the edge
+ *                     (no Dot escaping needed).  Can be 0.
+ * \param style        Dot style of the edge (e.g., "dotted" or "solid").
+ * \param fout         output stream.
+ */
 void output_edge (int source, int destination, char const *label,
                   char const *style, FILE *fout);
 
-/// Output a reduction.
-/// \param s            current state
-/// \param reds         the set of reductions
-/// \param fout         output stream.
+/** Output a reduction.
+ * \param s            current state
+ * \param reds         the set of reductions
+ * \param fout         output stream.
+ */
 void output_red (state const *s, reductions const *reds, FILE *fout);
 
-/// End a Dot graph.
-/// \param fout  output stream.
+/** End a Dot graph.
+ *
+ * \param fout  output stream.
+ */
 void finish_graph (FILE *fout);
 
-/// Escape a lookahead token.
-/// \param name         the token.
+/** Escape a lookahead token.
+ *
+ * \param name         the token.
+ */
 char const *escape (char const *name);
 
 #endif /* ! GRAPHVIZ_H_ */
diff --git a/src/ielr.c b/src/ielr.c
index cde2baa..e6aa6f5 100644
--- a/src/ielr.c
+++ b/src/ielr.c
@@ -758,8 +758,8 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv 
always_follows,
                     if (!bitset_empty_p (lookaheads[i]))
                       break;
                   }
-                // bitset_equal_p uses the size of the first argument, so
-                // lookaheads[i] must be the second argument.
+                /* bitset_equal_p uses the size of the first argument,
+                   so lookaheads[i] must be the second argument.  */
                 else if (!bitset_equal_p ((*this_isocorep)->lookaheads[i],
                                           lookaheads[i]))
                   break;
@@ -1187,8 +1187,8 @@ ielr (void)
   free (to_state);
   if (lr_type == LR_TYPE__CANONICAL_LR)
     {
-      // Reduction lookaheads are computed in ielr_split_states above but are
-      // timed as part of phase 4.
+      /* Reduction lookaheads are computed in ielr_split_states above
+         but are timed as part of phase 4. */
       set_goto_map ();
     }
   else
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 5e78cb9..9083dce 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -883,7 +883,7 @@ unexpected_end (boundary start, char const *msgid, char 
const *token_end)
   loc.start = start;
   loc.end = scanner_cursor;
   token_end = quote (token_end);
-  // Instead of '\'', display "'".
+  /* Instead of '\'', display "'".  */
   if (!strcmp (token_end, "'\\''"))
     token_end = "\"'\"";
   complain_at (loc, _(msgid), token_end);
diff --git a/src/system.h b/src/system.h
index 3a82e7f..35ff876 100644
--- a/src/system.h
+++ b/src/system.h
@@ -51,7 +51,7 @@
 typedef size_t uintptr_t;
 # endif
 
-// Version mismatch.
+/* Version mismatch. */
 # define EX_MISMATCH 63
 
 /*---------.
diff --git a/tests/actions.at b/tests/actions.at
index 17d9193..97c08c2 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -90,7 +90,7 @@ AT_DATA_GRAMMAR([[input.y]],
 %code
 {
 # include <stdio.h>
-# include <stdlib.h> // getenv
+# include <stdlib.h> /* getenv */
 ]AT_YYERROR_DECLARE[
 ]AT_YYLEX_DECLARE[
 }
@@ -195,7 +195,7 @@ AT_DATA_GRAMMAR([[input.y]],
 %code
 {
 # include <stdio.h>
-# include <stdlib.h> // getenv
+# include <stdlib.h> /* getenv */
 ]AT_YYERROR_DECLARE[
 ]AT_YYLEX_DECLARE[
 }
@@ -223,6 +223,7 @@ main (void)
 
   TEST(7, 2, 0, 2);
   TEST(8, 0, 8, 0);
+  return 0;
 }
 ]])
 
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index 088ad86..e08904b 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -195,10 +195,11 @@ yylex (void)
 int
 main (int argc, char **argv)
 {
+  int res;
   input = stdin;
   if (argc == 2 && !(input = fopen (argv[1], "r")))
     return 3;
-  int res = yyparse ();
+  res = yyparse ();
   if (argc == 2 && fclose (input))
     return 4;
   return res;
@@ -327,10 +328,11 @@ int yylex (void)
 int
 main(int argc, char* argv[])
 {
+  int res;
   input = stdin;
   if (argc == 2 && !(input = fopen (argv[1], "r")))
     return 3;
-  int res = yyparse ();
+  res = yyparse ();
   if (argc == 2 && fclose (input))
     return 4;
   return res;
-- 
1.8.0.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]