* encoding.c (enc_alias_internal): use st_insert2 and change return
value to int. * encoding.c (enc_alias): follow enc_alias_internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3010758245
commit
e59b9e9e43
@ -1,3 +1,10 @@
|
|||||||
|
Fri Dec 3 04:08:59 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* encoding.c (enc_alias_internal): use st_insert2 and change return
|
||||||
|
value to int.
|
||||||
|
|
||||||
|
* encoding.c (enc_alias): follow enc_alias_internal.
|
||||||
|
|
||||||
Fri Dec 3 01:52:43 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Fri Dec 3 01:52:43 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* encoding.c (enc_alias_internal): use xfree instead of free.
|
* encoding.c (enc_alias_internal): use xfree instead of free.
|
||||||
|
14
encoding.c
14
encoding.c
@ -440,23 +440,19 @@ rb_enc_unicode_p(rb_encoding *enc)
|
|||||||
* Returns copied alias name when the key is added for st_table,
|
* Returns copied alias name when the key is added for st_table,
|
||||||
* else returns NULL.
|
* else returns NULL.
|
||||||
*/
|
*/
|
||||||
static const char *
|
static int
|
||||||
enc_alias_internal(const char *alias, int idx)
|
enc_alias_internal(const char *alias, int idx)
|
||||||
{
|
{
|
||||||
char *name = strdup(alias);
|
return st_insert2(enc_table.names, (st_data_t)alias, (st_data_t)idx,
|
||||||
if (st_insert(enc_table.names, (st_data_t)name, (st_data_t)idx)) {
|
(st_data_t(*)(st_data_t))strdup);
|
||||||
xfree(name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
enc_alias(const char *alias, int idx)
|
enc_alias(const char *alias, int idx)
|
||||||
{
|
{
|
||||||
if (!valid_encoding_name_p(alias)) return -1;
|
if (!valid_encoding_name_p(alias)) return -1;
|
||||||
alias = enc_alias_internal(alias, idx);
|
if (!enc_alias_internal(alias, idx))
|
||||||
if (alias) set_encoding_const(alias, rb_enc_from_index(idx));
|
set_encoding_const(alias, rb_enc_from_index(idx));
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user