summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--string.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 84d5cc187b..fbc98f9c51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jan 9 16:59:54 2008 Tanaka Akira <akr@fsij.org>
+
+ * string.c (rb_enc_cr_str_buf_cat): fix self appending.
+
Wed Jan 9 15:54:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (process_options): give priority command line encoding option
diff --git a/string.c b/string.c
index f2371dcf01..c00fa3cd5c 100644
--- a/string.c
+++ b/string.c
@@ -1132,9 +1132,6 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
off = ptr - RSTRING_PTR(str);
}
rb_str_modify(str);
- if (off != -1) {
- ptr = RSTRING_PTR(str) + off;
- }
if (len == 0) {
ENCODING_CODERANGE_SET(str, res_encindex, res_cr);
return str;
@@ -1156,6 +1153,9 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
}
RESIZE_CAPA(str, capa);
}
+ if (off != -1) {
+ ptr = RSTRING_PTR(str) + off;
+ }
memcpy(RSTRING_PTR(str) + RSTRING_LEN(str), ptr, len);
STR_SET_LEN(str, total);
RSTRING_PTR(str)[total] = '\0'; // sentinel