ruby-changes:32675
From: usa <ko1@a...>
Date: Thu, 30 Jan 2014 12:49:20 +0900 (JST)
Subject: [ruby-changes:32675] usa:r44754 (ruby_1_9_3): merge revision(s) 44570:44572, 44581:
usa 2014-01-30 12:49:07 +0900 (Thu, 30 Jan 2014) New Revision: 44754 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44754 Log: merge revision(s) 44570:44572,44581: 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_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/ext/bigdecimal/bigdecimal.c branches/ruby_1_9_3/ext/dl/cptr.c branches/ruby_1_9_3/ext/json/generator/generator.c branches/ruby_1_9_3/ext/openssl/ossl.c branches/ruby_1_9_3/ext/openssl/ossl.h branches/ruby_1_9_3/ext/openssl/ossl_asn1.c branches/ruby_1_9_3/ext/openssl/ossl_cipher.c branches/ruby_1_9_3/ext/openssl/ossl_engine.c branches/ruby_1_9_3/ext/openssl/ossl_x509cert.c branches/ruby_1_9_3/ext/openssl/ruby_missing.h branches/ruby_1_9_3/ext/pty/pty.c branches/ruby_1_9_3/ext/strscan/strscan.c branches/ruby_1_9_3/ext/syslog/syslog.c branches/ruby_1_9_3/ext/tk/stubs.c branches/ruby_1_9_3/ext/tk/tcltklib.c branches/ruby_1_9_3/ext/win32ole/win32ole.c branches/ruby_1_9_3/ext/zlib/zlib.c branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 44753) +++ ruby_1_9_3/ChangeLog (revision 44754) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Thu Jan 30 11:07:09 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] + Wed Jan 29 19:22:45 2014 NAKAMURA Usaku <usa@r...> * enumerator.c: include internal.h instead of declaring the external Index: ruby_1_9_3/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_1_9_3/ext/bigdecimal/bigdecimal.c (revision 44753) +++ ruby_1_9_3/ext/bigdecimal/bigdecimal.c (revision 44754) @@ -102,6 +102,15 @@ bigzero_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/bigdecimal/bigdecimal.c#L102 # define RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0))) #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 ========================== */ @@ -2355,7 +2364,9 @@ BigDecimal_new(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/bigdecimal/bigdecimal.c#L2364 /* fall through */ case T_RATIONAL: if (NIL_P(nFig)) { - rb_raise(rb_eArgError, "can't omit precision for a Rational."); + rb_raise(rb_eArgError, + "can't omit precision for a %"PRIsVALUE".", + RB_OBJ_CLASSNAME(iniValue)); } return ToValue(GetVpValueWithPrec(iniValue, mf, 1)); Index: ruby_1_9_3/ext/syslog/syslog.c =================================================================== --- ruby_1_9_3/ext/syslog/syslog.c (revision 44753) +++ ruby_1_9_3/ext/syslog/syslog.c (revision 44754) @@ -12,6 +12,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/syslog/syslog.c#L12 #include "ruby/util.h" #include <syslog.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_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + /* Syslog class */ static VALUE mSyslog, mSyslogConstants; static const char *syslog_ident = NULL; @@ -301,7 +310,7 @@ static VALUE mSyslog_log(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/syslog/syslog.c#L310 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_CLASSNAME(pri)); } syslog_write(FIX2INT(pri), argc, argv); @@ -313,24 +322,17 @@ static VALUE mSyslog_log(int argc, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/syslog/syslog.c#L322 */ static VALUE mSyslog_inspect(VALUE self) { - char buf[1024]; - Check_Type(self, T_MODULE); - if (syslog_opened) { - snprintf(buf, sizeof(buf), - "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", - rb_class2name(self), - syslog_ident, - syslog_options, - syslog_facility, - syslog_mask); - } else { - snprintf(buf, sizeof(buf), - "<#%s: opened=false>", rb_class2name(self)); - } + if (!syslog_opened) + return rb_sprintf("<#%s: opened=false>", rb_class2name(self)); - return rb_str_new2(buf); + return rb_sprintf("<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", + rb_class2name(self), + syslog_ident, + syslog_options, + syslog_facility, + syslog_mask); } /* Returns self, for backward compatibility. Index: ruby_1_9_3/ext/dl/cptr.c =================================================================== --- ruby_1_9_3/ext/dl/cptr.c (revision 44753) +++ ruby_1_9_3/ext/dl/cptr.c (revision 44754) @@ -7,6 +7,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/dl/cptr.c#L7 #include <ctype.h> #include "dl.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_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + VALUE rb_cDLCPtr; static inline freefunc_t @@ -400,12 +409,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/dl/cptr.c#L409 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_CLASSNAME(self), data, data->ptr, data->size, data->free); } /* Index: ruby_1_9_3/ext/zlib/zlib.c =================================================================== --- ruby_1_9_3/ext/zlib/zlib.c (revision 44753) +++ ruby_1_9_3/ext/zlib/zlib.c (revision 44754) @@ -294,11 +294,8 @@ raise_zlib_error(int err, const char *ms https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/zlib/zlib.c#L294 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_new_str(cZError, + rb_sprintf("unknown zlib error %d: %s", err, msg)); } rb_exc_raise(exc); Index: ruby_1_9_3/ext/win32ole/win32ole.c =================================================================== --- ruby_1_9_3/ext/win32ole/win32ole.c (revision 44753) +++ ruby_1_9_3/ext/win32ole/win32ole.c (revision 44754) @@ -1185,19 +1185,18 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/win32ole/win32ole.c#L1185 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_new_str(ecs, msg)); } void Index: ruby_1_9_3/ext/json/generator/generator.c =================================================================== --- ruby_1_9_3/ext/json/generator/generator.c (revision 44753) +++ ruby_1_9_3/ext/json/generator/generator.c (revision 44754) @@ -5,6 +5,15 @@ static VALUE CEncoding_UTF_8; https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/json/generator/generator.c#L5 static ID i_encoding, i_encode; #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 + static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend, mTrueClass, mFalseClass, mNilClass, eGeneratorError, @@ -876,10 +885,10 @@ static void generate_json_float(FBuffer https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/json/generator/generator.c#L885 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_1_9_3/ext/pty/pty.c =================================================================== --- ruby_1_9_3/ext/pty/pty.c (revision 44753) +++ ruby_1_9_3/ext/pty/pty.c (revision 44754) @@ -609,7 +609,7 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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_1_9_3/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_new_str(eChildExited, msg); rb_iv_set(exc, "status", rb_last_status_get()); rb_exc_raise(exc); } Index: ruby_1_9_3/ext/tk/stubs.c =================================================================== --- ruby_1_9_3/ext/tk/stubs.c (revision 44753) +++ ruby_1_9_3/ext/tk/stubs.c (revision 44754) @@ -83,8 +83,8 @@ _nativethread_consistency_check(ip) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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_1_9_3/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" # if defined(__APPLE__) && defined(__MACH__) /* Mac OS X */ # undef DLEXT # define DLEXT ".dylib" @@ -116,7 +116,6 @@ ruby_open_tcl_dll(appname) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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_1_9_3/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_1_9_3/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_1_9_3/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_1_9_3/ext/tk/tcltklib.c =================================================================== --- ruby_1_9_3/ext/tk/tcltklib.c (revision 44753) +++ ruby_1_9_3/ext/tk/tcltklib.c (revision 44754) @@ -839,15 +839,14 @@ create_ip_exc(interp, exc, fmt, va_alist https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/tk/tcltklib.c#L839 #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_new_str(exc, msg); rb_ivar_set(einfo, ID_at_interp, interp); if (ptr) { Tcl_ResetResult(ptr->ip); @@ -6641,7 +6640,7 @@ ip_make_safe_core(interp, argc, argv) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/tk/tcltklib.c#L6640 if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) { /* return rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); */ - return create_ip_exc(interp, rb_eRuntimeError, + return create_ip_exc(interp, rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); } @@ -9331,7 +9330,7 @@ ip_get_variable2_core(interp, argc, argv https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/tk/tcltklib.c#L9330 volatile VALUE exc; /* exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); */ - exc = create_ip_exc(interp, rb_eRuntimeError, + exc = create_ip_exc(interp, rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); /* Tcl_Release(ptr->ip); */ rbtk_release_ip(ptr); @@ -9470,7 +9469,7 @@ ip_set_variable2_core(interp, argc, argv https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/tk/tcltklib.c#L9469 volatile VALUE exc; /* exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); */ - exc = create_ip_exc(interp, rb_eRuntimeError, + exc = create_ip_exc(interp, rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); /* Tcl_Release(ptr->ip); */ rbtk_release_ip(ptr); @@ -9590,7 +9589,7 @@ ip_unset_variable2_core(interp, argc, ar https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/tk/tcltklib.c#L9589 if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) { /* return rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip)); */ - return create_ip_exc(interp, rb_eRuntimeError, + return create_ip_exc(interp, rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip)); } return Qfalse; Index: ruby_1_9_3/ext/openssl/ossl_engine.c =================================================================== --- ruby_1_9_3/ext/openssl/ossl_engine.c (revision 44753) +++ ruby_1_9_3/ext/openssl/ossl_engine.c (revision 44754) @@ -347,18 +347,11 @@ ossl_engine_get_cmds(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl_engine.c#L347 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_CLASSNAME(self), ENGINE_get_id(e), ENGINE_get_name(e)); } #define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x)) Index: ruby_1_9_3/ext/openssl/ossl_cipher.c =================================================================== --- ruby_1_9_3/ext/openssl/ossl_cipher.c (revision 44753) +++ ruby_1_9_3/ext/openssl/ossl_cipher.c (revision 44754) @@ -213,10 +213,10 @@ ossl_cipher_init(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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", - cname, cname, cname); + 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", + RB_OBJ_STRING(cname), RB_OBJ_STRING(cname), RB_OBJ_STRING(cname)); StringValue(pass); GetCipher(self, ctx); if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv)); Index: ruby_1_9_3/ext/openssl/ruby_missing.h =================================================================== --- ruby_1_9_3/ext/openssl/ruby_missing.h (revision 44753) +++ ruby_1_9_3/ext/openssl/ruby_missing.h (revision 44754) @@ -38,4 +38,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ruby_missing.h#L38 #define rb_block_call(arg1, arg2, arg3, arg4, arg5, arg6) rb_iterate(rb_each, (arg1), (arg5), (arg6)) #endif /* ! HAVE_RB_BLOCK_CALL */ +#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 + #endif /* _OSSL_RUBY_MISSING_H_ */ Index: ruby_1_9_3/ext/openssl/ossl.c =================================================================== --- ruby_1_9_3/ext/openssl/ossl.c (revision 44753) +++ ruby_1_9_3/ext/openssl/ossl.c (revision 44754) @@ -284,10 +284,9 @@ ossl_to_der_if_possible(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl.c#L284 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(); @@ -295,14 +294,19 @@ ossl_make_error(VALUE exc, const char *f https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl.c#L294 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){ @@ -311,8 +315,8 @@ ossl_make_error(VALUE exc, const char *f https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl.c#L315 } 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_1_9_3/ext/openssl/ossl.h =================================================================== --- ruby_1_9_3/ext/openssl/ossl.h (revision 44753) +++ ruby_1_9_3/ext/openssl/ossl.h (revision 44754) @@ -89,15 +89,15 @@ extern VALUE eOSSLError; https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl.h#L89 */ #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 %s)",\ + RB_OBJ_CLASSNAME(obj), rb_class2name(klass));\ }\ } while (0) (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/