[前][次][番号順一覧][スレッド一覧]

ruby-changes:46373

From: nobu <ko1@a...>
Date: Wed, 26 Apr 2017 17:11:38 +0900 (JST)
Subject: [ruby-changes:46373] nobu:r58487 (trunk): error.c: splat warn arguments

nobu	2017-04-26 17:11:32 +0900 (Wed, 26 Apr 2017)

  New Revision: 58487

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58487

  Log:
    error.c: splat warn arguments
    
    * error.c (rb_warn_m): print array arguments with splatting.
      it is often used with `caller`.
      [ruby-core:80849] [Feature #12944]

  Modified files:
    trunk/error.c
Index: error.c
===================================================================
--- error.c	(revision 58486)
+++ error.c	(revision 58487)
@@ -302,18 +302,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/error.c#L302
 rb_warn_m(int argc, VALUE *argv, VALUE exc)
 {
     if (!NIL_P(ruby_verbose) && argc > 0) {
-	int i;
-	VALUE str;
-	for (i = 0; i < argc; i++) {
-	    str = rb_obj_as_string(argv[i]);
-	    if (RSTRING_LEN(str) == 0) {
-		str = rb_default_rs;
-	    }
-	    else if (!rb_str_end_with_asciichar(str, '\n')) {
-		str = rb_str_cat(rb_str_dup(str), "\n", 1);
-	    }
-	    rb_write_warning_str(str);
-	}
+	rb_io_puts(argc, argv, rb_mWarning);
     }
     return Qnil;
 }
@@ -2187,6 +2176,7 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L2176
 
     rb_mWarning = rb_define_module("Warning");
     rb_define_method(rb_mWarning, "warn", rb_warning_s_warn, 1);
+    rb_define_method(rb_mWarning, "write", rb_warning_s_warn, 1);
     rb_extend_object(rb_mWarning, rb_mWarning);
 
     rb_define_global_function("warn", rb_warn_m, -1);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]