summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-05 01:24:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-05 01:24:57 +0000
commit37dd754e970cc177761093980cc249328866578a (patch)
treeb4224e2cd2533fda68f8a4b4acc8fea47b76e868
parentec46ba5b90c3c9d4d73fea7989681d78c7c9ec7b (diff)
* string.c (rb_str_chomp_bang): keeps 7bit coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--string.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 15d07fc2e3..2878fcd2de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar 5 10:24:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_chomp_bang): keeps 7bit coderange.
+
Thu Mar 5 10:10:40 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/encoding.h (enc_initialized_p): ENC_UNINITIALIZED
diff --git a/string.c b/string.c
index 3166f595e7..e94f563995 100644
--- a/string.c
+++ b/string.c
@@ -6056,7 +6056,10 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
if (rb_enc_left_char_head(p, pp, e, enc) != pp)
return Qnil;
- rb_str_modify(str);
+ str_modify_keep_cr(str);
+ if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
+ ENC_CODERANGE_CLEAR(str);
+ }
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
return str;