ruby-changes:4716
From: ko1@a...
Date: Sat, 26 Apr 2008 21:52:42 +0900 (JST)
Subject: [ruby-changes:4716] akr - Ruby:r16210 (trunk): * include/ruby/intern.h (rb_hash_dup): declared.
akr 2008-04-26 21:52:25 +0900 (Sat, 26 Apr 2008)
New Revision: 16210
Modified files:
trunk/ChangeLog
trunk/hash.c
trunk/include/ruby/intern.h
trunk/process.c
trunk/test/ruby/test_process.rb
Log:
* include/ruby/intern.h (rb_hash_dup): declared.
* hash.c (rb_hash_dup): new function.
* process.c (rb_spawn_internal): don't modify option hash.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/hash.c?r1=16210&r2=16209&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_process.rb?r1=16210&r2=16209&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16210&r2=16209&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/process.c?r1=16210&r2=16209&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=16210&r2=16209&diff_format=u
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h (revision 16209)
+++ include/ruby/intern.h (revision 16210)
@@ -344,6 +344,7 @@
void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
VALUE rb_hash(VALUE);
VALUE rb_hash_new(void);
+VALUE rb_hash_dup(VALUE);
VALUE rb_hash_freeze(VALUE);
VALUE rb_hash_aref(VALUE, VALUE);
VALUE rb_hash_lookup(VALUE, VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16209)
+++ ChangeLog (revision 16210)
@@ -1,3 +1,11 @@
+Sat Apr 26 21:30:40 2008 Tanaka Akira <akr@f...>
+
+ * include/ruby/intern.h (rb_hash_dup): declared.
+
+ * hash.c (rb_hash_dup): new function.
+
+ * process.c (rb_spawn_internal): don't modify option hash.
+
Sat Apr 26 18:36:31 2008 Nobuyoshi Nakada <nobu@r...>
* io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
Index: process.c
===================================================================
--- process.c (revision 16209)
+++ process.c (revision 16210)
@@ -2560,6 +2560,10 @@
opthash = rb_hash_new();
RBASIC(opthash)->klass = 0;
}
+ if (RBASIC(opthash)->klass) {
+ opthash = rb_hash_dup(opthash);
+ RBASIC(opthash)->klass = 0;
+ }
if (!st_lookup(RHASH_TBL(opthash), close_others, 0))
rb_hash_aset(opthash, close_others, Qtrue);
}
Index: hash.c
===================================================================
--- hash.c (revision 16209)
+++ hash.c (revision 16210)
@@ -228,6 +228,19 @@
return hash_alloc(rb_cHash);
}
+VALUE
+rb_hash_dup(VALUE hash)
+{
+ VALUE ret = hash_alloc(RBASIC(hash)->klass);
+ if (!RHASH_EMPTY_P(hash))
+ RHASH(ret)->ntbl = st_copy(RHASH(hash)->ntbl);
+ if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
+ FL_SET(ret, HASH_PROC_DEFAULT);
+ }
+ RHASH(ret)->ifnone = RHASH(hash)->ifnone;
+ return ret;
+}
+
static void
rb_hash_modify_check(VALUE hash)
{
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb (revision 16209)
+++ test/ruby/test_process.rb (revision 16210)
@@ -500,6 +500,21 @@
}
end
+ def test_execopts_modification
+ h = {}
+ Process.wait spawn(EnvUtil.rubybin, '-e', '', h)
+ assert_equal({}, h)
+
+ h = {}
+ system(EnvUtil.rubybin, '-e', '', h)
+ assert_equal({}, h)
+
+ h = {}
+ io = IO.popen([EnvUtil.rubybin, '-e', '', h])
+ io.close
+ assert_equal({}, h)
+ end
+
def test_system
str = "echo fofo"
assert_nil(system([str, str]))
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/