From: Yoshida Masato Date: 1998-11-17T22:45:29+09:00 Subject: [ruby-list:10914] Re: ruby 1.1c8 released よしだです IO#read や $<.read でサイズを指定しないときに大きめのファイ ルを読むと [BUG] で落ちてしまいます。 read_all でバッファのサイズがおかしくなっているようです。 あと, open("/dev/null").read が "" を返すのに, open("/dev/null").read(1) は nil を返すのがちょっと気になります。 --- ruby-1.1c8/io.c.org Mon Nov 9 18:11:49 1998 +++ ruby-1.1c8/io.c Tue Nov 17 21:55:39 1998 @@ -370,7 +370,6 @@ GetOpenFile(port, fptr); io_readable(fptr); - str = str_new(0, siz); if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode) #ifdef __BEOS__ && (st.st_dev > 3) @@ -385,6 +384,7 @@ } } } + str = str_new(0, siz); for (;;) { READ_CHECK(fptr->f); TRAP_BEG; @@ -2455,12 +2455,12 @@ retry: if (!next_argv()) return str; tmp = io_read(argc, argv, file); - if (NIL_P(tmp) && next_p != -1) { + if ((NIL_P(tmp) || RSTRING(tmp)->len == 0) && next_p != -1) { io_close(file); next_p = 1; goto retry; } - if (NIL_P(tmp)) return str; + if (NIL_P(tmp) || RSTRING(tmp)->len == 0) return str; else if (NIL_P(str)) str = tmp; else str_cat(str, RSTRING(tmp)->ptr, RSTRING(tmp)->len); if (argc == 0) { -- 吉田正人 INS エンジニアリング(株) マルチメディアシステム事業部 yoshidam@inse.co.jp yoshidam@tau.bekkoame.ne.jp