ruby.c: feature_option
* ruby.c (feature_option): unify enable_option and disable_option not to repeat feature names twice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
95273072a7
commit
c1da4ef8d1
41
ruby.c
41
ruby.c
@ -745,35 +745,36 @@ name_match_p(const char *name, const char *str, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enable_option(const char *str, int len, void *arg)
|
feature_option(const char *str, int len, void *arg, const unsigned int enable)
|
||||||
{
|
{
|
||||||
#define SET_WHEN_ENABLE(bit) SET_WHEN(#bit, FEATURE_BIT(bit), str, len)
|
unsigned int *argp = arg;
|
||||||
SET_WHEN_ENABLE(gems);
|
unsigned int mask = ~0U;
|
||||||
SET_WHEN_ENABLE(did_you_mean);
|
#define SET_FEATURE(bit) \
|
||||||
SET_WHEN_ENABLE(rubyopt);
|
if (NAME_MATCH_P(#bit, str, len)) {mask = FEATURE_BIT(bit); goto found;}
|
||||||
SET_WHEN_ENABLE(frozen_string_literal);
|
SET_FEATURE(gems);
|
||||||
SET_WHEN_ENABLE(frozen_string_literal_debug);
|
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)) {
|
if (NAME_MATCH_P("all", str, len)) {
|
||||||
*(unsigned int *)arg = ~0U;
|
found:
|
||||||
|
*argp = (*argp & ~mask) | (mask & enable);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rb_warn("unknown argument for --enable: `%.*s'", len, str);
|
rb_warn("unknown argument for --%s: `%.*s'",
|
||||||
|
enable ? "enable" : "disable", len, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enable_option(const char *str, int len, void *arg)
|
||||||
|
{
|
||||||
|
feature_option(str, len, arg, ~0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disable_option(const char *str, int len, void *arg)
|
disable_option(const char *str, int len, void *arg)
|
||||||
{
|
{
|
||||||
#define UNSET_WHEN_DISABLE(bit) UNSET_WHEN(#bit, FEATURE_BIT(bit), str, len)
|
feature_option(str, len, arg, 0U);
|
||||||
UNSET_WHEN_DISABLE(gems);
|
|
||||||
UNSET_WHEN_DISABLE(did_you_mean);
|
|
||||||
UNSET_WHEN_DISABLE(rubyopt);
|
|
||||||
UNSET_WHEN_DISABLE(frozen_string_literal);
|
|
||||||
UNSET_WHEN_DISABLE(frozen_string_literal_debug);
|
|
||||||
if (NAME_MATCH_P("all", str, len)) {
|
|
||||||
*(unsigned int *)arg = 0U;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rb_warn("unknown argument for --disable: `%.*s'", len, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user