summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-21 09:57:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-21 09:57:31 +0000
commit82bd486e998e8182c1a452a4537f9a64bed07347 (patch)
tree89944c9776af0b0bf24c12c496e5c0d98a686d0c /ruby.c
parentc033efddea5fa5de315df8e560f55106b2b6cded (diff)
ruby.c: --debug=frozen-string-literal option
* ruby.c (need_argument): move frozen-string-literal-debug option from --enable to --debug. [Feature #11725] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/ruby.c b/ruby.c
index ab6d89a280..c6add52bd8 100644
--- a/ruby.c
+++ b/ruby.c
@@ -755,7 +755,6 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable)
SET_FEATURE(did_you_mean);
SET_FEATURE(rubyopt);
SET_FEATURE(frozen_string_literal);
- SET_FEATURE(frozen_string_literal_debug);
if (NAME_MATCH_P("all", str, len)) {
found:
*argp = (*argp & ~mask) | (mask & enable);
@@ -778,6 +777,14 @@ disable_option(const char *str, int len, void *arg)
}
static void
+debug_option(const char *str, int len, void *arg)
+{
+#define SET_WHEN_DEBUG(t, bit) SET_WHEN(#bit, t##_BIT(bit), str, len)
+ SET_WHEN_DEBUG(FEATURE, frozen_string_literal_debug);
+ rb_warn("unknown argument for --debug: `%.*s'", len, str);
+}
+
+static void
dump_option(const char *str, int len, void *arg)
{
#define SET_WHEN_DUMP(bit) SET_WHEN(#bit, DUMP_BIT(bit), str, len)
@@ -1087,22 +1094,25 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
# define check_envopt(name, allow_envopt) \
(((allow_envopt) || !envopt) ? (void)0 : \
rb_raise(rb_eRuntimeError, "invalid switch in RUBYOPT: --" name))
-# define need_argument(name, s, needs_arg) \
- ((*(s) ? !*++(s) : (!argc || !((s) = argv[1]) || (--argc, ++argv, 0))) && (needs_arg) ? \
+# define need_argument(name, s, needs_arg, next_arg) \
+ ((*(s) ? !*++(s) : (next_arg) && (!argc || !((s) = argv[1]) || (--argc, ++argv, 0))) && (needs_arg) ? \
rb_raise(rb_eRuntimeError, "missing argument for --" name) \
: (void)0)
# define is_option_with_arg(name, allow_hyphen, allow_envopt) \
- is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue)
-# define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg) \
+ is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue, Qtrue)
+# define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg, next_arg) \
(strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \
(check_envopt(name, (allow_envopt)), s += n, \
- need_argument(name, s, needs_arg), 1) : 0)
+ need_argument(name, s, needs_arg, next_arg), 1) : 0)
if (strcmp("copyright", s) == 0) {
if (envopt) goto noenvopt_long;
opt->dump |= DUMP_BIT(copyright);
}
- else if (strcmp("debug", s) == 0) {
+ else if (is_option_with_optarg("debug", Qtrue, Qtrue, Qfalse, Qfalse)) {
+ if (s && *s) {
+ ruby_each_words(s, debug_option, &opt->features);
+ }
ruby_debug = Qtrue;
ruby_verbose = Qtrue;
}