* io.c (fptr_finalize): close IO object if fd is already closed.
(rb_p): call rb_io_write just once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3854be4322
commit
507f89d33f
@ -1,3 +1,8 @@
|
||||
Mon Jun 9 17:47:09 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (fptr_finalize): close IO object if fd is already closed.
|
||||
(rb_p): call rb_io_write just once.
|
||||
|
||||
Mon Jun 9 15:37:38 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.c (require_libraries): req_list may be NULL. [ruby-dev:35008]
|
||||
|
19
io.c
19
io.c
@ -2673,6 +2673,7 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
|
||||
static void
|
||||
fptr_finalize(rb_io_t *fptr, int noraise)
|
||||
{
|
||||
int ebadf = 0;
|
||||
if (fptr->wbuf_len) {
|
||||
io_fflush(fptr);
|
||||
}
|
||||
@ -2690,13 +2691,22 @@ fptr_finalize(rb_io_t *fptr, int noraise)
|
||||
}
|
||||
else if (0 <= fptr->fd) {
|
||||
if (close(fptr->fd) < 0 && !noraise) {
|
||||
/* fptr->fd is still not closed */
|
||||
rb_sys_fail(fptr->path);
|
||||
if (errno != EBADF) {
|
||||
/* fptr->fd is still not closed */
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
else {
|
||||
/* fptr->fd is already closed. */
|
||||
ebadf = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
fptr->fd = -1;
|
||||
fptr->stdio_file = 0;
|
||||
fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
|
||||
if (ebadf) {
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4750,8 +4760,9 @@ rb_f_puts(int argc, VALUE *argv, VALUE recv)
|
||||
void
|
||||
rb_p(VALUE obj) /* for debug print within C code */
|
||||
{
|
||||
rb_io_write(rb_stdout, rb_obj_as_string(rb_inspect(obj)));
|
||||
rb_io_write(rb_stdout, rb_default_rs);
|
||||
VALUE str = rb_obj_as_string(rb_inspect(obj));
|
||||
rb_str_buf_append(str, rb_default_rs);
|
||||
rb_io_write(rb_stdout, str);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user