aboutsummaryrefslogtreecommitdiffstats
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-14 02:35:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-14 02:35:51 +0000
commitc05fa459bb9f77c4fecdd230e8d1379cc997975e (patch)
tree6150004feae5cbc52d874119c7b61362b490100b /sprintf.c
parent251c7892c15082078b8db3607155b262ad8ea490 (diff)
downloadruby-c05fa459bb9f77c4fecdd230e8d1379cc997975e.tar.gz
quote symbols
* sprintf.c (ruby__sfvextra): quote symbols as identifiers. * string.c (rb_id_quote_unprintable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sprintf.c b/sprintf.c
index e91d1f7e88..eed2c92282 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1378,6 +1378,12 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
}
value = rb_inspect(value);
}
+ else if (SYMBOL_P(value)) {
+ value = rb_sym2str(value);
+ if (sign == ' ' && !rb_str_symname_p(value)) {
+ value = rb_str_inspect(value);
+ }
+ }
else {
value = rb_obj_as_string(value);
if (sign == ' ') value = QUOTE(value);