toplev.h (skip_leading_substring): New macro.
authorGabriel Dos Reis <gdr@codesourcery.com>
Sun, 28 May 2000 21:22:12 +0000 (21:22 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Sun, 28 May 2000 21:22:12 +0000 (21:22 +0000)
2000-05-28  Gabriel Dos Reis  <gdr@codesourcery.com>

        * toplev.h (skip_leading_substring): New macro.
        * toplev.c (decode_f_option): Use skip_leading_substring instead
        of strncmp.
        (decode_W_option): Likewise.

cp/

2000-05-28  Gabriel Dos Reis  <gdr@codesourcery.com>

        * decl2.c (lang_decode_option): Use skip_leading_substring instead
        of plain strncmp.

From-SVN: r34240

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/toplev.c
gcc/toplev.h

index cd8bd1dd0fd95a0291a7d4950fe739af487b2c84..cb0589e71572bcf1d543ce75effd1a5fa745229f 100644 (file)
@@ -1,3 +1,10 @@
+2000-05-28  Gabriel Dos Reis  <gdr@codesourcery.com>
+
+       * toplev.h (skip_leading_substring): New macro.
+       * toplev.c (decode_f_option): Use skip_leading_substring instead
+       of strncmp.
+       (decode_W_option): Likewise.
+
 2000-05-28  Nick Clifton  <nickc@cygnus.com>
 
        * tm.texi (CONDITIONAL_REGISTER_USAGE): Document that it can
index fafb15cc7d74305a5209cb0cfbd410b5f8c01d16..385f9211d9e7618d1f7f36c7ce4ca787dcaca66e 100644 (file)
@@ -1,3 +1,8 @@
+2000-05-28  Gabriel Dos Reis  <gdr@codesourcery.com>
+
+       * decl2.c (lang_decode_option): Use skip_leading_substring instead
+       of plain strncmp.
+
 2000-05-28  Alexandre Oliva  <aoliva@cygnus.com>
 
        * operators.def (<?): Duplicated, should have been...
index 6a90a0a0dbb97b17cd287f2f20edd5a6555a3e27..5ce75ef1ee49095fdb7f642b4fb7c4cb1f45d0e1 100644 (file)
@@ -590,6 +590,7 @@ lang_decode_option (argc, argv)
       /* Some kind of -f option.
         P's value is the option sans `-f'.
         Search for it in the table of options.  */
+      const char *option_value = NULL;
       size_t j;
 
       p += 2;
@@ -639,31 +640,36 @@ lang_decode_option (argc, argv)
          flag_new_abi = 0;
          flag_do_squangling = 0;
        }
-      else if (!strncmp (p, "template-depth-", 15))
+      else if ((option_value
+                = skip_leading_substring (p, "template-depth-")))
        max_tinst_depth
-         = read_integral_parameter (p + 15, p - 2, max_tinst_depth);
-      else if (!strncmp (p, "name-mangling-version-", 22))
+         = read_integral_parameter (option_value, p - 2, max_tinst_depth);
+      else if ((option_value
+                = skip_leading_substring (p, "name-mangling-version-")))
        name_mangling_version 
-         = read_integral_parameter (p + 22, p - 2, name_mangling_version);
-      else if (!strncmp (p, "message-length=", 15))
+         = read_integral_parameter (option_value, p - 2, name_mangling_version);
+      else if ((option_value
+                = skip_leading_substring (p, "message-length=")))
        set_message_length
-         (read_integral_parameter (p + 15, p - 2,
+         (read_integral_parameter (option_value, p - 2,
                                    /* default line-wrap length */ 72));
-      else if (!strncmp (p, "diagnostics-show-location=", 26))
+      else if ((option_value
+                = skip_leading_substring (p, "diagnostics-show-location=")))
         {
-          if (!strncmp (p + 26, "once", 4))
+          if (!strcmp (option_value, "once"))
             set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
-          else if (!strncmp (p + 26, "every-line", 10))
+          else if (!strcmp (option_value, "every-line"))
             set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
           else
             error ("Unrecognized option `%s'", p - 2);
         }
-      else if (!strncmp (p, "dump-translation-unit-", 22))
+      else if ((option_value
+                = skip_leading_substring (p, "dump-translation-unit-")))
        {
          if (p[22] == '\0')
            error ("no file specified with -fdump-translation-unit");
          else
-           flag_dump_translation_unit = p + 22;
+           flag_dump_translation_unit = option_value;
        }
       else 
        {
index 1fc72f1fcb0afc559972d2770e14c78e01dd915b..e8e279e24bae1d41f1f9a7b1cea25828c4a4a76a 100644 (file)
@@ -3923,6 +3923,7 @@ decode_f_option (arg)
      const char * arg;
 {
   int j;
+  const char *option_value = NULL;
 
   /* Search for the option in the table of binary f options.  */
   for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
@@ -3941,44 +3942,47 @@ decode_f_option (arg)
        }
     }
 
-  if (!strncmp (arg, "inline-limit-", 13)
-      || !strncmp (arg, "inline-limit=", 13))
+  if ((option_value = skip_leading_substring (arg, "inline-limit-"))
+      || (option_value = skip_leading_substring (arg, "inline-limit=")))
     inline_max_insns =
-      read_integral_parameter (arg + 13, arg - 2, inline_max_insns);
+      read_integral_parameter (option_value, arg - 2, inline_max_insns);
 #ifdef INSN_SCHEDULING
-  else if (!strncmp (arg, "sched-verbose=", 14))
-    fix_sched_param ("verbose", (const char *)(arg + 14));
+  else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
+    fix_sched_param ("verbose", option_value);
 #endif
-  else if (!strncmp (arg, "fixed-", 6))
-    fix_register ((const char *)(arg + 6), 1, 1);
-  else if (!strncmp (arg, "call-used-", 10))
-    fix_register ((const char *)(arg + 10), 0, 1);
-  else if (!strncmp (arg, "call-saved-", 11))
-    fix_register ((const char *)(arg + 11), 0, 0);
-  else if (!strncmp (arg, "align-loops=", 12))
-    align_loops = read_integral_parameter (arg + 12, arg - 2, align_loops);
-  else if (!strncmp (arg, "align-functions=", 16))
+  else if ((option_value = skip_leading_substring (arg, "fixed-")))
+    fix_register (option_value, 1, 1);
+  else if ((option_value = skip_leading_substring (arg, "call-used-")))
+    fix_register (option_value, 0, 1);
+  else if ((option_value = skip_leading_substring (arg, "call-saved-")))
+    fix_register (option_value, 0, 0);
+  else if ((option_value = skip_leading_substring (arg, "align-loops=")))
+    align_loops = read_integral_parameter (option_value, arg - 2, align_loops);
+  else if ((option_value = skip_leading_substring (arg, "align-functions=")))
     align_functions
-      = read_integral_parameter (arg + 16, arg - 2, align_functions);
-  else if (!strncmp (arg, "align-jumps=", 12))
-    align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
-  else if (!strncmp (arg, "align-labels=", 13))
-    align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
-  else if (!strncmp (arg, "stack-limit-register=", 21))
+      = read_integral_parameter (option_value, arg - 2, align_functions);
+  else if ((option_value = skip_leading_substring (arg, "align-jumps=")))
+    align_jumps = read_integral_parameter (option_value, arg - 2, align_jumps);
+  else if ((option_value = skip_leading_substring (arg, "align-labels=")))
+    align_labels
+      = read_integral_parameter (option_value, arg - 2, align_labels);
+  else if ((option_value
+            = skip_leading_substring (arg, "stack-limit-register=")))
     {
-      int reg = decode_reg_name (arg + 21);
+      int reg = decode_reg_name (option_value);
       if (reg < 0)
-       error ("unrecognized register name `%s'", arg + 21);
+       error ("unrecognized register name `%s'", option_value);
       else
        stack_limit_rtx = gen_rtx_REG (Pmode, reg);
     }
-  else if (!strncmp (arg, "stack-limit-symbol=", 19))
+  else if ((option_value
+            = skip_leading_substring (arg, "stack-limit-symbol=")))
     {
       char *nm;
       if (ggc_p)
-       nm = ggc_alloc_string (arg + 19, strlen (arg + 19));
+       nm = ggc_alloc_string (option_value, strlen (option_value));
       else
-       nm = xstrdup (arg + 19);
+       nm = xstrdup (option_value);
       stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
     }
   else if (!strcmp (arg, "no-stack-limit"))
@@ -4001,6 +4005,7 @@ static int
 decode_W_option (arg)
      const char * arg;
 {
+  const char *option_value = NULL;
   int j;
   
   /* Search for the option in the table of binary W options.  */
@@ -4021,16 +4026,16 @@ decode_W_option (arg)
        }
     }
 
-  if (!strncmp (arg, "id-clash-", 9))
+  if ((option_value = skip_leading_substring (arg, "id-clash-")))
     {
-      id_clash_len = read_integral_parameter (arg + 9, arg - 2, -1);
+      id_clash_len = read_integral_parameter (option_value, arg - 2, -1);
       
       if (id_clash_len != -1)
        warn_id_clash = 1;
     }
-  else if (!strncmp (arg, "larger-than-", 12))
+  else if ((option_value = skip_leading_substring (arg, "larger-than-")))
     {
-      larger_than_size = read_integral_parameter (arg + 12, arg - 2, -1);
+      larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
 
       if (larger_than_size != -1)
        warn_larger_than = 1;
index 9f7ed84e027c08c9deac0e3f61862188d7d41bb4..fdfee432e51aff64aba4439b4c33470e7eb58163 100644 (file)
@@ -26,6 +26,11 @@ union tree_node;
 struct rtx_def;
 #endif
 
+/* If non-NULL, return one past-the-end of the matching SUBPART of
+   the WHOLE string.  */
+#define skip_leading_substring(whole,  part) \
+   (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
+
 extern int read_integral_parameter     PARAMS ((const char *, const char *,
                                                const int));
 extern int count_error                 PARAMS ((int));