summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-27 08:08:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-27 08:08:10 +0000
commit7505436d62a39abbfb6b0df46adde3260f96d711 (patch)
treea11542f5bb361cdea1b0ab23749b387e1188d62c /ruby.c
parent2e3fc1f06427c46aff50ba8eebe2f3fcb76dc96b (diff)
* ruby.c (is_option_with_optarg): macro for optional argument option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ruby.c b/ruby.c
index af4cf45a47..6b61162a8a 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1056,13 +1056,16 @@ 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) \
- ((*(s)++ ? !*(s) : (!--argc || !((s) = *++argv))) ? \
+# define need_argument(name, s, needs_arg) \
+ ((*(s)++ ? !*(s) : (!--argc || !((s) = *++argv))) && (needs_arg) ? \
rb_raise(rb_eRuntimeError, "missing argument for --" name) \
: (void)0)
-# define is_option_with_arg(name, allow_hyphen, allow_envopt) \
+# 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) \
(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), 1) : 0)
+ (check_envopt(name, (allow_envopt)), s += n, \
+ need_argument(name, s, needs_arg), 1) : 0)
if (strcmp("copyright", s) == 0) {
if (envopt) goto noenvopt_long;
@@ -1174,6 +1177,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
# undef check_envopt
# undef need_argument
# undef is_option_with_arg
+# undef is_option_with_optarg
}
}