diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | io.c | 7 |
2 files changed, 9 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Fri Aug 22 02:42:35 2008 Tanaka Akira <akr@fsij.org> + + * io.c (rb_io_extract_modeenc): use rb_check_to_integer to test + integer. + Fri Aug 22 02:25:04 2008 Tanaka Akira <akr@fsij.org> * iseq.c (iseq_inspect): don't raise on uninitialized object. @@ -3813,6 +3813,7 @@ rb_io_extract_modeenc(VALUE mode, VALUE opthash, int modenum, flags; rb_encoding *enc, *enc2; int has_enc = 0; + VALUE intmode; enc = NULL; enc2 = NULL; @@ -3821,11 +3822,11 @@ rb_io_extract_modeenc(VALUE mode, VALUE opthash, flags = FMODE_READABLE; modenum = O_RDONLY; } - else if (FIXNUM_P(mode)) { - modenum = FIX2INT(mode); + else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) { + modenum = NUM2INT(intmode); flags = rb_io_modenum_flags(modenum); } - else { /* xxx: Bignum, to_int */ + else { const char *p; SafeStringValue(mode); p = StringValueCStr(mode); |
