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

ruby-changes:18039

From: naruse <ko1@a...>
Date: Fri, 3 Dec 2010 04:19:54 +0900 (JST)
Subject: [ruby-changes:18039] Ruby:r30060 (trunk): * encoding.c (enc_alias_internal): use st_insert2 and change return

naruse	2010-12-03 04:19:47 +0900 (Fri, 03 Dec 2010)

  New Revision: 30060

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

  Log:
    * encoding.c (enc_alias_internal): use st_insert2 and change return
      value to int.
    
    * encoding.c (enc_alias): follow enc_alias_internal.

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c

Index: encoding.c
===================================================================
--- encoding.c	(revision 30059)
+++ encoding.c	(revision 30060)
@@ -440,23 +440,19 @@
  * Returns copied alias name when the key is added for st_table,
  * else returns NULL.
  */
-static const char *
+static int
 enc_alias_internal(const char *alias, int idx)
 {
-    char *name = strdup(alias);
-    if (st_insert(enc_table.names, (st_data_t)name, (st_data_t)idx)) {
-	xfree(name);
-	return NULL;
-    }
-    return name;
+    return st_insert2(enc_table.names, (st_data_t)alias, (st_data_t)idx,
+	    (st_data_t(*)(st_data_t))strdup);
 }
 
 static int
 enc_alias(const char *alias, int idx)
 {
     if (!valid_encoding_name_p(alias)) return -1;
-    alias = enc_alias_internal(alias, idx);
-    if (alias) set_encoding_const(alias, rb_enc_from_index(idx));
+    if (!enc_alias_internal(alias, idx))
+	set_encoding_const(alias, rb_enc_from_index(idx));
     return idx;
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30059)
+++ ChangeLog	(revision 30060)
@@ -1,3 +1,10 @@
+Fri Dec  3 04:08:59 2010  NARUSE, Yui  <naruse@r...>
+
+	* encoding.c (enc_alias_internal): use st_insert2 and change return
+	  value to int.
+
+	* encoding.c (enc_alias): follow enc_alias_internal.
+
 Fri Dec  3 01:52:43 2010  NARUSE, Yui  <naruse@r...>
 
 	* encoding.c (enc_alias_internal): use xfree instead of free.

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

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