From 6e154b9743fd753bbc314e73f588e1b4c32f73f8 Mon Sep 17 00:00:00 2001 From: kosako Date: Sun, 26 Mar 2006 13:04:13 +0000 Subject: refactoring for options git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index aa7f1329aa..600a023790 100644 --- a/parse.y +++ b/parse.y @@ -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()) { -- cgit v1.2.3