diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
commit | ee5ab9cc136baf18756abc6bd5d136a0231f973e (patch) | |
tree | abdc351cbffd7b67f63f41ea08f544819af0a28b /io.c | |
parent | dc8da69e7cbc54f020ef1182fd28e57bbaa40fc3 (diff) |
1.1c7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -370,13 +370,14 @@ read_all(port) GetOpenFile(port, fptr); io_readable(fptr); -#ifdef __BEOS__ + str = str_new(0, siz); if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode) - && (st.st_dev > 3)) { -#else - if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)) { +#ifdef __BEOS__ + && (st.st_dev > 3) #endif - if (st.st_size == 0) return Qnil; + ) + { + if (st.st_size == 0) return str_new(0, 0); else { int pos = ftell(fptr->f); if (st.st_size > pos && pos >= 0) { @@ -384,7 +385,6 @@ read_all(port) } } } - str = str_new(0, siz); for (;;) { READ_CHECK(fptr->f); TRAP_BEG; @@ -392,14 +392,14 @@ read_all(port) TRAP_END; if (n <= 0) { if (ferror(fptr->f)) rb_sys_fail(fptr->path); - return Qnil; + return str_new(0, 0); } bytes += n; if (bytes < siz) break; siz += BUFSIZ; str_resize(str, siz); } - if (bytes == 0) return Qnil; + if (bytes == 0) return str_new(0, 0); if (bytes != siz) str_resize(str, bytes); return str_taint(str); } @@ -414,7 +414,7 @@ io_read(argc, argv, io) int n, len; VALUE length, str; - if (rb_scan_args(argc, argv, "01", &length) == 0) { + if (rb_scan_args(argc, argv, "01", &length) == 0 || NIL_P(length)) { return read_all(io); } @@ -2037,10 +2037,10 @@ f_select(argc, argv, obj) GetOpenFile(io, fptr); FD_SET(fileno(fptr->f), wp); - if (max > fileno(fptr->f)) max = fileno(fptr->f); + if (max < fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { FD_SET(fileno(fptr->f2), wp); - if (max < (int)fileno(fptr->f2)) max = fileno(fptr->f2); + if (max < fileno(fptr->f2)) max = fileno(fptr->f2); } } } @@ -2059,7 +2059,7 @@ f_select(argc, argv, obj) if (max < fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { FD_SET(fileno(fptr->f2), ep); - if (max > (int)fileno(fptr->f2)) max = fileno(fptr->f2); + if (max < fileno(fptr->f2)) max = fileno(fptr->f2); } } } |