e$B$J$+$@$G$9!#e(B
At Tue, 4 Dec 2007 20:17:55 +0900,
Nobuyoshi N. wrote in [ruby-dev:32453]:
At Tue, 4 Dec 2007 17:52:27 +0900,
Tanaka A. wrote in [ruby-dev:32452]:
“e$B$”$$$&$($*e(B".force_encoding(“euc-jp”).split(//) e$B$He(B (EUC-JP
e$B$Ge(B) e$B9T$&$He(B negative string size e$B$H$J$j$^$9!#e(B
% ./ruby -ve ‘p “e$B$”$$$&$($*e(B".force_encoding(“euc-jp”).split(//)’
ruby 1.9.0 (2007-12-04 patchlevel 0) [i686-linux]
-e:1:in split': negative string size (or size too big) (ArgumentError) from -e:1:in
’
e$B$3$l0J30$K$b!“e(B
p “e$B$”$$$&$($*e(B”.partition(“e$B$&e(B”) #=> [“e$B$”$$e(B",
“e$B$&e(B”, “e$B$*e(B”]
-- encoding: shift_jis --
p “e$BI=<(e(B”.partition("\") #=> [“e$BI=e(B”, “\”, “”]
e$B$H$+$$$m$$$m$*$+$7$J$3$H$K$J$C$F$k$N$G!“e(Bbyte/char
offsete$B$N;H$$$oe(B
e$B$1$K4X$7$F$O$b$C$H8+D>$9I,MW$,$”$j$=$&$G$9!#e(B
rb_reg_search()e$B$,J8;zC10L$N0LCV$rJV$9$N$K!“e(Brb_str_split_m()e$B$G$Oe(B
bytee$B0LCV$H$7$F;H$C$F$$$k$?$a$G$9$M!#e(BBEG()e$B$de(BEND()e$B$be(Bbytee$B0LCV$N$^$^e(B
e$B$J$N$G!”%a%=%C%I$NLa$jCM$H$7$FJV$9$H$-$KJ8;z0LCV$KJQ49$9$k$h$&$Ke(B
e$B$7$?$[$&$,$$$$$N$G$O$J$$$G$7$g$&$+!#e(B
e$B$H$j$"$($:$3$C$A$@$1!#e(B
Index: re.c
— re.c (resuult 14122)
+++ re.c (working copy)
@@ -865,5 +865,5 @@ rb_reg_search(VALUE re, VALUE str, int p
OBJ_INFECT(match, str);
- return rb_str_sublen(RMATCH(match)->str, result);
@@ -1836,10 +1836,10 @@ reg_operand(VALUE s, int check)
}
-static VALUE
+static long
rb_reg_match_pos(VALUE re, VALUE str, long pos)
{
if (NIL_P(str)) {
rb_backref_set(Qnil);
- return -1;
}
str = reg_operand(str, Qtrue);
@@ -1848,5 +1848,5 @@ rb_reg_match_pos(VALUE re, VALUE str, lo
pos += RSTRING_LEN(str);
if (pos < 0) {
- return pos;
}
}
@@ -1854,8 +1854,5 @@ rb_reg_match_pos(VALUE re, VALUE str, lo
}
pos = rb_reg_search(re, str, pos, 0);
- if (pos < 0) {
- return Qnil;
- }
- return LONG2FIX(pos);
@@ -1872,5 +1869,7 @@ VALUE
rb_reg_match(VALUE re, VALUE str)
{
- return rb_reg_match_pos(re, str, 0);
- long pos = rb_reg_match_pos(re, str, 0);
- if (pos < 0) return Qnil;
- return LONG2FIX(pos);
}
@@ -1937,4 +1936,5 @@ rb_reg_match2(VALUE re)
return Qnil;
}
- start = rb_str_sublen(line, start);
return LONG2FIX(start);
}
@@ -1982,6 +1982,6 @@ rb_reg_match_m(int argc, VALUE *argv, VA
}
- result = rb_reg_match_pos(re, str, pos);
- if (NIL_P(result)) {
- pos = rb_reg_match_pos(re, str, pos);
- if (pos < 0) {
rb_backref_set(Qnil);
return Qnil;