From: matz@... (Yukihiro Matsumoto) Date: 1997-02-19T02:53:11+09:00 Subject: [ruby-list:2190] Re: [BUG] split(" ", limit) まつもと ゆきひろです In message "[ruby-list:2171] Re: [BUG] split(" ", limit)" on 97/02/18, WATANABE Hirofumi writes: |わたなべです. |これでどうかな? の 2 回目. 惜しい.でも,とても参考になりました. どうも以下のパッチが原さんの(perlの)仕様を満たすようです --- string.c.orig Wed Feb 19 01:32:28 1997 +++ string.c Wed Feb 19 02:31:22 1997 @@ -1631,2 +1631,4 @@ lim = NUM2INT(limit); + if (lim == 0) limit = Qnil; + else if (lim == 1) return ary_new3(1, str); i = 1; @@ -1681,4 +1683,4 @@ if (isspace(*ptr)) { - ary_push(result, str_substr(str, beg, end-beg)); if (!NIL_P(limit) && lim <= ++i) break; + ary_push(result, str_substr(str, beg, end-beg)); skip = 1; @@ -1695,4 +1697,4 @@ if (*ptr == char_sep) { - ary_push(result, str_substr(str, beg, end-beg)); if (!NIL_P(limit) && lim <= ++i) break; + ary_push(result, str_substr(str, beg, end-beg)); beg = end + 1;