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

ruby-changes:32502

From: nobu <ko1@a...>
Date: Mon, 13 Jan 2014 09:57:57 +0900 (JST)
Subject: [ruby-changes:32502] nobu:r44581 (trunk): ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE

nobu	2014-01-13 09:57:41 +0900 (Mon, 13 Jan 2014)

  New Revision: 44581

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

  Log:
    ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE

  Modified files:
    trunk/ext/openssl/ossl_engine.c
    trunk/ext/openssl/ossl_x509cert.c
    trunk/ext/syslog/syslog.c
Index: ext/syslog/syslog.c
===================================================================
--- ext/syslog/syslog.c	(revision 44580)
+++ ext/syslog/syslog.c	(revision 44581)
@@ -327,10 +327,10 @@ static VALUE mSyslog_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/syslog/syslog.c#L327
     Check_Type(self, T_MODULE);
 
     if (!syslog_opened)
-	return rb_sprintf("<#%s: opened=false>", rb_class2name(self));
+	return rb_sprintf("<#%"PRIsVALUE": opened=false>", self);
 
-    return rb_sprintf("<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
-		      rb_class2name(self),
+    return rb_sprintf("<#%"PRIsVALUE": opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
+		      self,
 		      syslog_ident,
 		      syslog_options,
 		      syslog_facility,
Index: ext/openssl/ossl_engine.c
===================================================================
--- ext/openssl/ossl_engine.c	(revision 44580)
+++ ext/openssl/ossl_engine.c	(revision 44581)
@@ -523,18 +523,11 @@ ossl_engine_get_cmds(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_engine.c#L523
 static VALUE
 ossl_engine_inspect(VALUE self)
 {
-    VALUE str;
-    const char *cname = rb_class2name(rb_obj_class(self));
+    ENGINE *e;
 
-    str = rb_str_new2("#<");
-    rb_str_cat2(str, cname);
-    rb_str_cat2(str, " id=\"");
-    rb_str_append(str, ossl_engine_get_id(self));
-    rb_str_cat2(str, "\" name=\"");
-    rb_str_append(str, ossl_engine_get_name(self));
-    rb_str_cat2(str, "\">");
-
-    return str;
+    GetEngine(self, e);
+    return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">",
+		      rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e));
 }
 
 #define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x))
Index: ext/openssl/ossl_x509cert.c
===================================================================
--- ext/openssl/ossl_x509cert.c	(revision 44580)
+++ ext/openssl/ossl_x509cert.c	(revision 44581)
@@ -693,35 +693,15 @@ ossl_x509_add_extension(VALUE self, VALU https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509cert.c#L693
 static VALUE
 ossl_x509_inspect(VALUE self)
 {
-    VALUE str;
-    const char *cname = rb_class2name(rb_obj_class(self));
-
-    str = rb_str_new2("#<");
-    rb_str_cat2(str, cname);
-    rb_str_cat2(str, " ");
-
-    rb_str_cat2(str, "subject=");
-    rb_str_append(str, rb_inspect(ossl_x509_get_subject(self)));
-    rb_str_cat2(str, ", ");
-
-    rb_str_cat2(str, "issuer=");
-    rb_str_append(str, rb_inspect(ossl_x509_get_issuer(self)));
-    rb_str_cat2(str, ", ");
-
-    rb_str_cat2(str, "serial=");
-    rb_str_append(str, rb_inspect(ossl_x509_get_serial(self)));
-    rb_str_cat2(str, ", ");
-
-    rb_str_cat2(str, "not_before=");
-    rb_str_append(str, rb_inspect(ossl_x509_get_not_before(self)));
-    rb_str_cat2(str, ", ");
-
-    rb_str_cat2(str, "not_after=");
-    rb_str_append(str, rb_inspect(ossl_x509_get_not_after(self)));
-
-    str = rb_str_cat2(str, ">");
-
-    return str;
+    return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", "
+		      "issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", "
+		      "not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">",
+		      rb_obj_class(self),
+		      ossl_x509_get_subject(self),
+		      ossl_x509_get_issuer(self),
+		      ossl_x509_get_serial(self),
+		      ossl_x509_get_not_before(self),
+		      ossl_x509_get_not_after(self));
 }
 
 /*

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

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