summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-26 12:52:25 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-26 12:52:25 +0000
commit514715250a2a4d69ea0a4ce3123e2e2f558f3109 (patch)
treec8b543090edb6016a11fda3b22c55b4eb5b01cea /hash.c
parent6fb36ebab0644f2b724b144b0a163148c87298aa (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 006b5f85d8..89c470f9e4 100644
--- a/hash.c
+++ b/hash.c
@@ -228,6 +228,19 @@ rb_hash_new(void)
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)
{