[#39606] [Feature:trunk] Dir instance methods for relative path — Nobuyoshi Nakada <nobu@...>

なかだです。

15 messages 2009/11/02
[#39607] Re: [Feature:trunk] Dir instance methods for relative path — Yukihiro Matsumoto <matz@...> 2009/11/02

まつもと ゆきひろです

[#39611] Re: [Feature:trunk] Dir instance methods for relative path — KOSAKI Motohiro <kosaki.motohiro@...> 2009/11/02

kosakiです

[#39660] [Bug:trunk] Enumerator.new {|y| y << 1 << 2 << 3 } — Yusuke ENDOH <mame@...>

遠藤です。

14 messages 2009/11/11
[#39661] Re: [Bug:trunk] Enumerator.new {|y| y << 1 << 2 << 3 } — Tanaka Akira <akr@...> 2009/11/11

In article <e0b1e5700911110537u2aacf835pc0aea13d89a92cef@mail.gmail.com>,

[#39685] [Feature #2366] private constant — Yusuke Endoh <redmine@...>

Feature #2366: private constant

23 messages 2009/11/14
[#39689] [Feature #2366] private constant — Yusuke Endoh <redmine@...> 2009/11/14

チケット #2366 が更新されました。 (by Yusuke Endoh)

[#40207] Re: [Feature #2366] private constant — Yusuke ENDOH <mame@...> 2010/01/28

遠藤です。

[#40239] Re: [Feature #2366] private constant — Masatoshi SEKI <m_seki@...> 2010/01/29

=1B$B31$H$$$$$^$9!#=1B(B

[#40243] Re: [Feature #2366] private constant — Yusuke ENDOH <mame@...> 2010/01/29

遠藤です。

[#40246] Re: [Feature #2366] private constant — Masatoshi SEKI <m_seki@...> 2010/01/29

=1B$B31$H$$$$$^$9!#=1B(B

[#40247] Re: [Feature #2366] private constant — "NARUSE, Yui" <naruse@...> 2010/01/29

成瀬です。

[#39720] hidden objectって? — keiju@... (Keiju ISHITSUKA)

けいじゅ@いしつかです.

15 messages 2009/11/18
[#39721] Re: hidden objectって? — Yukihiro Matsumoto <matz@...> 2009/11/18

まつもと ゆきひろです

[#39726] Re: hidden objectって? — keiju@... (石塚圭樹) 2009/11/19

けいじゅ@いしつかです.

[#39727] Re: hidden objectって? — Yukihiro Matsumoto <matz@...> 2009/11/19

まつもと ゆきひろです

[#39730] Re: hidden objectって? — keiju@... (石塚圭樹) 2009/11/19

けいじゅ@いしつかです.

[#39735] [Bug:trunk] r25230 causes SEGV arround Marshal — "NARUSE, Yui" <naruse@...> 2009/11/19

以下のコミット以降、後述の現象が発生するそうです。

[#39755] RbConfig.rubybin — Tanaka Akira <akr@...>

ruby コマンドのパス名を返す RbConfig.rubybin というメソッド

18 messages 2009/11/23
[#39756] Re: RbConfig.rubybin — Kouhei Sutou <kou@...> 2009/11/23

須藤です。

[#39814] Re: RbConfig.rubybin — Tanaka Akira <akr@...> 2009/11/30

In article <20091123.123808.1122146273169400964.kou@cozmixng.org>,

[#39815] Re: RbConfig.rubybin — KOSAKI Motohiro <kosaki.motohiro@...> 2009/11/30

> In article <20091123.123808.1122146273169400964.kou@cozmixng.org>,

[#39796] バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — keiju@... (Keiju ISHITSUKA)

けいじゅ@いしつかです.

14 messages 2009/11/27
[#39800] Re: バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — Yukihiro Matsumoto <matz@...> 2009/11/27

まつもと ゆきひろです

[#39803] Re: バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — keiju@... (石塚圭樹) 2009/11/27

けいじゅ@いしつかです.

[#39805] Re: バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — Yukihiro Matsumoto <matz@...> 2009/11/28

まつもと ゆきひろです

[#39806] Re: バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — keiju@... (石塚圭樹) 2009/11/28

けいじゅ@いしつかです.

[#39807] Re: バグ? ブロック引数で to_ary が呼ばれる必要のない場面で呼ばれる — Yukihiro Matsumoto <matz@...> 2009/11/28

まつもと ゆきひろです

[ruby-dev:39612] Re: [Bug #2323] "Z".."Z".succが空

From: Nobuyoshi Nakada <nobu@...>
Date: 2009-11-02 17:16:09 UTC
List: ruby-dev #39612
なかだです。

At Mon, 2 Nov 2009 16:19:40 +0900,
Hiro Asari wrote in [ruby-dev:39604]:
> surfboard:~$ ruby1.9 -v; ruby1.9 -e 'p ("Z".."Z".succ); p ("Z".."Z".succ).to_a'
> ruby 1.9.2dev (2009-11-02 trunk 25625) [x86_64-darwin10.0.0]
> "Z".."AA"
> []

こんなところでしょうか。


Index: string.c
===================================================================
--- string.c	(revision 25629)
+++ string.c	(working copy)
@@ -2844,4 +2844,44 @@ rb_str_succ_bang(VALUE str)
 }
 
+static int
+str_succ_cmp(VALUE str1, VALUE str2, rb_encoding *enc)
+{
+    const char *p1 = RSTRING_PTR(str1), *e1 = RSTRING_END(str1);
+    const char *p2 = RSTRING_PTR(str2), *e2 = RSTRING_END(str2);
+    size_t l1, l2;
+    do {
+	if (ISUPPER(*p1) && ISUPPER(*p2)) {
+	    for (l1 = 1; p1+l1 < e1 && ISUPPER(p1[l1]); l1++);
+	    for (l2 = 1; p2+l2 < e2 && ISUPPER(p2[l2]); l2++);
+	}
+	else if (ISLOWER(*p1) && ISLOWER(*p2)) {
+	    for (l1 = 1; p1+l1 < e1 && ISLOWER(p1[l1]); l1++);
+	    for (l2 = 1; p2+l2 < e2 && ISLOWER(p2[l2]); l2++);
+	}
+	else if (ISDIGIT(*p1) && ISDIGIT(*p2)) {
+	    for (l1 = 1; p1+l1 < e1 && ISDIGIT(p1[l1]); l1++);
+	    for (l2 = 1; p2+l2 < e2 && ISDIGIT(p2[l2]); l2++);
+	}
+	else {
+	    int n, c;
+	    for (l1 = 0; p1+l1 < e1; l1 += n) {
+		c = rb_enc_ascget(p1+l1, e1, &n, enc);
+		if (ISALNUM(c)) break;
+	    }
+	    for (l2 = 0; p2+l2 < e2; l2 += n) {
+		c = rb_enc_ascget(p2+l2, e2, &n, enc);
+		if (ISALNUM(c)) break;
+	    }
+	    if (l1 == 0 || l2 == 0) return 1;
+	}
+	if (l1 > l2) return 1;
+	if (l1 == l2) {
+	    if (memcmp(p1, p2, l1) > 0) return 0;
+	}
+	p1 += l1;
+	p2 += l2;
+    } while (p1 < e1 || p2 < e2);
+    return -(p1 == e1 && p2 == e2);
+}
 
 /*
@@ -2881,4 +2921,5 @@ rb_str_upto(int argc, VALUE *argv, VALUE
     ID succ;
     int n, excl, ascii;
+    char c, e;
     rb_encoding *enc;
 
@@ -2891,8 +2932,9 @@ rb_str_upto(int argc, VALUE *argv, VALUE
     ascii = (is_ascii_string(beg) && is_ascii_string(end));
     /* single character */
-    if (RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1 && ascii) {
-	char c = RSTRING_PTR(beg)[0];
-	char e = RSTRING_PTR(end)[0];
-
+    if (ascii &&
+	RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1 &&
+	(c = RSTRING_PTR(beg)[0], ISALPHA(c)) &&
+	(e = RSTRING_PTR(end)[0], ISALPHA(e)) &&
+	(ISUPPER(c) == ISUPPER(e))) {
 	if (c > e || (excl && c == e)) return beg;
 	for (;;) {
@@ -2906,5 +2948,5 @@ rb_str_upto(int argc, VALUE *argv, VALUE
     /* both edges are all digits */
     if (ascii && ISDIGIT(RSTRING_PTR(beg)[0]) && ISDIGIT(RSTRING_PTR(end)[0])) {
-	char *s, *send;
+	const char *s, *send;
 	VALUE b, e;
 	int width;
@@ -2949,5 +2991,8 @@ rb_str_upto(int argc, VALUE *argv, VALUE
     /* normal case */
   no_digits:
-    n = rb_str_cmp(beg, end);
+    if (ascii && rb_enc_str_coderange(beg) == rb_enc_str_coderange(end))
+	n = str_succ_cmp(beg, end, enc);
+    else
+	n = rb_str_cmp(beg, end);
     if (n > 0 || (excl && n == 0)) return beg;
 
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 25629)
+++ test/ruby/test_range.rb	(working copy)
@@ -256,4 +256,7 @@ class TestRange < Test::Unit::TestCase
     assert(!(("a"..."z").include?("z")))
     assert(!(("a".."z").include?("cc")))
+    assert(("Z".."ZA").include?("AA"))
+    assert(!("Z".."za").include?("AA"))
+    assert(("Z".."CA").include?("AA"))
     assert((0...10).include?(5))
   end
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 25629)
+++ test/ruby/test_string.rb	(working copy)
@@ -1588,4 +1588,8 @@ class TestString < Test::Unit::TestCase
                    })
     assert_equal(676, count)
+
+    a = []
+    S("Z").upto(S("AA")) {|s| a << s}
+    assert_equal([S("Z"), S("AA")], a)
   end
 


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread