ruby-changes:49531
From: nobu <ko1@a...>
Date: Sun, 7 Jan 2018 13:10:12 +0900 (JST)
Subject: [ruby-changes:49531] nobu:r61646 (trunk): io.c: rb_stderr_to_original_p
nobu 2018-01-07 13:10:06 +0900 (Sun, 07 Jan 2018) New Revision: 61646 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61646 Log: io.c: rb_stderr_to_original_p * io.c (rb_stderr_to_original_p): hoist out the condition to write messages to the stderr FD directly. Modified files: trunk/io.c Index: io.c =================================================================== --- io.c (revision 61645) +++ io.c (revision 61646) @@ -7763,10 +7763,16 @@ rb_obj_display(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/io.c#L7763 return Qnil; } +static int +rb_stderr_to_original_p(void) +{ + return (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0); +} + void rb_write_error2(const char *mesg, long len) { - if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) { + if (rb_stderr_to_original_p()) { #ifdef _WIN32 if (isatty(fileno(stderr))) { if (rb_w32_write_console(rb_str_new(mesg, len), fileno(stderr)) > 0) return; @@ -7792,7 +7798,7 @@ void https://github.com/ruby/ruby/blob/trunk/io.c#L7798 rb_write_error_str(VALUE mesg) { /* a stopgap measure for the time being */ - if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) { + if (rb_stderr_to_original_p()) { size_t len = (size_t)RSTRING_LEN(mesg); #ifdef _WIN32 if (isatty(fileno(stderr))) { @@ -7813,7 +7819,7 @@ rb_write_error_str(VALUE mesg) https://github.com/ruby/ruby/blob/trunk/io.c#L7819 int rb_stderr_tty_p(void) { - if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) + if (rb_stderr_to_original_p()) return isatty(fileno(stderr)); return 0; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/