diff options
author | kosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-03-26 13:04:13 +0000 |
---|---|---|
committer | kosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-03-26 13:04:13 +0000 |
commit | 6e154b9743fd753bbc314e73f588e1b4c32f73f8 (patch) | |
tree | 8d923701542a7c5e85332f1c2d62bfd2f619229b /parse.y | |
parent | 2025346077b7a514d7fed11cac52c125e9a188c1 (diff) | |
download | ruby-6e154b9743fd753bbc314e73f588e1b4c32f73f8.tar.gz |
refactoring for options
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 43 |
1 files changed, 13 insertions, 30 deletions
@@ -4986,41 +4986,24 @@ parser_tokadd_escape(struct parser_params *parser, int term) static int parser_regx_options(struct parser_params *parser) { - char kcode = 0; + extern int rb_char_to_option_kcode(int c, int *option, int *kcode); + + int kcode = 0; int options = 0; - int c; + int c, opt, kc, found; newtok(); while (c = nextc(), ISALPHA(c)) { - switch (c) { - case 'i': - options |= ONIG_OPTION_IGNORECASE; - break; - case 'x': - options |= ONIG_OPTION_EXTEND; - break; - case 'm': - options |= ONIG_OPTION_MULTILINE; - break; - case 'o': - options |= RE_OPTION_ONCE; - break; - case 'n': - kcode = 16; - break; - case 'e': - kcode = 32; - break; - case 's': - kcode = 48; - break; - case 'u': - kcode = 64; - break; - default: + if (c == 'o') { + options |= RE_OPTION_ONCE; + } + else if (rb_char_to_option_kcode(c, &opt, &kc)) { + options |= opt; + if (kc != 0) kcode = kc; + } + else { tokadd(c); - break; - } + } } pushback(c); if (toklen()) { |