summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorkosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-03-26 13:04:13 +0000
committerkosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-03-26 13:04:13 +0000
commit6e154b9743fd753bbc314e73f588e1b4c32f73f8 (patch)
tree8d923701542a7c5e85332f1c2d62bfd2f619229b /parse.y
parent2025346077b7a514d7fed11cac52c125e9a188c1 (diff)
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.y43
1 files changed, 13 insertions, 30 deletions
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()) {