ruby-changes:32485
From: nagachika <ko1@a...>
Date: Sun, 12 Jan 2014 15:30:42 +0900 (JST)
Subject: [ruby-changes:32485] nagachika:r44564 (ruby_2_0_0): merge revision(s) 41351: [Backport #9199]
nagachika 2014-01-12 15:30:32 +0900 (Sun, 12 Jan 2014) New Revision: 44564 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44564 Log: merge revision(s) 41351: [Backport #9199] * ext/tk/tkutil/tkutil.c: use rb_sprintf(), rb_id2str(), and rb_intern_str() instead of rb_intern() and RSTRING_PTR() with RB_GC_GUARD(), to prevent temporary objects from GC. [ruby-core:39000] [Bug #5199] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/ext/tk/tkutil/tkutil.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 44563) +++ ruby_2_0_0/ChangeLog (revision 44564) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Sun Jan 12 15:17:00 2014 Nobuyoshi Nakada <nobu@r...> + + * ext/tk/tkutil/tkutil.c: use rb_sprintf(), rb_id2str(), and + rb_intern_str() instead of rb_intern() and RSTRING_PTR() with + RB_GC_GUARD(), to prevent temporary objects from GC. + [ruby-core:39000] [Bug #5199] + Tue Jan 7 01:16:34 2014 Nobuyoshi Nakada <nobu@r...> * proc.c (mnew_from_me): keep iclass as-is, to make inheritance Index: ruby_2_0_0/ext/tk/tkutil/tkutil.c =================================================================== --- ruby_2_0_0/ext/tk/tkutil/tkutil.c (revision 44563) +++ ruby_2_0_0/ext/tk/tkutil/tkutil.c (revision 44564) @@ -897,8 +897,7 @@ get_eval_string_core(obj, enc_flag, self https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L897 } } - rb_warning("fail to convert '%s' to string for Tk", - RSTRING_PTR(rb_funcall(obj, rb_intern("inspect"), 0, 0))); + rb_warning("fail to convert '%+"PRIsVALUE"' to string for Tk", obj); return obj; } @@ -1247,7 +1246,7 @@ each_attr_def(key, value, klass) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1246 switch(TYPE(key)) { case T_STRING: - key_id = rb_intern(RSTRING_PTR(key)); + key_id = rb_intern_str(key); break; case T_SYMBOL: key_id = SYM2ID(key); @@ -1259,7 +1258,7 @@ each_attr_def(key, value, klass) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1258 switch(TYPE(value)) { case T_STRING: - value_id = rb_intern(RSTRING_PTR(value)); + value_id = rb_intern_str(value); break; case T_SYMBOL: value_id = SYM2ID(value); @@ -1299,7 +1298,7 @@ cbsubst_sym_to_subst(self, sym) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1298 VALUE sym; { struct cbsubst_info *inf; - const char *str; + VALUE str; char *buf, *ptr; int idx; long len; @@ -1312,12 +1311,12 @@ cbsubst_sym_to_subst(self, sym) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1311 struct cbsubst_info, inf); if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) { - str = rb_id2name(SYM2ID(ret)); + str = rb_id2str(SYM2ID(ret)); } else { - str = rb_id2name(SYM2ID(sym)); + str = rb_id2str(SYM2ID(sym)); } - id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str))); + id = rb_intern_str(rb_sprintf("@%"PRIsVALUE, str)); for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) { if (inf->ivar[idx] == id) break; @@ -1354,7 +1353,7 @@ cbsubst_get_subst_arg(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1353 VALUE self; { struct cbsubst_info *inf; - const char *str; + VALUE str; char *buf, *ptr; int i, idx; long len; @@ -1369,28 +1368,28 @@ cbsubst_get_subst_arg(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1368 for(i = 0; i < argc; i++) { switch(TYPE(argv[i])) { case T_STRING: - str = RSTRING_PTR(argv[i]); - arg_sym = ID2SYM(rb_intern(str)); + str = argv[i]; + arg_sym = ID2SYM(rb_intern_str(argv[i])); break; case T_SYMBOL: arg_sym = argv[i]; - str = rb_id2name(SYM2ID(arg_sym)); + str = rb_id2str(SYM2ID(arg_sym)); break; default: rb_raise(rb_eArgError, "arg #%d is not a String or a Symbol", i); } if (!NIL_P(ret = rb_hash_aref(inf->aliases, arg_sym))) { - str = rb_id2name(SYM2ID(ret)); + str = rb_id2str(SYM2ID(ret)); } - id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str))); + id = rb_intern_str(rb_sprintf("@%"PRIsVALUE, str)); for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) { if (inf->ivar[idx] == id) break; } if (idx >= CBSUBST_TBL_MAX) { - rb_raise(rb_eArgError, "cannot find attribute :%s", str); + rb_raise(rb_eArgError, "cannot find attribute :%"PRIsVALUE, str); } *(ptr++) = '%'; @@ -1572,7 +1571,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1571 subst_inf->full_subst_length += 3; id = SYM2ID(RARRAY_PTR(inf)[2]); - subst_inf->ivar[chr] = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), rb_id2name(id)))); + subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id))); rb_attr(self, id, 1, 0, Qtrue); } @@ -1611,7 +1610,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/tk/tkutil/tkutil.c#L1610 subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2); id = SYM2ID(RARRAY_PTR(inf)[2]); - subst_inf->ivar[chr] = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), rb_id2name(id)))); + subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id))); rb_attr(self, id, 1, 0, Qtrue); } Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 44563) +++ ruby_2_0_0/version.h (revision 44564) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2014-01-07" -#define RUBY_PATCHLEVEL 378 +#define RUBY_RELEASE_DATE "2014-01-12" +#define RUBY_PATCHLEVEL 379 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 12 #include "ruby/version.h" Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r41351 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/