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

ruby-changes:7246

From: akr <ko1@a...>
Date: Fri, 22 Aug 2008 05:13:46 +0900 (JST)
Subject: [ruby-changes:7246] Ruby:r18765 (trunk): * io.c (rb_file_open_generic): take filename as a VALUE.

akr	2008-08-22 05:12:29 +0900 (Fri, 22 Aug 2008)

  New Revision: 18765

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

  Log:
    * io.c (rb_file_open_generic): take filename as a VALUE.
      (rb_file_open_internal): ditto.
      (rb_io_open): ditto.
      (rb_file_open): pass filename as a VALUE to rb_file_open_internal.
      (rb_open_file): pass filename as a VALUE to rb_file_open_generic.
      (open_key_args): pass filename as a VALUE to rb_io_open.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18764)
+++ ChangeLog	(revision 18765)
@@ -1,3 +1,12 @@
+Fri Aug 22 05:10:07 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (rb_file_open_generic): take filename as a VALUE.
+	  (rb_file_open_internal): ditto.
+	  (rb_io_open): ditto.
+	  (rb_file_open): pass filename as a VALUE to rb_file_open_internal.
+	  (rb_open_file): pass filename as a VALUE to rb_file_open_generic.
+	  (open_key_args): pass filename as a VALUE to rb_io_open.
+
 Fri Aug 22 04:33:56 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/ruby.h: fix previous change for LP64.
Index: io.c
===================================================================
--- io.c	(revision 18764)
+++ io.c	(revision 18765)
@@ -3948,7 +3948,7 @@
 }
 
 static VALUE
-rb_file_open_generic(VALUE io, const char *fname, int modenum, int flags, convconfig_t *convconfig, mode_t perm)
+rb_file_open_generic(VALUE io, VALUE filename, int modenum, int flags, convconfig_t *convconfig, mode_t perm)
 {
     rb_io_t *fptr;
 
@@ -3962,7 +3962,7 @@
         fptr->enc = NULL;
         fptr->enc2 = NULL;
     }
-    fptr->path = strdup(fname);
+    fptr->path = strdup(RSTRING_PTR(filename));
     fptr->fd = rb_sysopen(fptr->path, modenum, perm);
     io_check_tty(fptr);
 
@@ -3970,7 +3970,7 @@
 }
 
 static VALUE
-rb_file_open_internal(VALUE io, const char *fname, const char *mode)
+rb_file_open_internal(VALUE io, VALUE filename, const char *mode)
 {
     int flags;
 
@@ -3985,7 +3985,7 @@
     }
 
     flags = rb_io_mode_flags(mode);
-    return rb_file_open_generic(io, fname,
+    return rb_file_open_generic(io, filename,
             rb_io_flags_modenum(flags),
             flags,
             &convconfig,
@@ -3995,7 +3995,7 @@
 VALUE
 rb_file_open(const char *fname, const char *mode)
 {
-    return rb_file_open_internal(io_alloc(rb_cFile), fname, mode);
+    return rb_file_open_internal(io_alloc(rb_cFile), rb_str_new_cstr(fname), mode);
 }
 
 #if defined(__CYGWIN__) || !defined(HAVE_FORK)
@@ -4579,7 +4579,7 @@
     mode_t perm;
 
     rb_scan_open_args(argc, argv, &fname, &modenum, &flags, &convconfig, &perm);
-    rb_file_open_generic(io, RSTRING_PTR(fname), modenum, flags, &convconfig, perm);
+    rb_file_open_generic(io, fname, modenum, flags, &convconfig, perm);
 
     return io;
 }
@@ -4795,8 +4795,9 @@
 }
 
 static VALUE
-rb_io_open(const char *fname, VALUE mode, VALUE opt)
+rb_io_open(VALUE filename, VALUE mode, VALUE opt)
 {
+    char *fname = RSTRING_PTR(filename);
     int modenum, flags;
     convconfig_t convconfig;
     rb_io_extract_modeenc(&mode, opt, &modenum, &flags, &convconfig);
@@ -4806,7 +4807,7 @@
 	return pipe_open_s(cmd, rb_io_modenum_mode(modenum), flags, &convconfig);
     }
     else {
-        return rb_file_open_generic(io_alloc(rb_cFile), fname,
+        return rb_file_open_generic(io_alloc(rb_cFile), filename,
                 modenum, flags, &convconfig, 0666);
     }
 }
@@ -6700,7 +6701,7 @@
     arg->argv = argv + 1;
     if (argc == 1) {
       no_key:
-	arg->io = rb_io_open(RSTRING_PTR(argv[0]), INT2NUM(O_RDONLY), Qnil);
+	arg->io = rb_io_open(argv[0], INT2NUM(O_RDONLY), Qnil);
 	return;
     }
     opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
@@ -6722,7 +6723,7 @@
     v = rb_hash_aref(opt, sym_mode);
     if (NIL_P(v))
         v = INT2NUM(O_RDONLY);
-    arg->io = rb_io_open(RSTRING_PTR(argv[0]), v, opt);
+    arg->io = rb_io_open(argv[0], v, opt);
 }
 
 static VALUE

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

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