summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-24 16:15:42 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-24 16:15:42 (GMT)
commit80aaa3ef6c87a4cbb13c92097ee5170a663d4175 (patch)
tree76af43a7bb8a549f6e27eec6281b60efc59f9ffb /sprintf.c
parent8996556b058b64226e15284d55f87640586b4315 (diff)
sprintf.c: inspect by plus
* sprintf.c (ruby__sfvextra): [EXPERIMENTAL] use inspect instead of to_s if plus flag is given. * vsnprintf.c (BSD_vfprintf): pass sign flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index d705566..c3fc395 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1178,7 +1178,7 @@ ruby__sfvwrite(register rb_printf_buffer *fp, register struct __suio *uio)
}
static char *
-ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz)
+ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int sign)
{
VALUE value, result = (VALUE)fp->_bf._base;
rb_encoding *enc;
@@ -1189,7 +1189,12 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz)
if (RBASIC(result)->klass) {
rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
}
- value = rb_obj_as_string(value);
+ if (sign == '+') {
+ value = rb_inspect(value);
+ }
+ else {
+ value = rb_obj_as_string(value);
+ }
enc = rb_enc_compatible(result, value);
if (enc) {
rb_enc_associate(result, enc);