diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-08 15:35:16 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-08 15:35:16 +0000 |
commit | ff3f19a16ce2c65fd198067a7f74470200bca3e3 (patch) | |
tree | 3453a22d66e190a035c1124ffa3aa831e1cbb91c /encoding.c | |
parent | 968f2e86273d15e8ad7eac604f8450d16e416fdd (diff) |
merges the latter half of r24423 from trunk into ruby_1_9_1.
* encoding.c (enc_capable, rb_enc_get_index): Symbol is encoding
capable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c index 7d73244675..faebdfac86 100644 --- a/encoding.c +++ b/encoding.c @@ -539,7 +539,7 @@ rb_enc_find(const char *name) static inline int enc_capable(VALUE obj) { - if (SPECIAL_CONST_P(obj)) return Qfalse; + if (SPECIAL_CONST_P(obj)) return SYMBOL_P(obj); switch (BUILTIN_TYPE(obj)) { case T_STRING: case T_REGEXP: @@ -565,6 +565,10 @@ rb_enc_get_index(VALUE obj) int i = -1; VALUE tmp; + if (SPECIAL_CONST_P(obj)) { + if (!SYMBOL_P(obj)) return -1; + obj = rb_id2str(SYM2ID(obj)); + } switch (BUILTIN_TYPE(obj)) { as_default: default: |