diff options
author | Gabriel Dos Reis <gdr@codesourcery.com> | 2000-05-28 21:22:12 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2000-05-28 21:22:12 +0000 |
commit | 6f5ef761dff56f6fad015e13d16d1ec12283a25c (patch) | |
tree | 8ea1a5fdfdba85a8c2a066a09b4a28546171a2b0 /gcc | |
parent | 055177dc83b011c37b3b78c23d4f86d471bf21c7 (diff) | |
download | gcc-6f5ef761dff56f6fad015e13d16d1ec12283a25c.zip gcc-6f5ef761dff56f6fad015e13d16d1ec12283a25c.tar.gz gcc-6f5ef761dff56f6fad015e13d16d1ec12283a25c.tar.bz2 |
toplev.h (skip_leading_substring): New macro.
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 28 | ||||
-rw-r--r-- | gcc/toplev.c | 63 | ||||
-rw-r--r-- | gcc/toplev.h | 5 |
5 files changed, 68 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cd8bd1d..cb0589e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fafb15c..385f921 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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... diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6a90a0a..5ce75ef 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 { diff --git a/gcc/toplev.c b/gcc/toplev.c index 1fc72f1..e8e279e 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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; diff --git a/gcc/toplev.h b/gcc/toplev.h index 9f7ed84..fdfee43 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -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)); |