summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-19 07:13:28 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-19 07:13:28 +0000
commitdd09dfe3f0bc975db4b84a0e563bcdf862a7063b (patch)
tree9466763d71dca9be88c5f3673681d8a3aa6f881a
parente3640bc7b8d201c3e54d32bdb79db41977eeb50f (diff)
* ext/tk/tkutil.c: backport from CVS HEAD
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/tk/tkutil.c43
2 files changed, 34 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 2738d4f..46d787f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Oct 19 16:12:18 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/tkutil.c: backport from CVS HEAD
+
Tue Oct 19 08:54:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* intern.h, object.c (rb_class_inherited_p): export.
diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c
index 7e62640..04d276c 100644
--- a/ext/tk/tkutil.c
+++ b/ext/tk/tkutil.c
@@ -198,15 +198,26 @@ fromUTF8_toDefaultEnc(str, self)
}
+static void
+hash_check(err)
+ int err;
+{
+ if (err) {
+ rb_raise(rb_eRuntimeError, "hash modified");
+ }
+}
+
static int
-to_strkey(key, value, hash)
+to_strkey(key, value, hash, err)
VALUE key;
VALUE value;
VALUE hash;
+ int err;
{
+ hash_check(err);
if (key == Qundef) return ST_CONTINUE;
rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value);
- return ST_CONTINUE;
+ return ST_CHECK;
}
static VALUE
@@ -217,9 +228,7 @@ tk_symbolkey2str(self, keys)
volatile VALUE new_keys = rb_hash_new();
if NIL_P(keys) return new_keys;
- if (TYPE(keys) != T_HASH) {
- rb_raise(rb_eArgError, "Hash is expected");
- }
+ keys = rb_convert_type(keys, T_HASH, "Hash", "to_hash");
st_foreach(RHASH(keys)->tbl, to_strkey, new_keys);
return new_keys;
}
@@ -438,12 +447,16 @@ assoc2kv_enc(assoc, ary, self)
}
static int
-push_kv(key, val, args)
+push_kv(key, val, args, err)
VALUE key;
VALUE val;
VALUE args;
+ int err;
{
- volatile VALUE ary = RARRAY(args)->ptr[0];
+ volatile VALUE ary;
+
+ hash_check(err);
+ ary = RARRAY(args)->ptr[0];
if (key == Qundef) return ST_CONTINUE;
#if 0
@@ -452,12 +465,12 @@ push_kv(key, val, args)
#endif
RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key);
- if (val == TK_None) return ST_CONTINUE;
+ if (val == TK_None) return ST_CHECK;
RARRAY(ary)->ptr[RARRAY(ary)->len++]
= get_eval_string_core(val, Qnil, RARRAY(args)->ptr[1]);
- return ST_CONTINUE;
+ return ST_CHECK;
}
static VALUE
@@ -484,12 +497,16 @@ hash2kv(hash, ary, self)
}
static int
-push_kv_enc(key, val, args)
+push_kv_enc(key, val, args, err)
VALUE key;
VALUE val;
VALUE args;
+ int err;
{
- volatile VALUE ary = RARRAY(args)->ptr[0];
+ volatile VALUE ary;
+
+ hash_check(err);
+ ary = RARRAY(args)->ptr[0];
if (key == Qundef) return ST_CONTINUE;
#if 0
@@ -501,12 +518,12 @@ push_kv_enc(key, val, args)
#endif
RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key);
- if (val == TK_None) return ST_CONTINUE;
+ if (val == TK_None) return ST_CHECK;
RARRAY(ary)->ptr[RARRAY(ary)->len++]
= get_eval_string_core(val, Qtrue, RARRAY(args)->ptr[1]);
- return ST_CONTINUE;
+ return ST_CHECK;
}
static VALUE