mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
encoding.c: is_obj_encoding
* encoding.c (is_obj_encoding): new macro to check if obj is an Encoding. obj can be any type while is_data_encoding expects T_DATA only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
84d473b750
commit
6c00e17706
2 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Jul 25 17:21:21 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (is_obj_encoding): new macro to check if obj is an
|
||||
Encoding. obj can be any type while is_data_encoding expects T_DATA
|
||||
only.
|
||||
|
||||
Thu Jul 25 17:17:52 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_expand_path_internal): should clear coderange after
|
||||
|
|
|
@ -73,6 +73,7 @@ static const rb_data_type_t encoding_data_type = {
|
|||
};
|
||||
|
||||
#define is_data_encoding(obj) (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type)
|
||||
#define is_obj_encoding(obj) (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj))
|
||||
|
||||
static VALUE
|
||||
enc_new(rb_encoding *encoding)
|
||||
|
@ -121,7 +122,7 @@ check_encoding(rb_encoding *enc)
|
|||
static int
|
||||
enc_check_encoding(VALUE obj)
|
||||
{
|
||||
if (!RB_TYPE_P(obj, T_DATA) || !is_data_encoding(obj)) {
|
||||
if (!is_obj_encoding(obj)) {
|
||||
return -1;
|
||||
}
|
||||
return check_encoding(RDATA(obj)->data);
|
||||
|
@ -1143,7 +1144,7 @@ static VALUE
|
|||
enc_find(VALUE klass, VALUE enc)
|
||||
{
|
||||
int idx;
|
||||
if (RB_TYPE_P(enc, T_DATA) && is_data_encoding(enc))
|
||||
if (is_obj_encoding(enc))
|
||||
return enc;
|
||||
idx = str_to_encindex(enc);
|
||||
if (idx == UNSPECIFIED_ENCODING) return Qnil;
|
||||
|
|
Loading…
Add table
Reference in a new issue