summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-07 08:48:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-07 08:48:30 +0000
commit2b5a14bf7c96fcda9ff6cd9bbdd83d9294a0d354 (patch)
tree1c5e740fcd47bdb4adeefd007c7e393054eff8f2 /io.c
parent4d372569d874b10db980fe4bd10bf8cfee585a55 (diff)
* eval.c (rb_eval): too many line trace call. (ruby-bugs PR#1320)
* numeric.c (flo_to_s): tweak output string based to preserve decimal point and to remove trailing zeros. [ruby-talk:97891] * string.c (rb_str_index_m): use unsigned comparison for T_FIXNUM search. [ruby-talk:97342] * hash.c (rb_hash_equal): returns true if two hashes have same set of key-value set. [ruby-talk:97559] * hash.c (rb_hash_eql): returns true if two hashes are equal and have same default values. * string.c (rb_str_equal): always returns true or false, never returns nil. [ruby-dev:23404] * io.c (rb_io_reopen): should use rb_io_check_io(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/io.c b/io.c
index 4e74f6f859..0b094ca99e 100644
--- a/io.c
+++ b/io.c
@@ -2368,16 +2368,29 @@ rb_fdopen(fd, mode)
{
FILE *file;
+#if defined(sun)
+ errno = 0;
+#endif
file = fdopen(fd, mode);
if (!file) {
+#if defined(sun)
+ if (errno == 0 || errno == EMFILE || errno == ENFILE) {
+#else
if (errno == EMFILE || errno == ENFILE) {
+#endif
rb_gc();
+#if defined(sun)
+ errno = 0;
+#endif
file = fdopen(fd, mode);
}
if (!file) {
#ifdef _WIN32
if (errno == 0) errno = EINVAL;
#endif
+#if defined(sun)
+ if (errno == 0) errno = EMFILE;
+#endif
rb_sys_fail(0);
}
}
@@ -2993,6 +3006,13 @@ rb_io_get_io(io)
return rb_convert_type(io, T_FILE, "IO", "to_io");
}
+static VALUE
+rb_io_check_io(io)
+ VALUE io;
+{
+ return rb_check_convert_type(io, T_FILE, "IO", "to_io");
+}
+
static char*
rb_io_mode_string(fptr)
OpenFile *fptr;
@@ -3122,8 +3142,9 @@ rb_io_reopen(argc, argv, file)
rb_secure(4);
if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
- if (TYPE(fname) != T_STRING) { /* fname must be IO */
- return io_reopen(file, fname);
+ VALUE tmp = rb_io_check_io(fname);
+ if (!NIL_P(tmp)) {
+ return io_reopen(file, tmp);
}
}