summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-27 05:47:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-27 05:47:24 +0000
commit6b52b88d46e5cda0def68665f185a3ac4335076c (patch)
tree37fba19b46eda1fa396e4e5bb625d4f992969638 /ruby.c
parent7f13f878cf0cdb5df4602f5bd15f255dc549f476 (diff)
ruby.c: abbreviated option name
* ruby.c (name_match_p): allow option argument names to be abbreviated for each words. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 70c6bdf..2f9355f 100644
--- a/ruby.c
+++ b/ruby.c
@@ -693,8 +693,26 @@ moreswitches(const char *s, struct cmdline_options *opt, int envopt)
rb_str_resize(argstr, 0);
}
+static int
+name_match_p(const char *name, const char *str, size_t len)
+{
+ if (len == 0) return 0;
+ do {
+ while (TOLOWER(*str) == *name) {
+ if (!--len || !*++str) return 1;
+ ++name;
+ }
+ if (*str != '-' && *str != '_') return 0;
+ while (ISALNUM(*name)) name++;
+ if (*name != '-' && *name != '_') return 0;
+ ++name;
+ ++str;
+ } while (len > 0);
+ return !*name;
+}
+
#define NAME_MATCH_P(name, str, len) \
- ((len) < (int)sizeof(name) && strncmp((str), (name), (len)) == 0)
+ ((len) < (int)sizeof(name) && name_match_p((name), (str), (len)))
#define UNSET_WHEN(name, bit, str, len) \
if (NAME_MATCH_P((name), (str), (len))) { \