aboutsummaryrefslogtreecommitdiffstats
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-25 12:36:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-25 12:36:24 +0000
commita487415e39e5cd15a326c48dda37504aef4c3849 (patch)
treed893c685c54ccdabff07c7d84913ebed795d3bcb /eval_error.c
parentac2cff19cb9a6638a33273c1d83d481f2a08605b (diff)
downloadruby-a487415e39e5cd15a326c48dda37504aef4c3849.tar.gz
eval_error.c: remove warn_printf
* eval_error.c (warn_printf): remove. * eval_error.c (error_pos_str): return error position string, split from error_pos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/eval_error.c b/eval_error.c
index 5d203d69a8..3b50123651 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -3,42 +3,42 @@
* included by eval.c
*/
-static void
-warn_printf(const char *fmt, ...)
-{
- VALUE str;
- va_list args;
-
- va_init_list(args, fmt);
- str = rb_vsprintf(fmt, args);
- va_end(args);
- 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 VALUE error_pos_str(void);
+
static void
error_pos(void)
{
+ VALUE str = error_pos_str();
+ if (!NIL_P(str)) {
+ warn_print_str(str);
+ }
+}
+
+static VALUE
+error_pos_str(void)
+{
int sourceline;
VALUE sourcefile = rb_source_location(&sourceline);
if (sourcefile) {
ID caller_name;
if (sourceline == 0) {
- warn_printf("%"PRIsVALUE": ", sourcefile);
+ return rb_sprintf("%"PRIsVALUE": ", sourcefile);
}
else if ((caller_name = rb_frame_callee()) != 0) {
- warn_printf("%"PRIsVALUE":%d:in `%"PRIsVALUE"': ",
- sourcefile, sourceline,
- rb_id2str(caller_name));
+ return rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"': ",
+ sourcefile, sourceline,
+ rb_id2str(caller_name));
}
else {
- warn_printf("%"PRIsVALUE":%d: ", sourcefile, sourceline);
+ return rb_sprintf("%"PRIsVALUE":%d: ", sourcefile, sourceline);
}
}
+ return Qnil;
}
static VALUE
@@ -173,11 +173,11 @@ error_print(void)
for (i = 1; i < len; i++) {
VALUE line = RARRAY_AREF(errat, i);
if (RB_TYPE_P(line, T_STRING)) {
- warn_printf("\tfrom %"PRIsVALUE"\n", line);
+ warn_print_str(rb_sprintf("\tfrom %"PRIsVALUE"\n", line));
}
if (skip && i == TRACE_HEAD && len > TRACE_MAX) {
- warn_printf("\t ... %ld levels...\n",
- len - TRACE_HEAD - TRACE_TAIL);
+ warn_print_str(rb_sprintf("\t ... %ld levels...\n",
+ len - TRACE_HEAD - TRACE_TAIL));
i = len - TRACE_TAIL;
}
}