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

ruby-changes:37576

From: naruse <ko1@a...>
Date: Fri, 20 Feb 2015 17:11:56 +0900 (JST)
Subject: [ruby-changes:37576] naruse:r49657 (ruby_2_2): merge revision(s) 49479, 49483, 49526, 49527:

naruse	2015-02-20 17:11:40 +0900 (Fri, 20 Feb 2015)

  New Revision: 49657

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

  Log:
    merge revision(s) 49479,49483,49526,49527:
    
    remove duplication in warning
    
    * dir.c (sys_warning_1): remove duplication in the message.
    * error.c (rb_mod_sys_fail_str): ditto.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/dir.c
    branches/ruby_2_2/error.c
    branches/ruby_2_2/internal.h
    branches/ruby_2_2/version.h
Index: ruby_2_2/dir.c
===================================================================
--- ruby_2_2/dir.c	(revision 49656)
+++ ruby_2_2/dir.c	(revision 49657)
@@ -1084,7 +1084,7 @@ dir_s_rmdir(VALUE obj, VALUE dir) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L1084
 static VALUE
 sys_warning_1(VALUE mesg)
 {
-    rb_sys_warning("%s:%s", strerror(errno), (const char *)mesg);
+    rb_sys_warning("%s", (const char *)mesg);
     return Qnil;
 }
 
Index: ruby_2_2/error.c
===================================================================
--- ruby_2_2/error.c	(revision 49656)
+++ ruby_2_2/error.c	(revision 49657)
@@ -198,10 +198,10 @@ rb_compile_warning(const char *file, int https://github.com/ruby/ruby/blob/trunk/ruby_2_2/error.c#L198
     va_end(args);
 }
 
-static void
-warn_print(const char *fmt, va_list args)
+static VALUE
+warning_string(rb_encoding *enc, const char *fmt, va_list args)
 {
-    VALUE str = rb_str_new(0, 0);
+    VALUE str = rb_enc_str_new(0, 0, enc);
     VALUE file = rb_sourcefilename();
 
     if (!NIL_P(file)) {
@@ -214,33 +214,69 @@ warn_print(const char *fmt, va_list args https://github.com/ruby/ruby/blob/trunk/ruby_2_2/error.c#L214
     rb_str_cat2(str, "warning: ");
     rb_str_vcatf(str, fmt, args);
     rb_str_cat2(str, "\n");
-    rb_write_error_str(str);
+    return str;
 }
 
 void
 rb_warn(const char *fmt, ...)
 {
+    VALUE mesg;
+    va_list args;
+
+    if (NIL_P(ruby_verbose)) return;
+
+    va_start(args, fmt);
+    mesg = warning_string(0, fmt, args);
+    va_end(args);
+    rb_write_error_str(mesg);
+}
+
+#if 0
+void
+rb_enc_warn(rb_encoding *enc, const char *fmt, ...)
+{
+    VALUE mesg;
     va_list args;
 
     if (NIL_P(ruby_verbose)) return;
 
     va_start(args, fmt);
-    warn_print(fmt, args);
+    mesg = warning_string(enc, fmt, args);
     va_end(args);
+    rb_write_error_str(mesg);
 }
+#endif
 
 /* rb_warning() reports only in verbose mode */
 void
 rb_warning(const char *fmt, ...)
 {
+    VALUE mesg;
+    va_list args;
+
+    if (!RTEST(ruby_verbose)) return;
+
+    va_start(args, fmt);
+    mesg = warning_string(0, fmt, args);
+    va_end(args);
+    rb_write_error_str(mesg);
+}
+
+#if 0
+void
+rb_enc_warning(rb_encoding *enc, const char *fmt, ...)
+{
+    VALUE mesg;
     va_list args;
 
     if (!RTEST(ruby_verbose)) return;
 
     va_start(args, fmt);
-    warn_print(fmt, args);
+    mesg = warning_string(enc, fmt, args);
     va_end(args);
+    rb_write_error_str(mesg);
 }
+#endif
 
 /*
  * call-seq:
@@ -2088,7 +2124,7 @@ rb_mod_syserr_fail_str(VALUE mod, int e, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/error.c#L2124
 void
 rb_sys_warning(const char *fmt, ...)
 {
-    char buf[BUFSIZ];
+    VALUE mesg;
     va_list args;
     int errno_save;
 
@@ -2096,12 +2132,32 @@ rb_sys_warning(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/error.c#L2132
 
     if (!RTEST(ruby_verbose)) return;
 
-    snprintf(buf, BUFSIZ, "warning: %s", fmt);
-    snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
+    va_start(args, fmt);
+    mesg = warning_string(0, fmt, args);
+    va_end(args);
+    rb_str_set_len(mesg, RSTRING_LEN(mesg)-1);
+    rb_str_catf(mesg, ": %s\n", strerror(errno_save));
+    rb_write_error_str(mesg);
+    errno = errno_save;
+}
+
+void
+rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...)
+{
+    VALUE mesg;
+    va_list args;
+    int errno_save;
+
+    errno_save = errno;
+
+    if (!RTEST(ruby_verbose)) return;
 
     va_start(args, fmt);
-    warn_print(buf, args);
+    mesg = warning_string(enc, fmt, args);
     va_end(args);
+    rb_str_set_len(mesg, RSTRING_LEN(mesg)-1);
+    rb_str_catf(mesg, ": %s\n", strerror(errno_save));
+    rb_write_error_str(mesg);
     errno = errno_save;
 }
 
Index: ruby_2_2/internal.h
===================================================================
--- ruby_2_2/internal.h	(revision 49656)
+++ ruby_2_2/internal.h	(revision 49657)
@@ -627,6 +627,9 @@ VALUE rb_check_backtrace(VALUE); https://github.com/ruby/ruby/blob/trunk/ruby_2_2/internal.h#L627
 NORETURN(void rb_async_bug_errno(const char *,int));
 const char *rb_builtin_type_name(int t);
 const char *rb_builtin_class_name(VALUE x);
+PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
+PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
+PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
 
 /* eval.c */
 VALUE rb_refinement_module_get_refined_class(VALUE module);
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49656)
+++ ruby_2_2/version.h	(revision 49657)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
 #define RUBY_RELEASE_DATE "2015-02-20"
-#define RUBY_PATCHLEVEL 65
+#define RUBY_PATCHLEVEL 66
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49479,49483,49526-49527


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

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