ruby-changes:39870
From: nobu <ko1@a...>
Date: Sun, 27 Sep 2015 14:47:45 +0900 (JST)
Subject: [ruby-changes:39870] nobu:r51951 (trunk): ruby.c: abbreviated option name
nobu 2015-09-27 14:47:24 +0900 (Sun, 27 Sep 2015) New Revision: 51951 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51951 Log: ruby.c: abbreviated option name * ruby.c (name_match_p): allow option argument names to be abbreviated for each words. Modified files: trunk/ruby.c Index: ruby.c =================================================================== --- ruby.c (revision 51950) +++ ruby.c (revision 51951) @@ -693,8 +693,26 @@ moreswitches(const char *s, struct cmdli https://github.com/ruby/ruby/blob/trunk/ruby.c#L693 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))) { \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/