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

ruby-changes:7179

From: akr <ko1@a...>
Date: Tue, 19 Aug 2008 01:04:26 +0900 (JST)
Subject: [ruby-changes:7179] Ruby:r18698 (trunk): * io.c (rb_open_file): don't access argv[-1] by

akr	2008-08-19 01:04:09 +0900 (Tue, 19 Aug 2008)

  New Revision: 18698

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

  Log:
    * io.c (rb_open_file): don't access argv[-1] by 
      File.allocate.instance_eval { initialize }.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18697)
+++ ChangeLog	(revision 18698)
@@ -1,3 +1,8 @@
+Tue Aug 19 01:02:19 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (rb_open_file): don't access argv[-1] by 
+	  File.allocate.instance_eval { initialize }.
+
 Tue Aug 19 00:56:01 2008  Tanaka Akira  <akr@f...>
 
 	* re.c (rb_reg_inspect): don't raise for uninitialized Regexp.
Index: io.c
===================================================================
--- io.c	(revision 18697)
+++ io.c	(revision 18698)
@@ -4461,14 +4461,16 @@
     int flags;
     unsigned int fmode;
 
-    opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
-    if (!NIL_P(opt)) {
-	VALUE v;
-	v = rb_hash_aref(opt, sym_mode);
-	if (!NIL_P(v)) vmode = v;
-	v = rb_hash_aref(opt, sym_perm);
-	if (!NIL_P(v)) perm = v;
-	argc -= 1;
+    if (0 < argc) {
+        opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
+        if (!NIL_P(opt)) {
+            VALUE v;
+            v = rb_hash_aref(opt, sym_mode);
+            if (!NIL_P(v)) vmode = v;
+            v = rb_hash_aref(opt, sym_perm);
+            if (!NIL_P(v)) perm = v;
+            argc -= 1;
+        }
     }
 
     rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);

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

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