string.c: term fill
* string.c (rb_str_chomp_bang): fill wchar terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c50d7ba15
commit
c77efe1144
2
string.c
2
string.c
@ -7188,7 +7188,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
|
|||||||
len = chompped_length(str, rs);
|
len = chompped_length(str, rs);
|
||||||
if (len < olen) {
|
if (len < olen) {
|
||||||
STR_SET_LEN(str, len);
|
STR_SET_LEN(str, len);
|
||||||
RSTRING_PTR(str)[len] = '\0';
|
TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str));
|
||||||
if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
|
if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
|
||||||
ENC_CODERANGE_CLEAR(str);
|
ENC_CODERANGE_CLEAR(str);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,10 @@ class Test_StringCStr < Test::Unit::TestCase
|
|||||||
assert_wchars_term_char("a ") {|s| s.rstrip!}
|
assert_wchars_term_char("a ") {|s| s.rstrip!}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_wchar_chop!
|
||||||
|
assert_wchars_term_char("a\n") {|s| s.chop!}
|
||||||
|
end
|
||||||
|
|
||||||
def assert_wchars_term_char(str)
|
def assert_wchars_term_char(str)
|
||||||
result = {}
|
result = {}
|
||||||
WCHARS.map do |enc|
|
WCHARS.map do |enc|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user