summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-01 04:23:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-01 04:23:43 +0000
commite6ab550ac5504c4e5f3b2946749f8381513448ff (patch)
tree454d2b1e5f17c97f13445701b5aa5664bebeb652 /re.c
parentcfe64537f8c34e003b49a5c265600787555ae467 (diff)
regex.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/re.c b/re.c
index 7209a73e42..1eee2cb8d6 100644
--- a/re.c
+++ b/re.c
@@ -89,6 +89,7 @@ str_cicmp(str1, str2)
}
#define REG_IGNORECASE FL_USER0
+#define REG_CASESTATE FL_USER1
#define KCODE_NONE 0
#define KCODE_EUC FL_USER2
@@ -376,9 +377,10 @@ reg_prepare_re(reg)
if (FL_TEST(reg, REG_IGNORECASE)) {
casefold = TRUE;
}
- if ((casefold && !(RREGEXP(reg)->ptr->options & RE_OPTION_IGNORECASE))
- || (!casefold && (RREGEXP(reg)->ptr->options & RE_OPTION_IGNORECASE))) {
+ else if ((casefold && !FL_TEST(reg, REG_CASESTATE)) ||
+ (!casefold && FL_TEST(reg, REG_CASESTATE))) {
RREGEXP(reg)->ptr->fastmap_accurate = 0;
+ RBASIC(reg)->flags ^= REG_CASESTATE;
need_recompile = 1;
}
@@ -387,7 +389,7 @@ reg_prepare_re(reg)
}
else if ((RBASIC(reg)->flags & KCODE_MASK) != reg_kcode) {
need_recompile = 1;
- RBASIC(reg)->flags = RBASIC(reg)->flags & ~KCODE_MASK;
+ RBASIC(reg)->flags &= ~KCODE_MASK;
RBASIC(reg)->flags |= reg_kcode;
}
@@ -647,6 +649,10 @@ reg_new_1(klass, s, len, options)
}
kcode_set_option(re);
+ if (RTEST(ignorecase)) {
+ options |= RE_OPTION_IGNORECASE;
+ FL_SET(re, REG_CASESTATE);
+ }
re->ptr = make_regexp(s, len, options & 0x3);
re->str = ALLOC_N(char, len+1);
memcpy(re->str, s, len);