mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_chomp_bang): coderange may change.
[ruby-core:22414] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
01e9a7be61
commit
6dd9388545
3 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Feb 25 02:28:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_chomp_bang): coderange may change.
|
||||||
|
[ruby-core:22414]
|
||||||
|
|
||||||
Wed Feb 25 02:17:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Feb 25 02:17:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_str_delete_bang): should recalculate coderange.
|
* string.c (rb_str_delete_bang): should recalculate coderange.
|
||||||
|
|
2
string.c
2
string.c
|
@ -6056,7 +6056,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
|
||||||
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
|
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
|
||||||
if (rb_enc_left_char_head(p, pp, e, enc) != pp)
|
if (rb_enc_left_char_head(p, pp, e, enc) != pp)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
str_modify_keep_cr(str);
|
rb_str_modify(str);
|
||||||
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
|
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
|
||||||
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
|
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -339,6 +339,8 @@ class TestString < Test::Unit::TestCase
|
||||||
assert_equal(S("hello"), S("hello").chomp)
|
assert_equal(S("hello"), S("hello").chomp)
|
||||||
assert_equal(S("hello"), S("hello!").chomp)
|
assert_equal(S("hello"), S("hello!").chomp)
|
||||||
$/ = save
|
$/ = save
|
||||||
|
|
||||||
|
assert_equal(S("a").hash, S("a\u0101").chomp(S("\u0101")).hash, '[ruby-core:22414]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chomp!
|
def test_chomp!
|
||||||
|
@ -393,6 +395,8 @@ class TestString < Test::Unit::TestCase
|
||||||
s = "foo\r"
|
s = "foo\r"
|
||||||
s.chomp!("")
|
s.chomp!("")
|
||||||
assert_equal("foo\r", s)
|
assert_equal("foo\r", s)
|
||||||
|
|
||||||
|
assert_equal(S("a").hash, S("a\u0101").chomp!(S("\u0101")).hash, '[ruby-core:22414]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chop
|
def test_chop
|
||||||
|
|
Loading…
Reference in a new issue