From 4191a6b90d3eeb63a31609dba29a1904efee3738 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 28 Sep 2015 02:40:46 +0000 Subject: preserve encodings in error messages git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'time.c') diff --git a/time.c b/time.c index c1c73699a0..11c76a5bac 100644 --- a/time.c +++ b/time.c @@ -202,8 +202,8 @@ divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r) tmp = rb_funcall(n, id_divmod, 1, d); ary = rb_check_array_type(tmp); if (NIL_P(ary)) { - rb_raise(rb_eTypeError, "unexpected divmod result: into %s", - rb_obj_classname(tmp)); + rb_raise(rb_eTypeError, "unexpected divmod result: into %"PRIsVALUE, + rb_obj_class(tmp)); } *q = rb_ary_entry(ary, 0); *r = rb_ary_entry(ary, 1); @@ -560,8 +560,8 @@ wdivmod(wideval_t wn, wideval_t wd, wideval_t *wq, wideval_t *wr) tmp = rb_funcall(w2v(wn), id_divmod, 1, w2v(wd)); ary = rb_check_array_type(tmp); if (NIL_P(ary)) { - rb_raise(rb_eTypeError, "unexpected divmod result: into %s", - rb_obj_classname(tmp)); + rb_raise(rb_eTypeError, "unexpected divmod result: into %"PRIsVALUE, + rb_obj_class(tmp)); } *wq = v2w(rb_ary_entry(ary, 0)); *wr = v2w(rb_ary_entry(ary, 1)); @@ -641,8 +641,10 @@ num_exact(VALUE v) default: typeerror: - rb_raise(rb_eTypeError, "can't convert %s into an exact number", - NIL_P(v) ? "nil" : rb_obj_classname(v)); + if (NIL_P(v)) + rb_raise(rb_eTypeError, "can't convert nil into an exact number"); + rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into an exact number", + rb_obj_class(v)); } return v; } @@ -2322,7 +2324,7 @@ static struct timespec time_timespec(VALUE num, int interval) { struct timespec t; - const char *tstr = interval ? "time interval" : "time"; + const char *const tstr = interval ? "time interval" : "time"; VALUE i, f, ary; #ifndef NEGATIVE_TIME_T @@ -2382,8 +2384,8 @@ time_timespec(VALUE num, int interval) t.tv_nsec = NUM2LONG(f); } else { - rb_raise(rb_eTypeError, "can't convert %s into %s", - rb_obj_classname(num), tstr); + rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into %s", + rb_obj_class(num), tstr); } break; } -- cgit v1.2.3