diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index da1a3c7a74..f99a30dfc3 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -523,18 +523,11 @@ ossl_engine_get_cmds(VALUE self) 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)) diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index 84cedc763a..85bbc0d081 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -693,35 +693,15 @@ ossl_x509_add_extension(VALUE self, VALUE extension) 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)); } /* diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c index 482a0a2eee..8ef722e1c0 100644 --- a/ext/syslog/syslog.c +++ b/ext/syslog/syslog.c @@ -327,10 +327,10 @@ static VALUE mSyslog_inspect(VALUE self) 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,