aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-20 10:20:43 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-20 10:20:43 +0000
commit492f431a46b5742e0c741fb0345e3279661a5762 (patch)
tree3dadcfefbd2aa5ba12cb993a0e49f85b69654fdd
parent96ada56fb9caf72b3ef451f251cf876c6bec3d7e (diff)
downloadruby-492f431a46b5742e0c741fb0345e3279661a5762.tar.gz
* string.c (rb_enc_str_copy): added for wrapper for rb_enc_copy.
this also copy coderange when ptr and len is equal. * string.c (rb_enc_cr_str_copy): added for wrapper for rb_enc_copy. this always copy coderange. * string.c (str_replace_shared): use rb_enc_str_copy. * string.c (str_new3): don't rb_enc_copy because encoding is copied at str_replace_shared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--string.c23
2 files changed, 32 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d502c60b1..27c5c60200 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Feb 20 19:15:38 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (rb_enc_str_copy): added for wrapper for rb_enc_copy.
+ this also copy coderange when ptr and len is equal.
+
+ * string.c (rb_enc_cr_str_copy): added for wrapper for rb_enc_copy.
+ this always copy coderange.
+
+ * string.c (str_replace_shared): use rb_enc_str_copy.
+
+ * string.c (str_new3): don't rb_enc_copy because encoding is copied
+ at str_replace_shared.
+
Wed Feb 20 13:08:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb (parse_args): added --dir-mode, --script-mode and
diff --git a/string.c b/string.c
index 4540b86f74..dbd6a09dcf 100644
--- a/string.c
+++ b/string.c
@@ -201,6 +201,23 @@ coderange_scan(const char *p, long len, rb_encoding *enc)
return ENC_CODERANGE_VALID;
}
+void
+rb_enc_str_copy(VALUE str1, VALUE str2)
+{
+ rb_enc_copy(str1, str2);
+ if (RSTRING_PTR(str1) == RSTRING_PTR(str2) &&
+ RSTRING_LEN(str1) == RSTRING_LEN(str2)) {
+ ENC_CODERANGE_SET(str1, ENC_CODERANGE(str2));
+ }
+}
+
+void
+rb_enc_cr_str_copy(VALUE str1, VALUE str2)
+{
+ rb_enc_copy(str1, str2);
+ ENC_CODERANGE_SET(str1, ENC_CODERANGE(str2));
+}
+
int
rb_enc_str_coderange(VALUE str)
{
@@ -359,6 +376,7 @@ str_replace_shared(VALUE str2, VALUE str)
RSTRING(str2)->as.heap.aux.shared = str;
FL_SET(str2, ELTS_SHARED);
}
+ rb_enc_cr_str_copy(str2, str);
return str2;
}
@@ -372,10 +390,7 @@ str_new_shared(VALUE klass, VALUE str)
static VALUE
str_new3(VALUE klass, VALUE str)
{
- VALUE str2 = str_new_shared(klass, str);
-
- rb_enc_copy(str2, str);
- return str2;
+ return str_new_shared(klass, str);
}
VALUE