Skip to content

Commit

Permalink
[fix #72] fix the Regexp#options
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed May 16, 2012
1 parent b08afdf commit c19da64
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions re.c
Expand Up @@ -26,6 +26,7 @@ static VALUE rb_cRegexpMatcher;
typedef struct rb_regexp {
struct RBasic basic;
URegularExpression *pattern;
int option;
bool fixed_encoding;
} rb_regexp_t;

Expand Down Expand Up @@ -53,6 +54,7 @@ regexp_alloc(VALUE klass, SEL sel)
NEWOBJ(re, struct rb_regexp);
OBJSETUP(re, klass, T_REGEXP);
re->pattern = NULL;
re->option = 0;
re->fixed_encoding = false;
return re;
}
Expand Down Expand Up @@ -258,6 +260,7 @@ printf("\n");
static bool
init_from_string(rb_regexp_t *regexp, VALUE str, int option, VALUE *excp)
{
regexp->option = option;
option |= REGEXP_OPT_DEFAULT;

RB_STR_GET_UCHARS(str, chars, chars_len);
Expand Down Expand Up @@ -313,6 +316,7 @@ init_from_regexp(rb_regexp_t *regexp, rb_regexp_t *from)
rb_raise(rb_eRegexpError, "can't clone given regexp: %s",
u_errorName(status));
}
regexp->option = from->option;
}

static VALUE
Expand Down Expand Up @@ -1229,8 +1233,7 @@ int
rb_reg_options(VALUE re)
{
rb_reg_check(re);
UErrorCode status = U_ZERO_ERROR;
return uregex_flags(RREGEXP(re)->pattern, &status);
return RREGEXP(re)->option;
}

static VALUE
Expand Down

0 comments on commit c19da64

Please sign in to comment.