[前][次][番号順一覧][スレッド一覧]

ruby-changes:7211

From: akr <ko1@a...>
Date: Wed, 20 Aug 2008 23:56:39 +0900 (JST)
Subject: [ruby-changes:7211] Ruby:r18730 (trunk): * io.c (io_set_encoding): removed.

akr	2008-08-20 23:56:23 +0900 (Wed, 20 Aug 2008)

  New Revision: 18730

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18730

  Log:
    * io.c (io_set_encoding): removed.
      (rb_io_open): set up encoding using new argument opt.
      (open_key_args): call rb_io_open with opt.  don't call
      io_set_encoding.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18729)
+++ ChangeLog	(revision 18730)
@@ -1,3 +1,10 @@
+Wed Aug 20 23:53:42 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (io_set_encoding): removed.
+	  (rb_io_open): set up encoding using new argument opt.
+	  (open_key_args): call rb_io_open with opt.  don't call
+	  io_set_encoding.
+
 Wed Aug 20 22:30:33 2008  Tanaka Akira  <akr@f...>
 
 	* io.c (rb_file_open_internal): use rb_io_flags_modenum.
Index: io.c
===================================================================
--- io.c	(revision 18729)
+++ io.c	(revision 18730)
@@ -4510,20 +4510,6 @@
 }
 
 static void
-io_set_encoding(VALUE io, VALUE opt)
-{
-    rb_io_t *fptr;
-    rb_encoding *enc, *enc2;
-
-    if (io_extract_encoding_option(opt, &enc, &enc2)) {
-        GetOpenFile(io, fptr);
-        fptr->enc = enc;
-        fptr->enc2 = enc2;
-        clear_codeconv(fptr);
-    }
-}
-
-static void
 rb_scan_open_args(int argc, VALUE *argv,
         VALUE *fname_p, int *modenum_p, int *flags_p,
         convconfig_t *convconfig_p, unsigned int *fmode_p)
@@ -4793,14 +4779,19 @@
 }
 
 static VALUE
-rb_io_open(const char *fname, const char *mode)
+rb_io_open(const char *fname, VALUE mode, VALUE opt)
 {
+    int modenum, flags;
+    convconfig_t convconfig;
+    rb_io_extract_modeenc(mode, opt, &modenum, &flags, &convconfig);
+
     if (fname[0] == '|') {
 	VALUE cmd = rb_str_new2(fname+1);
-	return pipe_open_s(cmd, mode);
+	return pipe_open_s(cmd, rb_io_modenum_mode(modenum));
     }
     else {
-        return rb_file_open_internal(io_alloc(rb_cFile), fname, mode);
+        return rb_file_open_generic(io_alloc(rb_cFile), fname,
+                modenum, flags, &convconfig, 0666);
     }
 }
 
@@ -6691,7 +6682,7 @@
     arg->argv = argv + 1;
     if (argc == 1) {
       no_key:
-	arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r");
+	arg->io = rb_io_open(RSTRING_PTR(argv[0]), INT2NUM(O_RDONLY), Qnil);
 	return;
     }
     opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
@@ -6713,13 +6704,11 @@
     }
     v = rb_hash_aref(opt, sym_mode);
     if (!NIL_P(v)) {
-	arg->io = rb_io_open(RSTRING_PTR(argv[0]), StringValueCStr(v));
+	arg->io = rb_io_open(RSTRING_PTR(argv[0]), v, opt);
     }
     else {
-	arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r");
+	arg->io = rb_io_open(RSTRING_PTR(argv[0]), INT2NUM(O_RDONLY), opt);
     }
-
-    io_set_encoding(arg->io, opt);
 }
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]