summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-01-06 12:55:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-01-06 12:55:05 +0000
commit6608596896a8acf92401fdb2530d16b93f2ffd90 (patch)
tree835474b02fd9662bdac1f53d8948f7fdefe6cfd0 /io.c
parent3492e5c791e9fbdace5a89bfab4ee46e0a7575f9 (diff)
downloadruby-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.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/io.c b/io.c
index 73423411c..6b1dd4c27 100644
--- a/io.c
+++ b/io.c
@@ -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);
}
}