diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-11 08:24:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-07-11 08:24:54 +0000 |
commit | fefba453856ff9dfe5ecb0b1e04888c6f14b2383 (patch) | |
tree | e4ac3ce8b1d657c893ce2e79d40ca183e625c846 /re.c | |
parent | 8e1d1358b689a13b4706754a2ab3fbcd7ef1d683 (diff) |
* string.c (rb_str_slice_bang): if there's no corresponding
substring, slice! should return nil without exception.
* string.c (rb_str_split_m): accept separator value nil as well.
* class.c (include_class_new): module may be T_ICLASS; retrieve
original module information.
* re.c (rb_reg_expr_str): need to process backslashes properly.
* parse.y (yylex): no here document after a dot.
* parse.y (yylex): should have set lex_state properly after '`'.
* parse.y (yylex): should have set lex_state properly after
tOP_ASGN.
* bignum.c (rb_big2dbl): return canonical HUGE_VAL for infinity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -228,7 +228,14 @@ rb_reg_expr_str(str, s, len) else { p = s; while (p<pend) { - if (*p == '/' && (s == p || p[-1] != '\\')) { + if (*p == '\\') { + rb_str_cat(str, p, 1); + p++; + rb_str_cat(str, p, mbclen(*p)); + p += mbclen(*p); + continue; + } + else if (*p == '/') { char c = '\\'; rb_str_cat(str, &c, 1); rb_str_cat(str, p, 1); @@ -687,19 +694,27 @@ VALUE rb_reg_match_pre(match) VALUE match; { + VALUE str; + if (NIL_P(match)) return Qnil; if (RMATCH(match)->BEG(0) == -1) return Qnil; - return rb_str_new(RSTRING(RMATCH(match)->str)->ptr, RMATCH(match)->BEG(0)); + str = rb_str_new(RSTRING(RMATCH(match)->str)->ptr, RMATCH(match)->BEG(0)); + if (OBJ_TAINTED(match)) OBJ_TAINT(str); + return str; } VALUE rb_reg_match_post(match) VALUE match; { + VALUE str; + if (NIL_P(match)) return Qnil; if (RMATCH(match)->BEG(0) == -1) return Qnil; - return rb_str_new(RSTRING(RMATCH(match)->str)->ptr+RMATCH(match)->END(0), - RSTRING(RMATCH(match)->str)->len-RMATCH(match)->END(0)); + str = rb_str_new(RSTRING(RMATCH(match)->str)->ptr+RMATCH(match)->END(0), + RSTRING(RMATCH(match)->str)->len-RMATCH(match)->END(0)); + if (OBJ_TAINTED(match)) OBJ_TAINT(str); + return str; } VALUE |