diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-06 12:55:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-06 12:55:05 +0000 |
commit | 6608596896a8acf92401fdb2530d16b93f2ffd90 (patch) | |
tree | 835474b02fd9662bdac1f53d8948f7fdefe6cfd0 /io.c | |
parent | 3492e5c791e9fbdace5a89bfab4ee46e0a7575f9 (diff) | |
download | ruby-6608596896a8acf92401fdb2530d16b93f2ffd90.tar.gz ruby-6608596896a8acf92401fdb2530d16b93f2ffd90.tar.xz ruby-6608596896a8acf92401fdb2530d16b93f2ffd90.zip |
* io.c (fptr_finalize): should save errno just after failure.
[ruby-dev:22492]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@5390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1726,12 +1726,12 @@ fptr_finalize(fptr, noraise) OpenFile *fptr; int noraise; { - int n1 = 0, n2 = 0, e = 0, f1, f2 = -1; + int n1 = 0, n2 = 0, f1, f2 = -1; if (fptr->f2) { f2 = fileno(fptr->f2); - while ((n2 = fclose(fptr->f2)) < 0) { - e = errno; + while (n2 = 0, fclose(fptr->f2) < 0) { + n2 = errno; if (!rb_io_wait_writable(f2)) { break; } @@ -1741,18 +1741,19 @@ fptr_finalize(fptr, noraise) } if (fptr->f) { f1 = fileno(fptr->f); - while ((n1 = fclose(fptr->f)) < 0) { + while (n1 = 0, fclose(fptr->f) < 0) { + n1 = errno; if (f2 != -1 || !(fptr->mode & FMODE_WBUF)) break; if (!rb_io_wait_writable(f1)) break; if (!fptr->f) break; } fptr->f = 0; - if (n1 < 0 && errno == EBADF && f1 == f2) { + if (n1 == EBADF && f1 == f2) { n1 = 0; } } - if (!noraise && (n1 < 0 || n2 < 0)) { - if (n1 == 0) errno = e; + if (!noraise && (n1 || n2)) { + errno = (n1 ? n1 : n2); rb_sys_fail(fptr->path); } } |