diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-08 11:08:18 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-08 11:08:18 +0000 |
| commit | e28369ebe894cb8e0b6fd6eee6a51f41a44469d8 (patch) | |
| tree | 264d96422fa41253f0352d11d72cd6921a578930 | |
| parent | 2045c3f7e2e15733d849348a698855594886dcb0 (diff) | |
| download | ruby-e28369ebe894cb8e0b6fd6eee6a51f41a44469d8.tar.gz ruby-e28369ebe894cb8e0b6fd6eee6a51f41a44469d8.tar.xz ruby-e28369ebe894cb8e0b6fd6eee6a51f41a44469d8.zip | |
* string.c (rb_str_rstrip_bang): should not sign-expand non-ascii.
[ruby-core:23158]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | string.c | 3 | ||||
| -rw-r--r-- | test/ruby/test_string.rb | 2 |
3 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Wed Apr 8 20:08:16 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (rb_str_rstrip_bang): should not sign-expand non-ascii. + [ruby-core:23158] + Wed Apr 8 17:29:29 2009 NARUSE, Yui <naruse@ruby-lang.org> * string.c (rb_str_chop_bang): reset coderange. [ruby-core:23155] @@ -6197,7 +6197,8 @@ rb_str_rstrip_bang(VALUE str) /* remove trailing spaces or '\0's */ if (single_byte_optimizable(str)) { - while (s < t && (*(t-1) == '\0' || rb_enc_isspace(*(t-1), enc))) t--; + unsigned char c; + while (s < t && ((c = *(t-1)) == '\0' || rb_enc_isspace(c, enc))) t--; } else { char *tp; diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index b209296ef..e87b6d3c8 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1139,6 +1139,8 @@ class TestString < Test::Unit::TestCase def test_strip assert_equal(S("x"), S(" x ").strip) assert_equal(S("x"), S(" \n\r\t x \t\r\n\n ").strip) + assert_equal(S(""), S("\xa0".force_encoding("iso-8859-1")).strip) + assert_equal(S("a"), S("a\xa0".force_encoding("iso-8859-1")).strip) end def test_strip! |
