mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* encoding.c (rb_enc_name_list_i, rb_enc_aliases_enc_i): freeze
element strings to be returned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4d1ee83e3c
commit
b66eb53650
2 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Jan 18 15:56:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* encoding.c (rb_enc_name_list_i, rb_enc_aliases_enc_i): freeze
|
||||||
|
element strings to be returned.
|
||||||
|
|
||||||
Fri Jan 18 14:36:34 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
Fri Jan 18 14:36:34 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||||
|
|
||||||
* test/ruby/test_m17n.rb (test_str_dump): added test for
|
* test/ruby/test_m17n.rb (test_str_dump): added test for
|
||||||
|
|
14
encoding.c
14
encoding.c
|
@ -1112,7 +1112,9 @@ static int
|
||||||
rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
|
rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
|
||||||
{
|
{
|
||||||
VALUE ary = (VALUE)arg;
|
VALUE ary = (VALUE)arg;
|
||||||
rb_ary_push(ary, rb_str_new2((char *)name));
|
VALUE str = rb_str_new2((char *)name);
|
||||||
|
OBJ_FREEZE(str);
|
||||||
|
rb_ary_push(ary, str);
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,10 +1146,9 @@ static int
|
||||||
rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
|
rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
|
||||||
{
|
{
|
||||||
VALUE *p = (VALUE *)arg;
|
VALUE *p = (VALUE *)arg;
|
||||||
VALUE aliases = p[0];
|
VALUE aliases = p[0], ary = p[1];
|
||||||
VALUE ary = p[1];
|
|
||||||
int idx = (int)orig;
|
int idx = (int)orig;
|
||||||
VALUE str = rb_ary_entry(ary, idx);
|
VALUE key, str = rb_ary_entry(ary, idx);
|
||||||
|
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
rb_encoding *enc = rb_enc_from_index(idx);
|
rb_encoding *enc = rb_enc_from_index(idx);
|
||||||
|
@ -1156,9 +1157,12 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
str = rb_str_new2(rb_enc_name(enc));
|
str = rb_str_new2(rb_enc_name(enc));
|
||||||
|
OBJ_FREEZE(str);
|
||||||
rb_ary_store(ary, idx, str);
|
rb_ary_store(ary, idx, str);
|
||||||
}
|
}
|
||||||
rb_hash_aset(aliases, rb_str_new2((char *)name), str);
|
key = rb_str_new2((char *)name);
|
||||||
|
OBJ_FREEZE(key);
|
||||||
|
rb_hash_aset(aliases, key, str);
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue