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

ruby-changes:24103

From: akr <ko1@a...>
Date: Wed, 20 Jun 2012 21:28:23 +0900 (JST)
Subject: [ruby-changes:24103] akr:r36154 (trunk): * internal.h (struct rb_execarg): add umask_given and umask_mask

akr	2012-06-20 21:27:09 +0900 (Wed, 20 Jun 2012)

  New Revision: 36154

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

  Log:
    * internal.h (struct rb_execarg): add umask_given and umask_mask
      fields.
    
    * process.c (STATIC_ASSERT): removed.
      (rb_execarg_addopt): follow the rb_execarg change.
      (rb_execarg_run_options): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36153)
+++ ChangeLog	(revision 36154)
@@ -1,3 +1,12 @@
+Wed Jun 20 21:25:37 2012  Tanaka Akira  <akr@f...>
+
+	* internal.h (struct rb_execarg): add umask_given and umask_mask
+	  fields.
+
+	* process.c (STATIC_ASSERT): removed.
+	  (rb_execarg_addopt): follow the rb_execarg change.
+	  (rb_execarg_run_options): ditto.
+
 Wed Jun 20 20:38:23 2012  Tanaka Akira  <akr@f...>
 
 	* internal.h (struct rb_execarg) moved and renamed from
Index: process.c
===================================================================
--- process.c	(revision 36153)
+++ process.c	(revision 36154)
@@ -17,8 +17,6 @@
 #include "internal.h"
 #include "vm_core.h"
 
-#define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
-
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
@@ -1261,7 +1259,6 @@
     EXEC_OPTION_UNSETENV_OTHERS,
     EXEC_OPTION_ENV,
     EXEC_OPTION_CHDIR,
-    EXEC_OPTION_UMASK,
     EXEC_OPTION_DUP2,
     EXEC_OPTION_CLOSE,
     EXEC_OPTION_OPEN,
@@ -1633,12 +1630,12 @@
                                   hide_obj(rb_str_dup(val)));
         }
         else if (id == rb_intern("umask")) {
-	    STATIC_ASSERT(sizeof_mode_t, sizeof(long) >= sizeof(mode_t)); /* for LONG2NUM */
 	    mode_t cmask = NUM2MODET(val);
-            if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_UMASK))) {
+            if (e->umask_given) {
                 rb_raise(rb_eArgError, "umask option specified twice");
             }
-            rb_ary_store(options, EXEC_OPTION_UMASK, LONG2FIX(cmask));
+            e->umask_given = 1;
+            e->umask_mask = cmask;
         }
         else if (id == rb_intern("close_others")) {
             if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS))) {
@@ -2767,12 +2764,13 @@
     }
 #endif
 
-    obj = rb_ary_entry(options, EXEC_OPTION_UMASK);
-    if (!NIL_P(obj)) {
-        mode_t mask = (mode_t)FIX2LONG(obj); /* no method calls */
+    if (e->umask_given) {
+        mode_t mask = e->umask_mask;
         mode_t oldmask = umask(mask); /* never fail */ /* async-signal-safe */
-        if (!NIL_P(soptions))
-            rb_ary_store(soptions, EXEC_OPTION_UMASK, MODET2NUM(oldmask));
+        if (s) {
+            s->umask_given = 1;
+            s->umask_mask = oldmask;
+        }
     }
 
     obj = rb_ary_entry(options, EXEC_OPTION_DUP2);
Index: internal.h
===================================================================
--- internal.h	(revision 36153)
+++ internal.h	(revision 36154)
@@ -177,6 +177,8 @@
     VALUE envp_str;
     VALUE envp_buf;
     VALUE dup2_tmpbuf;
+    unsigned umask_given : 1;
+    mode_t umask_mask;
 };
 
 /* argv_str contains extra two elements.

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

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