ruby-changes:4101
From: ko1@a...
Date: Sun, 24 Feb 2008 06:49:40 +0900 (JST)
Subject: [ruby-changes:4101] nobu - Ruby:r15591 (trunk): * ruby.c (enable_option, disable_option): allow all for all known
nobu 2008-02-24 06:49:15 +0900 (Sun, 24 Feb 2008)
New Revision: 15591
Modified files:
trunk/ChangeLog
trunk/ruby.c
Log:
* ruby.c (enable_option, disable_option): allow all for all known
features.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=15591&r2=15590&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15591&r2=15590&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15590)
+++ ChangeLog (revision 15591)
@@ -1,9 +1,12 @@
-Sun Feb 24 06:13:02 2008 Nobuyoshi Nakada <nobu@r...>
+Sun Feb 24 06:49:12 2008 Nobuyoshi Nakada <nobu@r...>
* debug.c (ruby_set_debug_option): separated ruby_each_words().
* util.c (ruby_each_words): extracted from ruby_set_debug_option().
+ * ruby.c (enable_option, disable_option): allow all for all known
+ features.
+
* ruby.c (proc_options): generalized enable/disable options.
* ruby.c (ruby_init_gems): take enabled flag. [ruby-core:14840]
Index: ruby.c
===================================================================
--- ruby.c (revision 15590)
+++ ruby.c (revision 15591)
@@ -79,7 +79,7 @@
int usage;
int version;
int copyright;
- int disable;
+ unsigned int disable;
int verbose;
int yydebug;
char *script;
@@ -139,7 +139,7 @@
"-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 @@
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);
}
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/