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

ruby-changes:61159

From: Nobuyoshi <ko1@a...>
Date: Sat, 9 May 2020 14:01:46 +0900 (JST)
Subject: [ruby-changes:61159] 0ce45db115 (master): [ruby/io-console] Show path name at error

https://git.ruby-lang.org/ruby.git/commit/?id=0ce45db115

From 0ce45db11536ecba8cc6a4d46ac448b162a96d51 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 9 May 2020 13:40:08 +0900
Subject: [ruby/io-console] Show path name at error

https://github.com/ruby/io-console/commit/6a4b1c1a6d

diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 9baad2b..58652d9 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -80,6 +80,8 @@ static ID id_getc, id_console, id_close, id_min, id_time, id_intr; https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L80
 static ID id_gets;
 #endif
 
+#define sys_fail_fptr(fptr) rb_sys_fail_str((fptr)->pathv)
+
 #ifndef HAVE_RB_F_SEND
 static ID id___send__;
 
@@ -410,9 +412,9 @@ console_set_raw(int argc, VALUE *argv, VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L412
 
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!getattr(fd, &t)) rb_sys_fail(0);
+    if (!getattr(fd, &t)) sys_fail_fptr(fptr);
     set_rawmode(&t, optp);
-    if (!setattr(fd, &t)) rb_sys_fail(0);
+    if (!setattr(fd, &t)) sys_fail_fptr(fptr);
     return io;
 }
 
@@ -453,9 +455,9 @@ console_set_cooked(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L455
 
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!getattr(fd, &t)) rb_sys_fail(0);
+    if (!getattr(fd, &t)) sys_fail_fptr(fptr);
     set_cookedmode(&t, NULL);
-    if (!setattr(fd, &t)) rb_sys_fail(0);
+    if (!setattr(fd, &t)) sys_fail_fptr(fptr);
     return io;
 }
 
@@ -590,12 +592,12 @@ console_set_echo(VALUE io, VALUE f) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L592
 
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!getattr(fd, &t)) rb_sys_fail(0);
+    if (!getattr(fd, &t)) sys_fail_fptr(fptr);
     if (RTEST(f))
 	set_echo(&t, NULL);
     else
 	set_noecho(&t, NULL);
-    if (!setattr(fd, &t)) rb_sys_fail(0);
+    if (!setattr(fd, &t)) sys_fail_fptr(fptr);
     return io;
 }
 
@@ -616,7 +618,7 @@ console_echo_p(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L618
 
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!getattr(fd, &t)) rb_sys_fail(0);
+    if (!getattr(fd, &t)) rb_sys_fail_str(fptr->pathv);
     return echo_p(&t) ? Qtrue : Qfalse;
 }
 
@@ -700,7 +702,7 @@ console_conmode_get(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L702
 
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!getattr(fd, &t)) rb_sys_fail(0);
+    if (!getattr(fd, &t)) sys_fail_fptr(fptr);
 
     return conmode_new(cConmode, &t);
 }
@@ -724,7 +726,7 @@ console_conmode_set(VALUE io, VALUE mode) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L726
     r = *t;
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
-    if (!setattr(fd, &r)) rb_sys_fail(0);
+    if (!setattr(fd, &r)) sys_fail_fptr(fptr);
 
     return mode;
 }
@@ -766,7 +768,7 @@ console_winsize(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L768
 
     GetOpenFile(io, fptr);
     fd = GetWriteFD(fptr);
-    if (!getwinsize(fd, &ws)) rb_sys_fail(0);
+    if (!getwinsize(fd, &ws)) sys_fail_fptr(fptr);
     return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws)));
 }
 
@@ -813,7 +815,7 @@ console_set_winsize(VALUE io, VALUE size) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L815
     SET(xpixel);
     SET(ypixel);
 #undef SET
-    if (!setwinsize(fd, &ws)) rb_sys_fail(0);
+    if (!setwinsize(fd, &ws)) sys_fail_fptr(fptr);
 #elif defined _WIN32
     wh = (HANDLE)rb_w32_get_osfhandle(fd);
 #define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
@@ -888,7 +890,7 @@ console_iflush(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L890
     GetOpenFile(io, fptr);
     fd = GetReadFD(fptr);
 #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
-    if (tcflush(fd, TCIFLUSH)) rb_sys_fail(0);
+    if (tcflush(fd, TCIFLUSH)) sys_fail_fptr(fptr);
 #endif
     (void)fd;
     return io;
@@ -911,7 +913,7 @@ console_oflush(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L913
     GetOpenFile(io, fptr);
     fd = GetWriteFD(fptr);
 #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
-    if (tcflush(fd, TCOFLUSH)) rb_sys_fail(0);
+    if (tcflush(fd, TCOFLUSH)) sys_fail_fptr(fptr);
 #endif
     (void)fd;
     return io;
@@ -938,11 +940,11 @@ console_ioflush(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L940
     fd1 = GetReadFD(fptr);
     fd2 = GetWriteFD(fptr);
     if (fd2 != -1 && fd1 != fd2) {
-	if (tcflush(fd1, TCIFLUSH)) rb_sys_fail(0);
-	if (tcflush(fd2, TCOFLUSH)) rb_sys_fail(0);
+	if (tcflush(fd1, TCIFLUSH)) sys_fail_fptr(fptr);
+	if (tcflush(fd2, TCOFLUSH)) sys_fail_fptr(fptr);
     }
     else {
-	if (tcflush(fd1, TCIOFLUSH)) rb_sys_fail(0);
+	if (tcflush(fd1, TCIOFLUSH)) sys_fail_fptr(fptr);
     }
 #endif
     return io;
@@ -961,7 +963,7 @@ console_beep(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L963
     MessageBeep(0);
 #else
     if (write(fd, "\a", 1) < 0)
-	rb_sys_fail(0);
+	sys_fail_fptr(fptr);
 #endif
     return io;
 }
-- 
cgit v0.10.2


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

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