summaryrefslogtreecommitdiff
path: root/eval_error.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 16:53:02 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 16:53:02 +0000
commitc6816d074b89131797e842a312f302037bcfbb9c (patch)
tree608dbc9a13d6c8839cbc37a86b0f848ce3151ad1 /eval_error.c
parent6df2fbf0f6c4efa68865bec69598894f89d61d0b (diff)
merge revision(s) r41598,r45181:
* eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific extensions like PRIsVALUE can be used in format strings * eval_error.c (error_print): use warn_print_str (alias for rb_write_error_str) to print a string value instead of using RSTRING_PTR and RSTRING_LEN manually * eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR * eval.c (setup_exception): preserve exception class name encoding in debug mode messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/eval_error.c b/eval_error.c
index c7ccf82a0a..54d6db9fb8 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -6,17 +6,18 @@
static void
warn_printf(const char *fmt, ...)
{
- char buf[BUFSIZ];
+ VALUE str;
va_list args;
va_init_list(args, fmt);
- vsnprintf(buf, BUFSIZ, fmt, args);
+ str = rb_vsprintf(fmt, args);
va_end(args);
- rb_write_error(buf);
+ rb_write_error_str(str);
}
#define warn_print(x) rb_write_error(x)
#define warn_print2(x,l) rb_write_error2((x),(l))
+#define warn_print_str(x) rb_write_error_str(x)
static void
error_pos(void)
@@ -117,7 +118,7 @@ error_print(void)
if (NIL_P(mesg))
error_pos();
else {
- warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg));
+ warn_print_str(mesg);
}
}
@@ -143,7 +144,7 @@ error_print(void)
epath = rb_class_name(eclass);
if (elen == 0) {
warn_print(": ");
- warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+ warn_print_str(epath);
warn_print("\n");
}
else {
@@ -160,7 +161,7 @@ error_print(void)
warn_print2(einfo, len);
if (epath) {
warn_print(" (");
- warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+ warn_print_str(epath);
warn_print(")\n");
}
if (tail) {
@@ -182,7 +183,7 @@ error_print(void)
for (i = 1; i < len; i++) {
if (RB_TYPE_P(ptr[i], T_STRING)) {
- warn_printf("\tfrom %s\n", RSTRING_PTR(ptr[i]));
+ warn_printf("\tfrom %"PRIsVALUE"\n", ptr[i]);
}
if (skip && i == TRACE_HEAD && len > TRACE_MAX) {
warn_printf("\t ... %ld levels...\n",