diff --git a/ChangeLog b/ChangeLog index aa5519a616..9aa50b1fd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Sep 15 03:00:35 2009 Yukihiro Matsumoto + + * string.c (rb_str_lstrip_bang): use ascii_isspace(). [ruby-dev:39322] + + * string.c (rb_str_rstrip_bang): ditto. + + * string.c (rb_str_split_m): ditto. + Mon Sep 14 16:39:14 2009 Nobuyoshi Nakada * debug.c, parse.y: fixed types. diff --git a/string.c b/string.c index 9aea029fe5..4a383c2e6f 100644 --- a/string.c +++ b/string.c @@ -5669,7 +5669,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) c = rb_enc_codepoint_len(ptr, eptr, &n, enc); ptr += n; if (skip) { - if (rb_enc_isspace(c, enc)) { + if (ascii_isspace(c)) { beg = ptr - bptr; } else { @@ -5678,7 +5678,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) if (!NIL_P(limit) && lim <= i) break; } } - else if (rb_enc_isspace(c, enc)) { + else if (ascii_isspace(c)) { rb_ary_push(result, rb_str_subseq(str, beg, end-beg)); skip = 1; beg = ptr - bptr; @@ -6320,7 +6320,7 @@ rb_str_lstrip_bang(VALUE str) int n; unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc); - if (!rb_enc_isspace(cc, enc)) break; + if (!ascii_isspace(cc)) break; s += n; } @@ -6382,14 +6382,14 @@ rb_str_rstrip_bang(VALUE str) /* remove trailing spaces or '\0's */ if (single_byte_optimizable(str)) { unsigned char c; - while (s < t && ((c = *(t-1)) == '\0' || rb_enc_isspace(c, enc))) t--; + while (s < t && ((c = *(t-1)) == '\0' || ascii_isspace(c))) t--; } else { char *tp; while ((tp = rb_enc_prev_char(s, t, e, enc)) != NULL) { unsigned int c = rb_enc_codepoint(tp, e, enc); - if (c && !rb_enc_isspace(c, enc)) break; + if (c && !ascii_isspace(c)) break; t = tp; } } diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 36968cae3f..36a8f67442 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1139,8 +1139,6 @@ 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!