summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-16 06:03:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-16 06:03:36 +0000
commitbcab5ca9d1b50cc940d3c2cf190c6ef18a20f3d0 (patch)
treefbb231b10c7092bef845762c8ea4434e851088a6 /hash.c
parentf96faa860bfaf119ed379db160c24bd815376fd1 (diff)
prepare to alpha
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/hash.c b/hash.c
index 34b02df..69e6eb3 100644
--- a/hash.c
+++ b/hash.c
@@ -241,17 +241,23 @@ rb_hash_s_create(argc, argv, klass)
VALUE hash;
int i;
- if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- NEWOBJ(hash, struct RHash);
- OBJSETUP(hash, klass, T_HASH);
+ if (argc == 1) {
+ if (TYPE(argv[0]) == T_HASH) {
+ NEWOBJ(hash, struct RHash);
+ OBJSETUP(hash, klass, T_HASH);
- hash->iter_lev = 0;
- hash->ifnone = Qnil;
- hash->tbl = 0; /* avoid GC crashing */
- hash->tbl = (st_table*)st_copy(RHASH(argv[0])->tbl);
- rb_obj_call_init((VALUE)hash, argc, argv);
+ hash->iter_lev = 0;
+ hash->ifnone = Qnil;
+ hash->tbl = 0; /* avoid GC crashing */
+ hash->tbl = st_copy(RHASH(argv[0])->tbl);
+ rb_obj_call_init((VALUE)hash, argc, argv);
- return (VALUE)hash;
+ return (VALUE)hash;
+ }
+ else {
+ VALUE a = rb_Array(argv[0]);
+ return rb_hash_s_create(RARRAY(a)->len, RARRAY(a)->ptr, klass);
+ }
}
if (argc % 2 != 0) {