[前][次][番号順一覧][スレッド一覧]

ruby-changes:29916

From: nobu <ko1@a...>
Date: Mon, 15 Jul 2013 02:31:24 +0900 (JST)
Subject: [ruby-changes:29916] nobu:r41968 (trunk): encoding.c: encoding check

nobu	2013-07-15 02:31:14 +0900 (Mon, 15 Jul 2013)

  New Revision: 41968

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41968

  Log:
    encoding.c: encoding check
    
    * encoding.c (enc_check_encoding): use is_data_encoding() to check
      type consistently.
    * encoding.c (must_encoding): return rb_encoding* instead of encoding
      index.

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c

Index: encoding.c
===================================================================
--- encoding.c	(revision 41967)
+++ encoding.c	(revision 41968)
@@ -129,13 +129,13 @@ check_encoding(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L129
 static int
 enc_check_encoding(VALUE obj)
 {
-    if (SPECIAL_CONST_P(obj) || !rb_typeddata_is_kind_of(obj, &encoding_data_type)) {
+    if (!is_data_encoding(obj)) {
 	return -1;
     }
     return check_encoding(RDATA(obj)->data);
 }
 
-static int
+static rb_encoding *
 must_encoding(VALUE enc)
 {
     int index = enc_check_encoding(enc);
@@ -143,7 +143,7 @@ must_encoding(VALUE enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L143
 	rb_raise(rb_eTypeError, "wrong argument type %s (expected Encoding)",
 		 rb_obj_classname(enc));
     }
-    return index;
+    return DATA_PTR(enc);
 }
 
 static rb_encoding *
@@ -456,7 +456,7 @@ rb_encdb_dummy(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L456
 static VALUE
 enc_dummy_p(VALUE enc)
 {
-    return ENC_DUMMY_P(enc_table.list[must_encoding(enc)].enc) ? Qtrue : Qfalse;
+    return ENC_DUMMY_P(must_encoding(enc)) ? Qtrue : Qfalse;
 }
 
 /*
@@ -472,7 +472,7 @@ enc_dummy_p(VALUE enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L472
 static VALUE
 enc_ascii_compatible_p(VALUE enc)
 {
-    return rb_enc_asciicompat(enc_table.list[must_encoding(enc)].enc) ? Qtrue : Qfalse;
+    return rb_enc_asciicompat(must_encoding(enc)) ? Qtrue : Qfalse;
 }
 
 /*
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41967)
+++ ChangeLog	(revision 41968)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul 15 02:31:12 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* encoding.c (enc_check_encoding): use is_data_encoding() to check
+	  type consistently.
+
+	* encoding.c (must_encoding): return rb_encoding* instead of encoding
+	  index.
+
+	* encoding.c (enc_check_encoding): use is_data_encoding() to check
+	  type consistently.
+
+	* encoding.c (must_encoding): return rb_encoding* instead of encoding
+	  index.
+
 Mon Jul 15 02:21:39 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (str_fill_term): consider old terminator length, and should

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]