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

ruby-changes:32580

From: nagachika <ko1@a...>
Date: Mon, 20 Jan 2014 01:29:04 +0900 (JST)
Subject: [ruby-changes:32580] nagachika:r44659 (ruby_2_0_0): merge revision(s) 44569:44572, 44576:44579, 44581, 44590:44594, 44607, 44608, 44614, 44615:

nagachika	2014-01-20 01:28:53 +0900 (Mon, 20 Jan 2014)

  New Revision: 44659

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

  Log:
    merge revision(s) 44569:44572,44576:44579,44581,44590:44594,44607,44608,44614,44615:
    
    iseq.c: linear search
    
    * iseq.c (iseq_type_from_id): linear search instead of hash lookup for
      small fixed number keys.
    ------------------------------------------------------------------------
    r44570 | nobu | 2014-01-12 17:11:32 +0900 (Sun, 12 Jan 2014) | 4 lines
    
    tcltklib.c: create_ip_exc format argument
    
    * ext/tk/tcltklib.c (create_ip_exc): format argument must not be a
      dynamic string, not to contain unescaped %.
    ------------------------------------------------------------------------
    r44571 | nobu | 2014-01-12 17:11:34 +0900 (Sun, 12 Jan 2014) | 5 lines
    
    stubs.c: library name strings
    
    * ext/tk/stubs.c (ruby_open_tcl_dll, ruby_open_tk_dll): make library
      names by string literal concatenation at compilation time, not by
      sprintf() at runtime.
    ------------------------------------------------------------------------
    r44572 | nobu | 2014-01-12 17:11:36 +0900 (Sun, 12 Jan 2014) | 1 line
    
    ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE
    * ext/bigdecimal/bigdecimal.c (CLASS_NAME): macro to wrap
      depending on PRIsVALUE for 1.9.  [Backport #9406]
    
    * ext/bigdecimal/bigdecimal.c (DECIMAL_SIZE_OF_BITS): fallback
      definition for 2.1 or older.  [ruby-core:59750] [Backport #9406]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/bigdecimal/bigdecimal.c
    branches/ruby_2_0_0/ext/dl/cptr.c
    branches/ruby_2_0_0/ext/fiddle/function.c
    branches/ruby_2_0_0/ext/fiddle/pointer.c
    branches/ruby_2_0_0/ext/json/fbuffer/fbuffer.h
    branches/ruby_2_0_0/ext/json/generator/generator.c
    branches/ruby_2_0_0/ext/openssl/ossl.c
    branches/ruby_2_0_0/ext/openssl/ossl.h
    branches/ruby_2_0_0/ext/openssl/ossl_asn1.c
    branches/ruby_2_0_0/ext/openssl/ossl_cipher.c
    branches/ruby_2_0_0/ext/openssl/ossl_engine.c
    branches/ruby_2_0_0/ext/openssl/ossl_x509cert.c
    branches/ruby_2_0_0/ext/pty/pty.c
    branches/ruby_2_0_0/ext/racc/cparse/cparse.c
    branches/ruby_2_0_0/ext/strscan/strscan.c
    branches/ruby_2_0_0/ext/syslog/syslog.c
    branches/ruby_2_0_0/ext/tk/stubs.c
    branches/ruby_2_0_0/ext/tk/tcltklib.c
    branches/ruby_2_0_0/ext/win32ole/win32ole.c
    branches/ruby_2_0_0/ext/zlib/zlib.c
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 44658)
+++ ruby_2_0_0/ChangeLog	(revision 44659)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Jan 20 01:02:18 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/bigdecimal/bigdecimal.c (CLASS_NAME): macro to wrap
+	  depending on PRIsVALUE for 1.9.  [Backport #9406]
+
+	* ext/bigdecimal/bigdecimal.c (DECIMAL_SIZE_OF_BITS): fallback
+	  definition for 2.1 or older.  [ruby-core:59750] [Backport #9406]
+
 Sun Jan 12 22:46:49 2014  CHIKANAGA Tomoyuki  <nagachika@r...>
 
 	patch inspired from r44260 on trunk. [ruby-core:58652] [Bug #9168]
Index: ruby_2_0_0/ext/bigdecimal/bigdecimal.c
===================================================================
--- ruby_2_0_0/ext/bigdecimal/bigdecimal.c	(revision 44658)
+++ ruby_2_0_0/ext/bigdecimal/bigdecimal.c	(revision 44659)
@@ -102,6 +102,20 @@ bigzero_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/bigdecimal/bigdecimal.c#L102
 # define RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))
 #endif
 
+#ifndef DECIMAL_SIZE_OF_BITS
+#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
+/* an approximation of ceil(n * log10(2)), upto 65536 at least */
+#endif
+
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
 /*
  * ================== Ruby Interface part ==========================
  */
@@ -262,8 +276,8 @@ SomeOneMayDoIt: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/bigdecimal/bigdecimal.c#L276
 unable_to_coerce_without_prec:
     if (must) {
 	rb_raise(rb_eArgError,
-		 "%s can't be coerced into BigDecimal without a precision",
-		 rb_obj_classname(v));
+		 "%"PRIsVALUE" can't be coerced into BigDecimal without a precision",
+		 RB_OBJ_CLASSNAME(v));
     }
     return NULL;
 }
@@ -2195,8 +2209,8 @@ retry: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/bigdecimal/bigdecimal.c#L2209
 	/* fall through */
       default:
 	rb_raise(rb_eTypeError,
-		 "wrong argument type %s (expected scalar Numeric)",
-		 rb_obj_classname(vexp));
+		 "wrong argument type %"PRIsVALUE" (expected scalar Numeric)",
+		 RB_OBJ_CLASSNAME(vexp));
     }
 
     if (VpIsZero(x)) {
@@ -2451,8 +2465,8 @@ BigDecimal_new(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/bigdecimal/bigdecimal.c#L2465
       case T_RATIONAL:
 	if (NIL_P(nFig)) {
 	    rb_raise(rb_eArgError,
-		     "can't omit precision for a %s.",
-		     rb_class2name(CLASS_OF(iniValue)));
+		     "can't omit precision for a %"PRIsVALUE".",
+		     RB_OBJ_CLASSNAME(iniValue));
 	}
 	return GetVpValueWithPrec(iniValue, mf, 1);
 
Index: ruby_2_0_0/ext/syslog/syslog.c
===================================================================
--- ruby_2_0_0/ext/syslog/syslog.c	(revision 44658)
+++ ruby_2_0_0/ext/syslog/syslog.c	(revision 44659)
@@ -315,7 +315,7 @@ static VALUE mSyslog_log(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/syslog/syslog.c#L315
     pri = *argv++;
 
     if (!FIXNUM_P(pri)) {
-      rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri)));
+	rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri));
     }
 
     syslog_write(FIX2INT(pri), argc, argv);
@@ -330,10 +330,10 @@ static VALUE mSyslog_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/syslog/syslog.c#L330
     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: ruby_2_0_0/ext/dl/cptr.c
===================================================================
--- ruby_2_0_0/ext/dl/cptr.c	(revision 44658)
+++ ruby_2_0_0/ext/dl/cptr.c	(revision 44659)
@@ -391,12 +391,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/dl/cptr.c#L391
 rb_dlptr_inspect(VALUE self)
 {
     struct ptr_data *data;
-    char str[1024];
 
     TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data);
-    snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>",
-	     rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
-    return rb_str_new2(str);
+    return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
+		      rb_obj_class(self), data, data->ptr, data->size, data->free);
 }
 
 /*
Index: ruby_2_0_0/ext/zlib/zlib.c
===================================================================
--- ruby_2_0_0/ext/zlib/zlib.c	(revision 44658)
+++ ruby_2_0_0/ext/zlib/zlib.c	(revision 44659)
@@ -337,11 +337,8 @@ raise_zlib_error(int err, const char *ms https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/zlib/zlib.c#L337
 	rb_sys_fail(msg);
 	/* no return */
       default:
-      {
-	  char buf[BUFSIZ];
-	  snprintf(buf, BUFSIZ, "unknown zlib error %d: %s", err, msg);
-	  exc = rb_exc_new2(cZError, buf);
-      }
+	exc = rb_exc_new3(cZError,
+			     rb_sprintf("unknown zlib error %d: %s", err, msg));
     }
 
     rb_exc_raise(exc);
Index: ruby_2_0_0/ext/win32ole/win32ole.c
===================================================================
--- ruby_2_0_0/ext/win32ole/win32ole.c	(revision 44658)
+++ ruby_2_0_0/ext/win32ole/win32ole.c	(revision 44659)
@@ -1193,19 +1193,18 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/win32ole/win32ole.c#L1193
 ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
 {
     va_list args;
-    char buf[BUFSIZ];
+    VALUE msg;
     VALUE err_msg;
     va_init_list(args, fmt);
-    vsnprintf(buf, BUFSIZ, fmt, args);
+    msg = rb_vsprintf(fmt, args);
     va_end(args);
 
     err_msg = ole_hresult2msg(hr);
     if(err_msg != Qnil) {
-        rb_raise(ecs, "%s\n%s", buf, StringValuePtr(err_msg));
-    }
-    else {
-        rb_raise(ecs, "%s", buf);
+	rb_str_cat2(msg, "\n");
+	rb_str_append(msg, err_msg);
     }
+    rb_exc_raise(rb_exc_new3(ecs, msg));
 }
 
 void
Index: ruby_2_0_0/ext/json/fbuffer/fbuffer.h
===================================================================
--- ruby_2_0_0/ext/json/fbuffer/fbuffer.h	(revision 44658)
+++ ruby_2_0_0/ext/json/fbuffer/fbuffer.h	(revision 44659)
@@ -25,6 +25,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/json/fbuffer/fbuffer.h#L25
 #define RSTRING_LEN(string) RSTRING(string)->len
 #endif
 
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
 #ifdef HAVE_RUBY_ENCODING_H
 #include "ruby/encoding.h"
 #define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
Index: ruby_2_0_0/ext/json/generator/generator.c
===================================================================
--- ruby_2_0_0/ext/json/generator/generator.c	(revision 44658)
+++ ruby_2_0_0/ext/json/generator/generator.c	(revision 44659)
@@ -804,10 +804,10 @@ static void generate_json_float(FBuffer https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/json/generator/generator.c#L804
     if (!allow_nan) {
         if (isinf(value)) {
             fbuffer_free(buffer);
-            rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
+            rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
         } else if (isnan(value)) {
             fbuffer_free(buffer);
-            rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
+            rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
         }
     }
     fbuffer_append_str(buffer, tmp);
Index: ruby_2_0_0/ext/pty/pty.c
===================================================================
--- ruby_2_0_0/ext/pty/pty.c	(revision 44658)
+++ ruby_2_0_0/ext/pty/pty.c	(revision 44659)
@@ -609,7 +609,7 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/pty/pty.c#L609
 raise_from_check(pid_t pid, int status)
 {
     const char *state;
-    char buf[1024];
+    VALUE msg;
     VALUE exc;
 
 #if defined(WIFSTOPPED)
@@ -627,8 +627,8 @@ raise_from_check(pid_t pid, int status) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/pty/pty.c#L627
     else {
 	state = "exited";
     }
-    snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)pid);
-    exc = rb_exc_new2(eChildExited, buf);
+    msg = rb_sprintf("pty - %s: %ld", state, (long)pid);
+    exc = rb_exc_new3(eChildExited, msg);
     rb_iv_set(exc, "status", rb_last_status_get());
     rb_exc_raise(exc);
 }
Index: ruby_2_0_0/ext/tk/stubs.c
===================================================================
--- ruby_2_0_0/ext/tk/stubs.c	(revision 44658)
+++ ruby_2_0_0/ext/tk/stubs.c	(revision 44659)
@@ -83,8 +83,8 @@ _nativethread_consistency_check(ip) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L83
 # define DL_SYM GetProcAddress
 # define TCL_INDEX 4
 # define TK_INDEX 3
-# define TCL_NAME "tcl89%s"
-# define TK_NAME "tk89%s"
+# define TCL_NAME "tcl89"
+# define TK_NAME "tk89"
 # undef DLEXT
 # define DLEXT ".dll"
 #elif defined HAVE_DLOPEN
@@ -94,8 +94,8 @@ _nativethread_consistency_check(ip) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L94
 # define DL_SYM dlsym
 # define TCL_INDEX 8
 # define TK_INDEX 7
-# define TCL_NAME "libtcl8.9%s"
-# define TK_NAME "libtk8.9%s"
+# define TCL_NAME "libtcl8.9"
+# define TK_NAME "libtk8.9"
 # ifdef __APPLE__
 #  undef DLEXT
 #  define DLEXT ".dylib"
@@ -116,7 +116,6 @@ ruby_open_tcl_dll(appname) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L116
     void (*p_Tcl_FindExecutable)(const char *);
     int n;
     char *ruby_tcl_dll = 0;
-    char tcl_name[20];
 
     if (tcl_dll) return TCLTK_STUBS_OK;
 
@@ -127,7 +126,7 @@ ruby_open_tcl_dll(appname) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L126
     if (ruby_tcl_dll) {
         tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
     } else {
-        snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
+	char tcl_name[] = TCL_NAME DLEXT;
         /* examine from 8.9 to 8.1 */
         for (n = '9'; n > '0'; n--) {
             tcl_name[TCL_INDEX] = n;
@@ -162,7 +161,6 @@ ruby_open_tk_dll() https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L161
 {
     int n;
     char *ruby_tk_dll = 0;
-    char tk_name[20];
 
     if (!tcl_dll) {
         /* int ret = ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
@@ -176,7 +174,7 @@ ruby_open_tk_dll() https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/stubs.c#L174
     if (ruby_tk_dll) {
         tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
     } else {
-        snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
+	char tk_name[] = TK_NAME DLEXT;
         /* examine from 8.9 to 8.1 */
         for (n = '9'; n > '0'; n--) {
             tk_name[TK_INDEX] = n;
Index: ruby_2_0_0/ext/tk/tcltklib.c
===================================================================
--- ruby_2_0_0/ext/tk/tcltklib.c	(revision 44658)
+++ ruby_2_0_0/ext/tk/tcltklib.c	(revision 44659)
@@ -843,15 +843,14 @@ create_ip_exc(interp, exc, fmt, va_alist https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tcltklib.c#L843
 #endif
 {
     va_list args;
-    char buf[BUFSIZ];
+    VALUE msg;
     VALUE einfo;
     struct tcltkip *ptr = get_ip(interp);
 
     va_init_list(args,fmt);
-    vsnprintf(buf, BUFSIZ, fmt, args);
-    buf[BUFSIZ - 1] = '\0';
+    msg = rb_vsprintf(fmt, args);
     va_end(args);
-    einfo = rb_exc_new2(exc, buf);
+    einfo = rb_exc_new3(exc, msg);
     rb_ivar_set(einfo, ID_at_interp, interp);
     if (ptr) {
         Tcl_ResetResult(ptr->ip);
Index: ruby_2_0_0/ext/openssl/ossl_engine.c
===================================================================
--- ruby_2_0_0/ext/openssl/ossl_engine.c	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl_engine.c	(revision 44659)
@@ -365,18 +365,11 @@ ossl_engine_get_cmds(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl_engine.c#L365
 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: ruby_2_0_0/ext/openssl/ossl_cipher.c
===================================================================
--- ruby_2_0_0/ext/openssl/ossl_cipher.c	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl_cipher.c	(revision 44659)
@@ -213,9 +213,9 @@ ossl_cipher_init(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl_cipher.c#L213
 	 * We deprecated the arguments for this method, but we decided
 	 * keeping this behaviour for backward compatibility.
 	 */
-	const char *cname  = rb_class2name(rb_obj_class(self));
-	rb_warn("arguments for %s#encrypt and %s#decrypt were deprecated; "
-                "use %s#pkcs5_keyivgen to derive key and IV",
+	VALUE cname  = rb_class_path(rb_obj_class(self));
+	rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; "
+                "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV",
                 cname, cname, cname);
 	StringValue(pass);
 	GetCipher(self, ctx);
Index: ruby_2_0_0/ext/openssl/ossl.c
===================================================================
--- ruby_2_0_0/ext/openssl/ossl.c	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl.c	(revision 44659)
@@ -293,10 +293,9 @@ ossl_to_der_if_possible(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl.c#L293
 static VALUE
 ossl_make_error(VALUE exc, const char *fmt, va_list args)
 {
-    char buf[BUFSIZ];
+    VALUE str = Qnil;
     const char *msg;
     long e;
-    int len = 0;
 
 #ifdef HAVE_ERR_PEEK_LAST_ERROR
     e = ERR_peek_last_error();
@@ -304,14 +303,19 @@ ossl_make_error(VALUE exc, const char *f https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl.c#L303
     e = ERR_peek_error();
 #endif
     if (fmt) {
-	len = vsnprintf(buf, BUFSIZ, fmt, args);
+	str = rb_vsprintf(fmt, args);
     }
-    if (len < BUFSIZ && e) {
+    if (e) {
 	if (dOSSL == Qtrue) /* FULL INFO */
 	    msg = ERR_error_string(e, NULL);
 	else
 	    msg = ERR_reason_error_string(e);
-	len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg);
+	if (NIL_P(str)) {
+	    str = rb_str_new_cstr(msg);
+	}
+	else {
+	    rb_str_cat2(rb_str_cat2(str, ": "), msg);
+	}
     }
     if (dOSSL == Qtrue){ /* show all errors on the stack */
 	while ((e = ERR_get_error()) != 0){
@@ -320,8 +324,8 @@ ossl_make_error(VALUE exc, const char *f https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl.c#L324
     }
     ERR_clear_error();
 
-    if(len > BUFSIZ) len = rb_long2int(strlen(buf));
-    return rb_exc_new(exc, buf, len);
+    if (NIL_P(str)) str = rb_str_new(0, 0);
+    return rb_exc_new3(exc, str);
 }
 
 void
Index: ruby_2_0_0/ext/openssl/ossl.h
===================================================================
--- ruby_2_0_0/ext/openssl/ossl.h	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl.h	(revision 44659)
@@ -95,15 +95,15 @@ extern VALUE eOSSLError; https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl.h#L95
  */
 #define OSSL_Check_Kind(obj, klass) do {\
   if (!rb_obj_is_kind_of((obj), (klass))) {\
-    ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
-               rb_obj_classname(obj), rb_class2name(klass));\
+    ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
+               rb_obj_class(obj), (klass));\
   }\
 } while (0)
 
 #define OSSL_Check_Instance(obj, klass) do {\
   if (!rb_obj_is_instance_of((obj), (klass))) {\
-    ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
-               rb_obj_classname(obj), rb_class2name(klass));\
+    ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\
+               rb_obj_class(obj), (klass));\
   }\
 } while (0)
 
Index: ruby_2_0_0/ext/openssl/ossl_asn1.c
===================================================================
--- ruby_2_0_0/ext/openssl/ossl_asn1.c	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl_asn1.c	(revision 44659)
@@ -624,8 +624,8 @@ ossl_asn1_default_tag(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/openssl/ossl_asn1.c#L624
       	}
     	tmp_class = rb_class_superclass(tmp_class);
     }
-    ossl_raise(eASN1Error, "universal tag for %s not found",
-	       rb_class2name(CLASS_OF(obj)));
+    ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found",
+	       rb_obj_class(obj));
 
     return -1; /* dummy */
 }
Index: ruby_2_0_0/ext/openssl/ossl_x509cert.c
===================================================================
--- ruby_2_0_0/ext/openssl/ossl_x509cert.c	(revision 44658)
+++ ruby_2_0_0/ext/openssl/ossl_x509cert.c	(revision 44659)
@@ -693,35 +693,15 @@ ossl_x509_add_extension(VALUE self, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/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));
 }
 
 /*
Index: ruby_2_0_0/ext/fiddle/pointer.c
===================================================================
--- ruby_2_0_0/ext/fiddle/pointer.c	(revision 44658)
+++ ruby_2_0_0/ext/fiddle/pointer.c	(revision 44659)
@@ -7,6 +7,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/fiddle/pointer.c#L7
 #include <ctype.h>
 #include <fiddle.h>
 
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLA (... truncated)

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

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