summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-12 07:39:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-12 07:39:12 +0000
commit1f99d95729fd18bf3dc98cf9eea62df6b8353e40 (patch)
treec6552503cdefea1749c7252d551911170c05e255 /hash.c
parent66f8f8691b2f63428c2e0fbf95f794443ce89e18 (diff)
* bignum.c (rb_big_cmp): use dbl2big() for Floats, instead of
big2dbl(). * bignum.c (Init_Bignum): rb_big_zero_p() removed. There may be Bignum zero. * eval.c (rb_call0): new argument added for original method name. preserve original method name in frame->orig_func. * eval.c (is_defined): use frame->orig_func, not last_func. * eval.c (rb_eval): ditto. * eval.c (method_call): supply data->oid also to rb_call0(). * object.c (rb_class_allocate_instance): call rb_obj_alloc() when called from alias, thus invoke original "allocate". * eval.c (remove_method): removing allocate from classes should cause NameError. * hash.c (rb_hash_equal): should check default values. * ext/socket/socket.c (s_recvfrom): update RSTRING len. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 5cc3638..98bf342 100644
--- a/hash.c
+++ b/hash.c
@@ -24,6 +24,7 @@ static void
rb_hash_modify(hash)
VALUE hash;
{
+ if (!RHASH(hash)->tbl) rb_raise(rb_eTypeError, "uninitialized Hash");
if (OBJ_FROZEN(hash)) rb_error_frozen("hash");
if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
@@ -226,7 +227,7 @@ rb_hash_s_create(argc, argv, klass)
int i;
if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- VALUE hash = rb_obj_alloc(klass);
+ hash = rb_obj_alloc(klass);
RHASH(hash)->ifnone = Qnil;
RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl);
@@ -237,8 +238,8 @@ rb_hash_s_create(argc, argv, klass)
if (argc % 2 != 0) {
rb_raise(rb_eArgError, "odd number args for Hash");
}
- hash = rb_hash_s_alloc(klass);
+ hash = rb_obj_alloc(klass);
for (i=0; i<argc; i+=2) {
rb_hash_aset(hash, argv[i], argv[i + 1]);
}
@@ -280,6 +281,7 @@ rb_hash_rehash(hash)
{
st_table *tbl;
+ rb_hash_modify(hash);
tbl = st_init_table_with_size(&objhash, RHASH(hash)->tbl->num_entries);
st_foreach(RHASH(hash)->tbl, rb_hash_rehash_i, tbl);
st_free_table(RHASH(hash)->tbl);
@@ -852,6 +854,8 @@ rb_hash_equal(hash1, hash2)
if (TYPE(hash2) != T_HASH) return Qfalse;
if (RHASH(hash1)->tbl->num_entries != RHASH(hash2)->tbl->num_entries)
return Qfalse;
+ if (!rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone))
+ return Qfalse;
data.tbl = RHASH(hash2)->tbl;
data.result = Qtrue;