ruby-changes:13180
From: naruse <ko1@a...>
Date: Tue, 15 Sep 2009 14:27:49 +0900 (JST)
Subject: [ruby-changes:13180] Ruby:r24934 (trunk): Use rb_isspace for ASCII-incompatible strings.
naruse 2009-09-15 14:27:29 +0900 (Tue, 15 Sep 2009) New Revision: 24934 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24934 Log: Use rb_isspace for ASCII-incompatible strings. * string.c (rb_str_split_m): use rb_isspace when the string may be ASCII-incompatible. (rb_str_lstrip_bang): ditto. (rb_str_rstrip_bang): ditto. Modified files: trunk/ChangeLog trunk/string.c trunk/test/ruby/test_string.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24933) +++ ChangeLog (revision 24934) @@ -1,3 +1,12 @@ +Tue Sep 15 14:24:52 2009 NARUSE, Yui <naruse@r...> + + * string.c (rb_str_split_m): use rb_isspace when the + string may be ASCII-incompatible. + + * string.c (rb_str_lstrip_bang): ditto. + + * string.c (rb_str_rstrip_bang): ditto. + Tue Sep 15 12:12:27 2009 Nobuyoshi Nakada <nobu@r...> * configure.in (RUBY_USE_BUILTIN_FRAME_ADDRESS): check after real Index: string.c =================================================================== --- string.c (revision 24933) +++ string.c (revision 24934) @@ -5669,7 +5669,7 @@ c = rb_enc_codepoint_len(ptr, eptr, &n, enc); ptr += n; if (skip) { - if (ascii_isspace(c)) { + if (rb_isspace(c)) { beg = ptr - bptr; } else { @@ -5678,7 +5678,7 @@ if (!NIL_P(limit) && lim <= i) break; } } - else if (ascii_isspace(c)) { + else if (rb_isspace(c)) { rb_ary_push(result, rb_str_subseq(str, beg, end-beg)); skip = 1; beg = ptr - bptr; @@ -6320,7 +6320,7 @@ int n; unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc); - if (!ascii_isspace(cc)) break; + if (!rb_isspace(cc)) break; s += n; } @@ -6389,7 +6389,7 @@ while ((tp = rb_enc_prev_char(s, t, e, enc)) != NULL) { unsigned int c = rb_enc_codepoint(tp, e, enc); - if (c && !ascii_isspace(c)) break; + if (c && !rb_isspace(c)) break; t = tp; } } Index: test/ruby/test_string.rb =================================================================== --- test/ruby/test_string.rb (revision 24933) +++ test/ruby/test_string.rb (revision 24934) @@ -1139,6 +1139,11 @@ 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("0b0 ".force_encoding("UTF-16BE"), + "\x00 0b0 ".force_encoding("UTF-16BE").strip) + assert_equal("0\x000b0 ".force_encoding("UTF-16BE"), + "0\x000b0 ".force_encoding("UTF-16BE").strip) end def test_strip! -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/