From: matz@... (Yukihiro Matsumoto) Date: 1997-02-19T17:23:57+09:00 Subject: [ruby-list:2210] Re: [BUG] split(" ", limit) まつもと ゆきひろです. In message "[ruby-list:2209] Re: [BUG] split(" ", limit)" on 97/02/19, WATANABE Hirofumi writes: |わたなべです. | |何度も何度もすいません. いえいえ,パッチ合戦ですね. |ary_push の問題より beg が修正されないのが大元の原因でした. |("a,b,b:c" のような結果になる). だから | | i = 1 | beg はチェックの前 | |でよさそうです. 私はこういう感じの修正をしてみました.どうもちゃんと動いてい るようです. --- string.c.orig Wed Feb 19 01:32:28 1997 +++ string.c Wed Feb 19 16:58:53 1997 @@ -1631,2 +1631,4 @@ lim = NUM2INT(limit); + if (lim == 0) limit = Qnil; + else if (lim == 1) return ary_new3(1, str); i = 1; @@ -1682,3 +1684,3 @@ ary_push(result, str_substr(str, beg, end-beg)); - if (!NIL_P(limit) && lim <= ++i) break; + if (!NIL_P(limit) && lim <= i++) break; skip = 1; @@ -1696,3 +1698,3 @@ ary_push(result, str_substr(str, beg, end-beg)); - if (!NIL_P(limit) && lim <= ++i) break; + if (!NIL_P(limit) && lim <= i++) break; beg = end + 1;