From: matz@... (Yukihiro Matsumoto) Date: 1998-04-09T18:29:39+09:00 Subject: [ruby-list:7402] Re: chomp まつもと ゆきひろです In message "[ruby-list:7399] chomp" on 98/04/09, NAGAI Hidetoshi writes: |永井@知能.九工大です. | |chomp の動作がおかしいようです.(ruby-1.1b9_08) chompと==(というかstr_cmp())の相乗効果のようですね.パッチ付 けときます. diff -u -1 -r1.1.1.2.2.22 string.c --- string.c 1998/04/08 08:12:38 1.1.1.2.2.22 +++ string.c 1998/04/09 09:29:17 @@ -46,2 +46,3 @@ } + str->ptr = 0; str->len = len; @@ -485,3 +486,5 @@ if (retval == 0) { - retval = RSTRING(str1)->ptr[len] - RSTRING(str2)->ptr[len]; + if (RSTRING(str1)->len == RSTRING(str2)->len) return 0; + if (RSTRING(str1)->len > RSTRING(str2)->len) return 1; + return -1; } @@ -2290,2 +2293,3 @@ RSTRING(str)->len = len; + RSTRING(str)->ptr[len] = '\0'; return str; @@ -2301,2 +2305,3 @@ RSTRING(str)->len -= rslen; + RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; return str;