summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/string.c b/string.c
index 30d57b5df4..6492a2a7fc 100644
--- a/string.c
+++ b/string.c
@@ -8012,7 +8012,12 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
if (subptr != pend) {
if (chomp) {
- pend = chomp_newline(subptr, pend, enc);
+ if (rsnewline) {
+ pend = chomp_newline(subptr, pend, enc);
+ }
+ else if (memcmp(pend - rslen, rsptr, rslen) == 0) {
+ pend -= rslen;
+ }
}
line = rb_str_subseq(str, subptr - ptr, pend - subptr);
ENUM_ELEM(ary, line);