summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-28 02:40:46 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-28 02:40:46 (GMT)
commit4191a6b90d3eeb63a31609dba29a1904efee3738 (patch)
tree6689e8d252ca17f1f90626d7ade4b144dbfccdd7 /time.c
parent7d49923e9e9a9d1a01f3183fd798258e9d289da0 (diff)
preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/time.c b/time.c
index c1c7369..11c76a5 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;
}