aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--string.c8
-rw-r--r--test/ruby/test_string.rb5
3 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4004db6268..0d6059cc7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Sep 15 14:24:52 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* configure.in (RUBY_USE_BUILTIN_FRAME_ADDRESS): check after real
diff --git a/string.c b/string.c
index 4a383c2e6f..ef5474b731 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 (ascii_isspace(c)) {
+ if (rb_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 (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 @@ rb_str_lstrip_bang(VALUE str)
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 @@ rb_str_rstrip_bang(VALUE str)
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;
}
}
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 36a8f67442..f14e1e856d 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1139,6 +1139,11 @@ 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("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!