summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-04-25 15:00:09 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-04-25 15:00:09 +0900
commit8464cac63cce822245f76284a48d35343b680507 (patch)
tree8d1ea23c299ce535ce31567774463b70df2c48c6
parentf0bea86437e46cec11d1fe5f9c3ab7ab8933161d (diff)
downloadmruby-8464cac63cce822245f76284a48d35343b680507.tar.gz
mruby-8464cac63cce822245f76284a48d35343b680507.zip
remove calling sprintf(); ref #1210
-rw-r--r--src/string.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index be8e449c9..5152eadb3 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2348,8 +2348,12 @@ mrb_str_dump(mrb_state *mrb, mrb_value str)
*q++ = c;
}
else {
+ int oct = c & 0xff;
+
*q++ = '\\';
- sprintf(q, "%03o", c&0xff);
+ q[2] = '0' + oct % 8; oct /= 8;
+ q[1] = '0' + oct % 8; oct /= 8;
+ q[0] = '0' + oct % 8;
q += 3;
}
}