ruby-changes:4210
From: ko1@a...
Date: Thu, 6 Mar 2008 04:34:41 +0900 (JST)
Subject: [ruby-changes:4210] naruse - Ruby:r15700 (trunk): * string.c (count_utf8_lead_bytes_with_ulong): fix shift size.
naruse 2008-03-06 04:34:15 +0900 (Thu, 06 Mar 2008)
New Revision: 15700
Modified files:
trunk/ChangeLog
trunk/string.c
trunk/test/ruby/test_m17n.rb
trunk/test/ruby/test_regexp.rb
Log:
* string.c (count_utf8_lead_bytes_with_ulong): fix shift size.
[ruby-dev:33993]
* string.c (str_utf8_nth) fix wrong counting.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=15700&r2=15699&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15700&r2=15699&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_regexp.rb?r1=15700&r2=15699&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=15700&r2=15699&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15699)
+++ ChangeLog (revision 15700)
@@ -1,3 +1,10 @@
+Thu Mar 6 04:32:06 2008 NARUSE, Yui <naruse@r...>
+
+ * string.c (count_utf8_lead_bytes_with_ulong): fix shift size.
+ [ruby-dev:33993]
+
+ * string.c (str_utf8_nth) fix wrong counting.
+
Thu Mar 6 00:34:00 2008 Nobuyoshi Nakada <nobu@r...>
* sprintf.c (rb_str_format): size_t returned from strlen() can be
@@ -7,7 +14,7 @@
* struct.c (make_struct): preserve encoding of struct name.
-Wed Mar 05 22:49:20 2008 NARUSE, Yui <naruse@r...>
+Wed Mar 5 22:49:20 2008 NARUSE, Yui <naruse@r...>
* string.c (is_utf8_lead_byte, count_utf8_lead_bytes_with_ulong):
defined for UTF-8 optimization.
@@ -22,7 +29,7 @@
* file.c (rb_file_flock): returns false on EAGAIN if non-blocking.
[ruby-core:15795]
-Web Mar 5 17:43:43 2008 Martin Duerst <duerst@i...>
+Wed Mar 5 17:43:43 2008 Martin Duerst <duerst@i...>
* transcode.c (transcode_loop): Adjusted detection of invalid
(ill-formed) UTF-8 sequences. Fixing potential security issue, see
@@ -85,7 +92,7 @@
* parse.y (parser_yylex): disallow non digits '0o' expression.
-Tue Mar 04 14:35:12 2008 NARUSE, Yui <naruse@r...>
+Tue Mar 4 14:35:12 2008 NARUSE, Yui <naruse@r...>
* io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open.
[ruby-core:15763]
@@ -99,7 +106,7 @@
* gc.c (add_heap): use binary search to find the place to insert the
new heap slot. [ruby-dev:33983]
-Tue Mar 04 05:30:31 2008 NARUSE, Yui <naruse@r...>
+Tue Mar 4 05:30:31 2008 NARUSE, Yui <naruse@r...>
* io.c (open_key_args): use rb_io_open instead of rb_f_open.
[ruby-core:15746]
@@ -189,7 +196,7 @@
* thread.c (remove_event_hook): should not access freed memory.
[ruby-dev:31820]
-Sat Mar 01 10:31:19 2008 NARUSE, Yui <naruse@r...>
+Sat Mar 1 10:31:19 2008 NARUSE, Yui <naruse@r...>
* io.c (read_all, rb_io_getline_fast): encoding is io_input_encoding.
Index: string.c
===================================================================
--- string.c (revision 15699)
+++ string.c (revision 15700)
@@ -763,7 +763,7 @@
unsigned long d = *s;
d |= ~(d>>1);
d >>= 6;
- d &= NONASCII_MASK >> 3;
+ d &= NONASCII_MASK >> 7;
d += (d>>8);
d += (d>>16);
#if NONASCII_MASK == 0x8080808080808080UL
@@ -1177,11 +1177,10 @@
if (is_utf8_lead_byte(*p)) nth--;
p++;
}
- while (s < t) {
+ do {
nth -= count_utf8_lead_bytes_with_ulong(s);
- if (nth < sizeof(long)) break;
s++;
- }
+ } while (s < t && sizeof(long) <= nth);
p = (char *)s;
}
if (0 < nth) {
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb (revision 15699)
+++ test/ruby/test_m17n.rb (revision 15700)
@@ -810,6 +810,17 @@
assert_equal(false, str[0..-1].ascii_only?)
end
+ def test_utf8str_aref
+ s = "abcdefghijklmnopqrstuvwxyz\u{3042 3044 3046 3048 304A}"
+ assert_equal("a", s[0])
+ assert_equal("h", s[7])
+ assert_equal("i", s[8])
+ assert_equal("j", s[9])
+ assert_equal("\u{3044}", s[27])
+ assert_equal("\u{3046}", s[28])
+ assert_equal("\u{3048}", s[29])
+ end
+
def test_str_aref_len
assert_equal(a("\xa1"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 1])
assert_equal(a("\xa1\xc2"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 2])
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb (revision 15699)
+++ test/ruby/test_regexp.rb (revision 15700)
@@ -123,6 +123,8 @@
r = /./
m = r.match("a")
assert_equal(r, m.regexp)
+ re = /foo/
+ assert_equal(re, re.match("foo").regexp)
end
def test_source
@@ -188,11 +190,6 @@
assert_equal(/foo/, m.dup.regexp)
end
- def test_match_regexp
- re = /foo/
- assert_equal(re, re.match("foo").regexp)
- end
-
def test_match_size
m = /(.)(.)(\d+)(\d)/.match("THX1138.")
assert_equal(5, m.size)
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/