summaryrefslogtreecommitdiff
path: root/sprintf.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 /sprintf.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 'sprintf.c')
-rw-r--r--sprintf.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sprintf.c b/sprintf.c
index 4549791..afe27c2 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1338,6 +1338,26 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
}
if (sign == '+') {
+ if (RB_TYPE_P(value, T_CLASS)) {
+# define LITERAL(str) (*sz = rb_strlen_lit(str), str)
+
+ if (value == rb_cNilClass) {
+ return LITERAL("nil");
+ }
+ else if (value == rb_cFixnum) {
+ return LITERAL("Fixnum");
+ }
+ else if (value == rb_cSymbol) {
+ return LITERAL("Symbol");
+ }
+ else if (value == rb_cTrueClass) {
+ return LITERAL("true");
+ }
+ else if (value == rb_cFalseClass) {
+ return LITERAL("false");
+ }
+# undef LITERAL
+ }
value = rb_inspect(value);
}
else {