ruby-changes:7241
From: akr <ko1@a...>
Date: Fri, 22 Aug 2008 03:02:13 +0900 (JST)
Subject: [ruby-changes:7241] Ruby:r18760 (trunk): * io.c (rb_io_extract_modeenc): notify coerced to caller.
akr 2008-08-22 02:58:50 +0900 (Fri, 22 Aug 2008) New Revision: 18760 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18760 Log: * io.c (rb_io_extract_modeenc): notify coerced to caller. (rb_io_initialize): mode may be a Bignum. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18759) +++ ChangeLog (revision 18760) @@ -1,3 +1,8 @@ +Fri Aug 22 02:57:03 2008 Tanaka Akira <akr@f...> + + * io.c (rb_io_extract_modeenc): notify coerced to caller. + (rb_io_initialize): mode may be a Bignum. + Fri Aug 22 02:42:35 2008 Tanaka Akira <akr@f...> * io.c (rb_io_extract_modeenc): use rb_check_to_integer to test Index: io.c =================================================================== --- io.c (revision 18759) +++ io.c (revision 18760) @@ -3807,14 +3807,17 @@ } convconfig_t; static void -rb_io_extract_modeenc(VALUE mode, VALUE opthash, +rb_io_extract_modeenc(VALUE *mode_p, VALUE opthash, int *modenum_p, int *flags_p, convconfig_t *convconfig_p) { + VALUE mode; int modenum, flags; rb_encoding *enc, *enc2; int has_enc = 0; VALUE intmode; + mode = *mode_p; + enc = NULL; enc2 = NULL; @@ -3823,6 +3826,7 @@ modenum = O_RDONLY; } else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) { + mode = intmode; modenum = NUM2INT(intmode); flags = rb_io_modenum_flags(modenum); } @@ -3847,6 +3851,8 @@ } } + *mode_p = mode; + *modenum_p = modenum; *flags_p = flags; convconfig_p->enc = enc; @@ -4485,7 +4491,7 @@ opt = pop_last_hash(&argc, &argv); rb_scan_args(argc, argv, "11", &pname, &pmode); - rb_io_extract_modeenc(pmode, opt, &modenum, &flags, &convconfig); + rb_io_extract_modeenc(&pmode, opt, &modenum, &flags, &convconfig); mode = rb_io_modenum_mode(modenum); tmp = rb_check_array_type(pname); @@ -4554,7 +4560,7 @@ #endif FilePathValue(fname); - rb_io_extract_modeenc(vmode, opt, &modenum, &flags, convconfig_p); + rb_io_extract_modeenc(&vmode, opt, &modenum, &flags, convconfig_p); perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm); @@ -4790,7 +4796,7 @@ { int modenum, flags; convconfig_t convconfig; - rb_io_extract_modeenc(mode, opt, &modenum, &flags, &convconfig); + rb_io_extract_modeenc(&mode, opt, &modenum, &flags, &convconfig); if (fname[0] == '|') { VALUE cmd = rb_str_new2(fname+1); @@ -5480,7 +5486,7 @@ opt = pop_last_hash(&argc, &argv); rb_scan_args(argc, argv, "11", &fnum, &mode); - rb_io_extract_modeenc(mode, opt, &modenum, &flags, &convconfig); + rb_io_extract_modeenc(&mode, opt, &modenum, &flags, &convconfig); orig = rb_io_check_io(fnum); if (NIL_P(orig)) { fd = NUM2INT(fnum); @@ -5511,7 +5517,7 @@ } if (!NIL_P(mode)) { if ((ofp->mode ^ flags) & (FMODE_READWRITE|FMODE_BINMODE)) { - if (FIXNUM_P(mode)) { + if (TYPE(mode) != T_STRING) { rb_raise(rb_eArgError, "incompatible mode 0x%x", modenum); } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/