summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-25 09:42:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-25 09:42:47 +0000
commit8b1e7e34403977058d412931e31577df719fd2e4 (patch)
tree7743656749f91b601f3d025ea357e8a8043424d8 /re.c
parent45c61f40b23b14e97428206e1b813eb813526e6f (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/re.c b/re.c
index b192080264..7209a73e42 100644
--- a/re.c
+++ b/re.c
@@ -318,7 +318,7 @@ make_regexp(s, len, flag)
rp->allocated = 16;
rp->fastmap = ALLOC_N(char, 256);
if (flag) {
- rp->translate = casetable;
+ rp->options = flag;
}
err = re_compile_pattern(s, (size_t)len, rp);
kcode_reset_option();
@@ -376,15 +376,8 @@ reg_prepare_re(reg)
if (FL_TEST(reg, REG_IGNORECASE)) {
casefold = TRUE;
}
- if (casefold) {
- if (RREGEXP(reg)->ptr->translate != casetable) {
- RREGEXP(reg)->ptr->translate = casetable;
- RREGEXP(reg)->ptr->fastmap_accurate = 0;
- need_recompile = 1;
- }
- }
- else if (RREGEXP(reg)->ptr->translate) {
- RREGEXP(reg)->ptr->translate = NULL;
+ if ((casefold && !(RREGEXP(reg)->ptr->options & RE_OPTION_IGNORECASE))
+ || (!casefold && (RREGEXP(reg)->ptr->options & RE_OPTION_IGNORECASE))) {
RREGEXP(reg)->ptr->fastmap_accurate = 0;
need_recompile = 1;
}
@@ -619,42 +612,42 @@ Regexp *rp;
VALUE cRegexp;
static VALUE
-reg_new_1(klass, s, len, flag)
+reg_new_1(klass, s, len, options)
VALUE klass;
char *s;
int len;
- int flag; /* CASEFOLD = 0x1 */
- /* CODE_NONE = 0x2 */
- /* CODE_EUC = 0x4 */
- /* CODE_SJIS = 0x6 */
+ int options; /* CASEFOLD = 1 */
+ /* EXTENDED = 2 */
+ /* CODE_NONE = 4 */
+ /* CODE_EUC = 8 */
+ /* CODE_SJIS = 12 */
{
NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP);
-
re->ptr = 0;
re->str = 0;
- if (flag & 0x1) {
+ if (options & 0x1) {
FL_SET(re, REG_IGNORECASE);
}
- switch (flag & ~0x1) {
+ switch (options & ~0x3) {
case 0:
default:
FL_SET(re, reg_kcode);
break;
- case 2:
+ case 4:
kcode_none(re);
break;
- case 4:
+ case 8:
kcode_euc(re);
break;
- case 6:
+ case 12:
kcode_sjis(re);
break;
}
kcode_set_option(re);
- re->ptr = make_regexp(s, len, flag & 0x1);
+ re->ptr = make_regexp(s, len, options & 0x3);
re->str = ALLOC_N(char, len+1);
memcpy(re->str, s, len);
re->str[len] = '\0';
@@ -1024,6 +1017,7 @@ Init_Regexp()
| RE_CONTEXTUAL_INVALID_OPS
| RE_CHAR_CLASSES
| RE_BACKSLASH_ESCAPE_IN_LISTS);
+ re_set_casetable(casetable);
rb_define_virtual_variable("$~", match_getter, match_setter);
rb_define_virtual_variable("$&", last_match_getter, 0);