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

ruby-changes:39505

From: nobu <ko1@a...>
Date: Sat, 15 Aug 2015 13:32:38 +0900 (JST)
Subject: [ruby-changes:39505] nobu:r51586 (trunk): use rb_sym2str

nobu	2015-08-15 13:32:15 +0900 (Sat, 15 Aug 2015)

  New Revision: 51586

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

  Log:
    use rb_sym2str
    
    * ext/openssl/ossl_ssl.c (ossl_sslctx_set_ssl_version): use
      rb_sym2str to get rid of inadvertent ID creations.
    
    * ext/socket/ancdata.c (ancillary_inspect): ditto.
    
    * ext/socket/option.c (sockopt_inspect): ditto.

  Modified files:
    trunk/ext/openssl/ossl_ssl.c
    trunk/ext/socket/ancdata.c
    trunk/ext/socket/option.c
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 51585)
+++ ext/openssl/ossl_ssl.c	(revision 51586)
@@ -174,13 +174,13 @@ ossl_sslctx_set_ssl_version(VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L174
 {
     SSL_METHOD *method = NULL;
     const char *s;
+    VALUE m = ssl_method;
     int i;
 
     SSL_CTX *ctx;
     if (RB_TYPE_P(ssl_method, T_SYMBOL))
-	s = rb_id2name(SYM2ID(ssl_method));
-    else
-	s =  StringValuePtr(ssl_method);
+	m = rb_sym2str(ssl_method);
+    s = StringValuePtr(m);
     for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
         if (strcmp(ossl_ssl_method_tab[i].name, s) == 0) {
             method = ossl_ssl_method_tab[i].func();
Index: ext/socket/option.c
===================================================================
--- ext/socket/option.c	(revision 51585)
+++ ext/socket/option.c	(revision 51586)
@@ -1244,7 +1244,7 @@ sockopt_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L1244
 
 	v = optname_to_sym(level, optname);
 	if (SYMBOL_P(v))
-	    rb_str_catf(ret, " %s", rb_id2name(SYM2ID(v)));
+	    rb_str_catf(ret, " %"PRIsVALUE, rb_sym2str(v));
 	else
 	    rb_str_catf(ret, " optname:%d", optname);
     }
Index: ext/socket/ancdata.c
===================================================================
--- ext/socket/ancdata.c	(revision 51585)
+++ ext/socket/ancdata.c	(revision 51586)
@@ -990,7 +990,7 @@ ancillary_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L990
 
         vtype = ip_cmsg_type_to_sym(level, type);
         if (SYMBOL_P(vtype))
-            rb_str_catf(ret, " %s", rb_id2name(SYM2ID(vtype)));
+            rb_str_catf(ret, " %"PRIsVALUE, rb_sym2str(vtype));
         else
             rb_str_catf(ret, " cmsg_type:%d", type);
     }

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

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