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 | d3554dba41442ecad7bb8387ad35c72e7f09710b (patch) | |
| tree | 3453a22d66e190a035c1124ffa3aa831e1cbb91c /encoding.c | |
| parent | c2de620c78a1eba753144cf16ee9f7c0ae51b910 (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: http://svn.ruby-lang.org/repos/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 7d7324467..faebdfac8 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: |
