summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-05 04:45:32 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-05 04:45:32 +0000
commit3b983407ef254cf1908f844fecb4d8b3a02f9a67 (patch)
tree57a958671253db50c502369ba84a95580c2ea097 /string.c
parent3caea6b6a2e4c2e152bf8799acd21127bb88a607 (diff)
* string.c (rb_str_enumerate_lines): fix invalid byte sequence error
when a separator is passed. The patch is from yoshidam (Yoshida Masato). [Bug #7646] [ruby-dev:46827] * test/ruby/test_string.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/string.c b/string.c
index a3f937d19e..d0c30c6c7b 100644
--- a/string.c
+++ b/string.c
@@ -6199,14 +6199,14 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray)
if (c == newline &&
(rslen <= 1 ||
(pend - p >= rslen && memcmp(RSTRING_PTR(rs), p, rslen) == 0))) {
- p += (rslen ? rslen : n);
- line = rb_str_subseq(str, s - ptr, p - s);
+ const char *pp = p + (rslen ? rslen : n);
+ line = rb_str_subseq(str, s - ptr, pp - s);
if (wantarray)
rb_ary_push(ary, line);
else
rb_yield(line);
str_mod_check(str, ptr, len);
- s = p;
+ s = pp;
}
p += n;
}