summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-25 04:38:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-25 04:38:42 +0000
commit43601a1d171333cccea5d656e0f18b77cb1ff987 (patch)
tree380e68c3277b995f38e425e54c31424cfc6224d3 /re.c
parent651f324a278e133a1cb809ec8ba9b0ff9e69d1d9 (diff)
* re.c (rb_reg_options_m): use rb_reg_options() to mask internal
flags. * re.c (rb_reg_initialize_m): allow nil as third argument and ignore, and mask code flags if the argument is given. [ruby-dev:20885] * re.c (rb_reg_options): get common flags directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/re.c b/re.c
index 16b4c5e295..e81b093a3e 100644
--- a/re.c
+++ b/re.c
@@ -502,8 +502,8 @@ static VALUE
rb_reg_options_m(re)
VALUE re;
{
- rb_reg_check(re);
- return INT2NUM(RREGEXP(re)->ptr->options);
+ int options = rb_reg_options(re);
+ return INT2NUM(options);
}
static VALUE
@@ -1303,9 +1303,10 @@ rb_reg_initialize_m(argc, argv, self)
if (FIXNUM_P(argv[1])) flags = FIX2INT(argv[1]);
else if (RTEST(argv[1])) flags = RE_OPTION_IGNORECASE;
}
- if (argc == 3) {
+ if (argc == 3 && !NIL_P(argv[2])) {
char *kcode = StringValuePtr(argv[2]);
+ flags &= ~0x70;
switch (kcode[0]) {
case 'n': case 'N':
flags |= 16;
@@ -1471,15 +1472,11 @@ int
rb_reg_options(re)
VALUE re;
{
- int options = 0;
+ int options;
rb_reg_check(re);
- if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
- options |= RE_OPTION_IGNORECASE;
- if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
- options |= RE_OPTION_MULTILINE;
- if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
- options |= RE_OPTION_EXTENDED;
+ options = RREGEXP(re)->ptr->options &
+ (RE_OPTION_IGNORECASE|RE_OPTION_MULTILINE|RE_OPTION_EXTENDED);
if (FL_TEST(re, KCODE_FIXED)) {
options |= rb_reg_get_kcode(re);
}