summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
commit6125313d69c158b423d1f4aff2e206cfd43a036a (patch)
treea1a78a9425305557dcff6569806876989c9098c3 /error.c
parentf5a7f85917abed4d64ad908a4837e0db0499c951 (diff)
* array.c (push_values_at): Array#values_at should work with
ranges too. * range.c (rb_range_beg_len): length calculation was wrong. * eval.c (rb_call): should set T_ICLASS in the frame->last_class. [ruby-core:01110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/error.c b/error.c
index e2d1430..d9c673c 100644
--- a/error.c
+++ b/error.c
@@ -26,26 +26,33 @@
int ruby_nerrs;
-static void
-err_snprintf(buf, len, fmt, args)
+static int
+err_position(buf, len)
char *buf;
long len;
- const char *fmt;
- va_list args;
{
- long n;
-
ruby_set_current_source();
if (!ruby_sourcefile) {
- vsnprintf(buf, len, fmt, args);
- return;
+ return 0;
}
else if (ruby_sourceline == 0) {
- n = snprintf(buf, len, "%s: ", ruby_sourcefile);
+ return snprintf(buf, len, "%s: ", ruby_sourcefile);
}
else {
- n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
+ return snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
}
+}
+
+static void
+err_snprintf(buf, len, fmt, args)
+ char *buf;
+ long len;
+ const char *fmt;
+ va_list args;
+{
+ long n;
+
+ n = err_position(buf, len);
if (len > n) {
vsnprintf((char*)buf+n, len-n, fmt, args);
}
@@ -151,6 +158,15 @@ rb_warning(fmt, va_alist)
va_end(args);
}
+static VALUE
+rb_warn_m(self, mesg)
+ VALUE self, mesg;
+{
+ rb_io_write(rb_deferr, mesg);
+ rb_io_write(rb_deferr, rb_default_rs);
+ return mesg;
+}
+
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_bug(const char *fmt, ...)
@@ -653,6 +669,8 @@ Init_Exception()
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
init_syserr();
+
+ rb_define_global_function("warn", rb_warn_m, 1);
}
void