]> git.saurik.com Git - bison.git/commitdiff
maint: use STREQ/STRNEQ.
authorAkim Demaille <demaille@gostai.com>
Thu, 23 Feb 2012 17:51:51 +0000 (18:51 +0100)
committerAkim Demaille <demaille@gostai.com>
Thu, 23 Feb 2012 18:13:45 +0000 (19:13 +0100)
* doc/bison.texinfo: Space change.
* src/system.h (STREQ, STRNEQ): New.
* src/files.c, src/ielr.c, src/lalr.c, src/muscle-tab.c,
* src/output.c, src/print.c, src/print_graph.c,
* src/reader.c, src/scan-skel.l, src/tables.c,
* src/uniqstr.c:
Use them.
* src/scan-gram.l: Do not use streq.h, use system.h's STREQ.
* cfg.mk: The documentation is an exception.

15 files changed:
cfg.mk
doc/bison.texinfo
src/files.c
src/ielr.c
src/lalr.c
src/muscle-tab.c
src/output.c
src/print.c
src/print_graph.c
src/reader.c
src/scan-gram.l
src/scan-skel.l
src/system.h
src/tables.c
src/uniqstr.c

diff --git a/cfg.mk b/cfg.mk
index 5f8958b03bb8d6bb05b9e8038980f2124f42a4ea..ce7553932cc977519263e4f293ec96e1118eeacc 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -35,9 +35,7 @@ url_dir_list = \
 # Tests not to run as part of "make distcheck".
 local-checks-to-skip =                 \
   sc_immutable_NEWS                    \
-  sc_prohibit_always_true_header_tests \
-  sc_prohibit_atoi_atof                        \
-  sc_prohibit_strcmp
+  sc_prohibit_atoi_atof
 
 # The local directory containing the checked-out copy of gnulib used in
 # this release.  Used solely to get a date for the "announcement" target.
@@ -61,6 +59,7 @@ $(call exclude,                                                               \
   prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$     \
   prohibit_always-defined_macros+=?|^tests/regression.at$$             \
   prohibit_empty_lines_at_EOF=^src/parse-gram.h$$                      \
+  prohibit_strcmp=^doc/bison\.texinfo$$                                        \
   require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$           \
   space_tab=^tests/(input|c\+\+)\.at$$                                 \
   unmarked_diagnostics=^djgpp/                                         \
index 79dd3311f630b05dc27462c667dd537d9509aa54..d24d0c664ff37106a2c182b3a8f13da6c9d9f275 100644 (file)
@@ -2569,7 +2569,7 @@ getsym (char const *sym_name)
   symrec *ptr;
   for (ptr = sym_table; ptr != (symrec *) 0;
        ptr = (symrec *)ptr->next)
-    if (strcmp (ptr->name,sym_name) == 0)
+    if (strcmp (ptr->name, sym_name) == 0)
       return ptr;
   return 0;
 @}
index 208634cd2ddbafd76099d57f723481b51b691aac..ceb0489a61e41cd4c5341c2243e6b98aa52530cc 100644 (file)
@@ -142,7 +142,7 @@ xfclose (FILE *ptr)
 static void
 compute_exts_from_gf (const char *ext)
 {
-  if (strcmp (ext, ".y") == 0)
+  if (STREQ (ext, ".y"))
     {
       src_extension = xstrdup (language->src_extension);
       header_extension = xstrdup (language->header_extension);
@@ -347,7 +347,7 @@ void
 output_file_name_check (char **file_name)
 {
   bool conflict = false;
-  if (0 == strcmp (*file_name, grammar_file))
+  if (STREQ (*file_name, grammar_file))
     {
       complain (_("refusing to overwrite the input file %s"),
                 quote (*file_name));
@@ -357,7 +357,7 @@ output_file_name_check (char **file_name)
     {
       int i;
       for (i = 0; i < file_names_count; i++)
-        if (0 == strcmp (file_names[i], *file_name))
+        if (STREQ (file_names[i], *file_name))
           {
             warn (_("conflicting outputs to file %s"),
                   quote (*file_name));
index cde2baaf292813ed82c5fc6b7a310666ddfcb423..39e9cb6695c858eeb2ec8cbe6f3a585c8792cf3b 100644 (file)
@@ -1095,11 +1095,11 @@ ielr (void)
   /* Examine user options.  */
   {
     char *type = muscle_percent_define_get ("lr.type");
-    if (0 == strcmp (type, "lalr"))
+    if (STREQ (type, "lalr"))
       lr_type = LR_TYPE__LALR;
-    else if (0 == strcmp (type, "ielr"))
+    else if (STREQ (type, "ielr"))
       lr_type = LR_TYPE__IELR;
-    else if (0 == strcmp (type, "canonical-lr"))
+    else if (STREQ (type, "canonical-lr"))
       lr_type = LR_TYPE__CANONICAL_LR;
     else
       aver (false);
index f86bde1c02b5d893133839a486f6aa1a2a11f07b..1ceda002b454fcddd9993da74c665c3d3f84040f 100644 (file)
@@ -372,8 +372,7 @@ initialize_LA (void)
   {
     char *default_reductions =
       muscle_percent_define_get ("lr.default-reductions");
-    default_reduction_only_for_accept =
-      0 == strcmp (default_reductions, "accepting");
+    default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
     free (default_reductions);
   }
 
index bc1aa1fc183b313c6fb80d48c74394d57aad7565..57050d05d2d443dfbe73fe30dcd9ca103e081026 100644 (file)
@@ -50,7 +50,7 @@ hash_compare_muscles (void const *x, void const *y)
 {
   muscle_entry const *m1 = x;
   muscle_entry const *m2 = y;
-  return strcmp (m1->key, m2->key) == 0;
+  return STREQ (m1->key, m2->key);
 }
 
 static size_t
@@ -407,7 +407,7 @@ muscle_percent_variable_update (char const *variable)
     };
   int i;
   for (i = 0; i < sizeof conversion / sizeof *conversion; ++i)
-    if (!strcmp (conversion[i].obsolete, variable))
+    if (STREQ (conversion[i].obsolete, variable))
       return conversion[i].updated;
   return variable;
 }
@@ -555,9 +555,9 @@ muscle_percent_define_flag_if (char const *variable)
   if (muscle_percent_define_ifdef (variable))
     {
       char *value = muscle_percent_define_get (variable);
-      if (value[0] == '\0' || 0 == strcmp (value, "true"))
+      if (value[0] == '\0' || STREQ (value, "true"))
         result = true;
-      else if (0 == strcmp (value, "false"))
+      else if (STREQ (value, "false"))
         result = false;
       else if (!muscle_find_const (invalid_boolean_name))
         {
@@ -614,7 +614,7 @@ muscle_percent_define_check_values (char const * const *values)
         {
           for (++values; *values; ++values)
             {
-              if (0 == strcmp (value, *values))
+              if (STREQ (value, *values))
                 break;
             }
           if (!*values)
index 64a14c52982b0787c3a9cb385062c83d8d476365..08922bc2046b686b6c2a27d55263fb37bc40fe1f 100644 (file)
@@ -689,7 +689,7 @@ prepare (void)
   bool use_push_for_pull_flag = false;
   if (use_push_for_pull_env != NULL
       && use_push_for_pull_env[0] != '\0'
-      && 0 != strcmp (use_push_for_pull_env, "0"))
+      && STRNEQ (use_push_for_pull_env, "0"))
     use_push_for_pull_flag = true;
 
   /* Flags. */
index 58a9016addb090e30c622f21c4e2368a726d9b21..e3795a945301edb211784b60f2f9e0fe4ca44dee 100644 (file)
@@ -336,8 +336,8 @@ print_reductions (FILE *out, state *s)
       char *default_reductions =
         muscle_percent_define_get ("lr.default-reductions");
       print_reduction (out, width, _("$default"), default_reduction, true);
-      aver (0 == strcmp (default_reductions, "most")
-            || (0 == strcmp (default_reductions, "consistent")
+      aver (STREQ (default_reductions, "most")
+            || (STREQ (default_reductions, "consistent")
                 && default_reduction_only)
             || (reds->num == 1 && reds->rules[0]->number == 0));
       free (default_reductions);
index 8dd8db4342b6b6f95a76d2241ba2dd0d8b9167b5..61d3651297342ef40bdd1d69a5fc5297f2dbe0ae 100644 (file)
@@ -133,7 +133,7 @@ print_actions (state const *s, FILE *fgraph)
            : "dashed");
 
         if (TRANSITION_IS_ERROR (trans, i)
-            && strcmp (symbols[sym]->tag, "error") != 0)
+            && STRNEQ (symbols[sym]->tag, "error"))
           abort ();
         output_edge (s->number, s1->number,
                      TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
index 85f686ef7c71d4c2179683eea784351c0c2bfa1c..2e0aa5ee81449787635c1af365d39f63cb2472da 100644 (file)
@@ -638,7 +638,7 @@ prepare_percent_define_front_end_variables (void)
        default.  */
     muscle_percent_define_default ("lr.type", "lalr");
     lr_type = muscle_percent_define_get ("lr.type");
-    if (0 != strcmp (lr_type, "canonical-lr"))
+    if (STRNEQ (lr_type, "canonical-lr"))
       muscle_percent_define_default ("lr.default-reductions", "most");
     else
       muscle_percent_define_default ("lr.default-reductions", "accepting");
index e2e08f9ab9dbf62253ee67e27d4c59c0d5840c52..fa200d64da107619362f0a4d8df23e2cf86ab4d1 100644 (file)
@@ -39,7 +39,6 @@
 #include <ctype.h>
 #include <mbswidth.h>
 #include <quote.h>
-#include <streq.h>
 
 #include <src/scan-gram.h>
 
@@ -968,7 +967,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end)
   loc.end = scanner_cursor;
   token_end = quote (token_end);
   // Instead of '\'', display "'".
-  if (STREQ (token_end, "'\\''", '\'', '\\', '\'', '\'', 0,0,0,0,0))
+  if (STREQ (token_end, "'\\''"))
     token_end = "\"'\"";
   complain_at (loc, _(msgid), token_end);
 }
index 33c264a16af193dc37acaf2081686244c149d97d..e15294a1e219292be2114417857233c99cb1db8c 100644 (file)
@@ -179,15 +179,15 @@ at_directive_perform (int at_directive_argc,
                       char *at_directive_argv[],
                       char **outnamep, int *out_linenop)
 {
-  if (0 == strcmp (at_directive_argv[0], "@basename"))
+  if (STREQ (at_directive_argv[0], "@basename"))
     {
       if (at_directive_argc > 2)
         fail_for_at_directive_too_many_args (at_directive_argv[0]);
       fputs (last_component (at_directive_argv[1]), yyout);
     }
-  else if (0 == strcmp (at_directive_argv[0], "@warn")
-           || 0 == strcmp (at_directive_argv[0], "@complain")
-           || 0 == strcmp (at_directive_argv[0], "@fatal"))
+  else if (STREQ (at_directive_argv[0], "@warn")
+           || STREQ (at_directive_argv[0], "@complain")
+           || STREQ (at_directive_argv[0], "@fatal"))
     {
       void (*func)(char const *, ...);
       switch (at_directive_argv[0][1])
@@ -223,9 +223,9 @@ at_directive_perform (int at_directive_argc,
             break;
         }
     }
-  else if (0 == strcmp (at_directive_argv[0], "@warn_at")
-           || 0 == strcmp (at_directive_argv[0], "@complain_at")
-           || 0 == strcmp (at_directive_argv[0], "@fatal_at"))
+  else if (STREQ (at_directive_argv[0], "@warn_at")
+           || STREQ (at_directive_argv[0], "@complain_at")
+           || STREQ (at_directive_argv[0], "@fatal_at"))
     {
       void (*func)(location, char const *, ...);
       location loc;
@@ -266,7 +266,7 @@ at_directive_perform (int at_directive_argc,
             break;
         }
     }
-  else if (0 == strcmp (at_directive_argv[0], "@output"))
+  else if (STREQ (at_directive_argv[0], "@output"))
     {
       if (at_directive_argc > 2)
         fail_for_at_directive_too_many_args (at_directive_argv[0]);
index 24151bbadab4c5565831244b7a3fd083a0f2477d..7aa2c9fa1c08a480603a38d88ac86bd6e12f7b92 100644 (file)
@@ -39,6 +39,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#define STREQ(L, R)  (strcmp(L, R) == 0)
+#define STRNEQ(L, R) (!STREQ(L, R))
+
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
index f22ec9aa603073dd58ce9dafa0b6e52c5d9e4114..96354b1a225d136922e7d571f6deae0f33efa6aa 100644 (file)
@@ -309,7 +309,7 @@ action_row (state *s)
   {
     char *default_reductions =
       muscle_percent_define_get ("lr.default-reductions");
-    if (0 != strcmp (default_reductions, "most") && !s->consistent)
+    if (STRNEQ (default_reductions, "most") && !s->consistent)
       nodefault = true;
     free (default_reductions);
   }
index 7b2bb205853be65f9f6c0cf3ac56b2d398134a0b..f2954443e9c9e9a3140fd9766f5905d38d3f050c 100644 (file)
@@ -111,7 +111,7 @@ uniqstr_print_processor (void *ustr, void *null ATTRIBUTE_UNUSED)
 static bool
 hash_compare_uniqstr (void const *m1, void const *m2)
 {
-  return strcmp (m1, m2) == 0;
+  return STREQ (m1, m2);
 }
 
 static size_t