mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
e3640bc7b8
commit
dd09dfe3f0
2 changed files with 34 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue