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 | 673ded681abb4b844581ea74ecc74d45e92b4480 (patch) | |
| tree | 8d923701542a7c5e85332f1c2d62bfd2f619229b /parse.y | |
| parent | 1f287c6788621d661052b06489385e3361f8762c (diff) | |
| download | ruby-673ded681abb4b844581ea74ecc74d45e92b4480.tar.gz ruby-673ded681abb4b844581ea74ecc74d45e92b4480.tar.xz ruby-673ded681abb4b844581ea74ecc74d45e92b4480.zip | |
refactoring for options
git-svn-id: http://svn.ruby-lang.org/repos/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()) { |
