summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-23 21:49:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-23 21:49:15 +0000
commitb676e2671eaf82b7d1c71988d3f951183eef612b (patch)
tree4ed9a183810e6f5ba3bc95be7aff173b76ece839 /ruby.c
parent552badf29f3aa5e9b76d02716f93f37b94ba8353 (diff)
* ruby.c (enable_option, disable_option): allow all for all known
features. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/ruby.c b/ruby.c
index 5975b308d4..c4f8daa0bf 100644
--- a/ruby.c
+++ b/ruby.c
@@ -79,7 +79,7 @@ struct cmdline_options {
int usage;
int version;
int copyright;
- int disable;
+ unsigned int disable;
int verbose;
int yydebug;
char *script;
@@ -139,7 +139,7 @@ usage(const char *name)
"-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)",
"-x[directory] strip off text before #!ruby line and perhaps cd to directory",
"--enable/--disable-FEATURE --enable/--disable=FEATURE enable/disable FEATUREs",
- " gems: gem libraries, rubyopt: RUBYOPT env",
+ " gems: gem libraries, rubyopt: RUBYOPT env, or all",
"--copyright print the copyright",
"--version print the version",
NULL
@@ -543,31 +543,44 @@ moreswitches(const char *s, struct cmdline_options *opt)
return (char *)s;
}
-#define UNSET_WHEN(bit) \
- if (len < sizeof(#bit) && strncmp(str, #bit, len) == 0) { \
- *(unsigned int *)arg &= ~DISABLE_BIT(bit); \
- return; \
+#define NAME_MATCH_P(name, str, len) \
+ ((len) < sizeof(name) && strncmp((str), name, (len)) == 0)
+
+#define UNSET_WHEN(name, bit, str, len) \
+ if (NAME_MATCH_P(name, str, len)) { \
+ *(unsigned int *)arg &= ~(bit); \
+ return; \
}
-#define SET_WHEN(bit) \
- if (len < sizeof(#bit) && strncmp(str, #bit, len) == 0) { \
- *(unsigned int *)arg |= DISABLE_BIT(bit); \
- return; \
+#define SET_WHEN(name, bit, str, len) \
+ if (NAME_MATCH_P(name, str, len)) { \
+ *(unsigned int *)arg |= (bit); \
+ return; \
}
static void
enable_option(const char *str, int len, void *arg)
{
- UNSET_WHEN(gems);
- UNSET_WHEN(rubyopt);
+#define UNSET_WHEN_DISABLE(bit) UNSET_WHEN(#bit, DISABLE_BIT(bit), str, len)
+ UNSET_WHEN_DISABLE(gems);
+ UNSET_WHEN_DISABLE(rubyopt);
+ if (NAME_MATCH_P("all", str, len)) {
+ *(unsigned int *)arg = 0U;
+ return;
+ }
rb_warn("unknown argument for --enable: `%.*s'", len, str);
}
static void
disable_option(const char *str, int len, void *arg)
{
- SET_WHEN(gems);
- SET_WHEN(rubyopt);
+#define SET_WHEN_DISABLE(bit) SET_WHEN(#bit, DISABLE_BIT(bit), str, len)
+ SET_WHEN_DISABLE(gems);
+ SET_WHEN_DISABLE(rubyopt);
+ if (NAME_MATCH_P("all", str, len)) {
+ *(unsigned int *)arg = ~0U;
+ return;
+ }
rb_warn("unknown argument for --disable: `%.*s'", len, str);
}