* compile.c (make_name_for_block): use PRIsVALUE in format string

instead of %s and RSTRING_PTR to protect objects from being garbage
  collected too soon
* encoding.c (str_to_encindex): ditto
* hash.c (rb_hash_fetch_m): ditto
* io.c (rb_io_reopen): ditto
* parse.y (reg_fragment_check_gen): ditto
* parse.y (reg_compile_gen): ditto
* parse.y (ripper_assert_Qundef): ditto
* re.c (rb_reg_raise): ditto
* ruby.c (set_option_encoding_once): ditto
* vm_eval.c (rb_throw_obj): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
charliesome 2013-06-24 11:31:21 +00:00
Родитель 8f15f58210
Коммит fff3589899
9 изменённых файлов: 28 добавлений и 15 удалений

Просмотреть файл

@ -1,3 +1,18 @@
Mon Jun 24 20:31:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
* compile.c (make_name_for_block): use PRIsVALUE in format string
instead of %s and RSTRING_PTR to protect objects from being garbage
collected too soon
* encoding.c (str_to_encindex): ditto
* hash.c (rb_hash_fetch_m): ditto
* io.c (rb_io_reopen): ditto
* parse.y (reg_fragment_check_gen): ditto
* parse.y (reg_compile_gen): ditto
* parse.y (ripper_assert_Qundef): ditto
* re.c (rb_reg_raise): ditto
* ruby.c (set_option_encoding_once): ditto
* vm_eval.c (rb_throw_obj): ditto
Mon Jun 24 07:57:18 2013 Masaya Tarui <tarui@ruby-lang.org>
* gc.c (after_gc_sweep): Have to record malloc info before reset.

Просмотреть файл

@ -2999,10 +2999,10 @@ make_name_for_block(rb_iseq_t *iseq)
}
if (level == 1) {
return rb_sprintf("block in %s", RSTRING_PTR(ip->location.label));
return rb_sprintf("block in %"PRIsVALUE, ip->location.label);
}
else {
return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->location.label));
return rb_sprintf("block (%d levels) in %"PRIsVALUE, level, ip->location.label);
}
}

Просмотреть файл

@ -179,7 +179,7 @@ str_to_encindex(VALUE enc)
{
int idx = str_find_encindex(enc);
if (idx < 0) {
rb_raise(rb_eArgError, "unknown encoding name - %s", RSTRING_PTR(enc));
rb_raise(rb_eArgError, "unknown encoding name - %"PRIsVALUE, enc);
}
return idx;
}

2
hash.c
Просмотреть файл

@ -716,7 +716,7 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
desc = rb_any_to_s(key);
}
desc = rb_str_ellipsize(desc, 65);
rb_raise(rb_eKeyError, "key not found: %s", RSTRING_PTR(desc));
rb_raise(rb_eKeyError, "key not found: %"PRIsVALUE, desc);
}
return if_none;
}

6
io.c
Просмотреть файл

@ -6554,15 +6554,15 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
rb_fd_fix_cloexec(fptr->fd);
#ifdef USE_SETVBUF
if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0)
rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
#endif
if (fptr->stdio_file == stderr) {
if (setvbuf(fptr->stdio_file, NULL, _IONBF, BUFSIZ) != 0)
rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
}
else if (fptr->stdio_file == stdout && isatty(fptr->fd)) {
if (setvbuf(fptr->stdio_file, NULL, _IOLBF, BUFSIZ) != 0)
rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
}
}
else {

Просмотреть файл

@ -9740,8 +9740,7 @@ reg_fragment_check_gen(struct parser_params* parser, VALUE str, int options)
err = rb_reg_check_preprocess(str);
if (err != Qnil) {
err = rb_obj_as_string(err);
compile_error(PARSER_ARG "%s", RSTRING_PTR(err));
RB_GC_GUARD(err);
compile_error(PARSER_ARG "%"PRIsVALUE, err);
return 0;
}
return 1;
@ -9844,7 +9843,7 @@ reg_compile_gen(struct parser_params* parser, VALUE str, int options)
rb_str_append(rb_str_cat(rb_attr_get(err, mesg), "\n", 1), m);
}
else {
compile_error(PARSER_ARG "%s", RSTRING_PTR(m));
compile_error(PARSER_ARG "%"PRIsVALUE, m);
}
return Qnil;
}
@ -11400,7 +11399,7 @@ ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
{
StringValue(msg);
if (obj == Qundef) {
rb_raise(rb_eArgError, "%s", RSTRING_PTR(msg));
rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
}
return Qnil;
}

2
re.c
Просмотреть файл

@ -610,7 +610,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
{
volatile VALUE desc = rb_reg_desc(s, len, re);
rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_PTR(desc));
rb_raise(rb_eRegexpError, "%s: %"PRIsVALUE, err, desc);
}
static VALUE

2
ruby.c
Просмотреть файл

@ -765,7 +765,7 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
if (*name &&
rb_funcall(ename, rb_intern("casecmp"), 1, *name) != INT2FIX(0)) {
rb_raise(rb_eRuntimeError,
"%s already set to %s", type, RSTRING_PTR(*name));
"%s already set to %"PRIsVALUE, type, *name);
}
*name = ename;
}

Просмотреть файл

@ -1740,8 +1740,7 @@ rb_throw_obj(VALUE tag, VALUE value)
}
if (!tt) {
VALUE desc = rb_inspect(tag);
RB_GC_GUARD(desc);
rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
rb_raise(rb_eArgError, "uncaught throw %"PRIsVALUE, desc);
}
th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW);