summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--string.c2
-rw-r--r--test/-ext-/string/test_cstr.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/string.c b/string.c
index d82051d25f..6b3b61c9e9 100644
--- a/string.c
+++ b/string.c
@@ -6076,7 +6076,7 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
}
}
- *t = '\0';
+ TERM_FILL(t, TERM_LEN(str));
if (t - RSTRING_PTR(str) != RSTRING_LEN(str)) {
STR_SET_LEN(str, t - RSTRING_PTR(str));
modify = 1;
diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb
index 86670dc6e2..9c2b73f695 100644
--- a/test/-ext-/string/test_cstr.rb
+++ b/test/-ext-/string/test_cstr.rb
@@ -68,6 +68,10 @@ class Test_StringCStr < Test::Unit::TestCase
assert_wchars_term_char("foobar") {|s| s.delete!("ao".encode(s.encoding))}
end
+ def test_wchar_squeeze!
+ assert_wchars_term_char("foo!") {|s| s.squeeze!}
+ end
+
def assert_wchars_term_char(str)
result = {}
WCHARS.map do |enc|