diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-28 08:35:48 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-28 08:35:48 +0000 |
commit | d0fb73a0f0b82ebc0d3eb931c28686a2b9c40fef (patch) | |
tree | 7587165b00fd75037adcd1667a102bda5e9f3d09 /include/ruby/encoding.h | |
parent | 40efaab3012188e159d0f6e104371c22fc3fcafd (diff) | |
download | ruby-d0fb73a0f0b82ebc0d3eb931c28686a2b9c40fef.tar.gz |
check enc_capable.
* encoding.c (rb_enc_capable): make it extern to check enc_capable.
enc_index can be set to limited types such as T_STRING, T_REGEX
and so on. This function check an object is this kind of types.
* include/ruby/encoding.h: ditto.
* encoding.c (enc_set_index): check a given object is enc_capable.
* include/ruby/encoding.h (PUREFUNC):
* marshal.c (encoding_name): check `rb_enc_capable` first.
* marshal.c (r_ivar): ditto. If it is not enc_capable, it should be
malformed data.
* spec/ruby/optional/capi/encoding_spec.rb: remove tests depending
on the wrong feature: all objects can set enc_index.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/encoding.h')
-rw-r--r-- | include/ruby/encoding.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 0c7e1e3d6a..32d874aa9d 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -122,6 +122,7 @@ PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc)); PUREFUNC(int rb_enc_to_index(rb_encoding *enc)); int rb_enc_get_index(VALUE obj); void rb_enc_set_index(VALUE obj, int encindex); +int rb_enc_capable(VALUE obj); int rb_enc_find_index(const char *name); int rb_to_encoding_index(VALUE); rb_encoding *rb_to_encoding(VALUE); |