summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-27 13:33:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-27 13:33:27 +0000
commita5729ea05a55c86142c57dbb176638c0e4f54cc6 (patch)
tree0adf25b73524bc22d66a0e7af4881dae5488f8f1 /error.c
parent0ec868314558e7b0583235a3fd363c767bb35ecc (diff)
* error.c (rb_bug): should not use other methods; this function is
not for ordinary use. [ruby-dev:21259] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/error.c b/error.c
index e1f62aa..2e40408 100644
--- a/error.c
+++ b/error.c
@@ -111,10 +111,12 @@ warn_print(fmt, args)
va_list args;
{
char buf[BUFSIZ];
+ int len;
err_snprintf(buf, BUFSIZ, fmt, args);
- rb_write_error(buf);
- rb_write_error("\n");
+ len = strlen(buf);
+ buf[len++] = '\n';
+ rb_write_error2(buf, len);
}
void
@@ -180,16 +182,18 @@ rb_bug(fmt, va_alist)
{
char buf[BUFSIZ];
va_list args;
-
- snprintf(buf, BUFSIZ, "[BUG] %s", fmt);
- ruby_in_eval = 0;
-
- va_init_list(args, fmt);
- warn_print(buf, args);
- va_end(args);
- snprintf(buf, BUFSIZ, "ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
- rb_write_error(buf);
- rb_write_error("\n");
+ FILE *out = stderr;
+ int len = err_position(buf, BUFSIZ);
+
+ if (fwrite(buf, 1, len, out) == len ||
+ fwrite(buf, 1, len, (out = stdout)) == len) {
+ fputs("[BUG] ", out);
+ va_init_list(args, fmt);
+ vfprintf(out, fmt, args);
+ va_end(args);
+ fprintf(out, "\nruby %s (%s) [%s]\n\n",
+ RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
+ }
abort();
}
@@ -758,7 +762,7 @@ rb_sys_fail(mesg)
errno = 0;
if (n == 0) {
- rb_bug("rb_sys_fail() - errno == 0");
+ rb_bug("rb_sys_fail(%s) - errno == 0", mesg ? mesg : "");
}
arg = mesg ? rb_str_new2(mesg) : Qnil;