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

ruby-changes:71237

From: Yusuke <ko1@a...>
Date: Tue, 22 Feb 2022 11:56:09 +0900 (JST)
Subject: [ruby-changes:71237] 98ca99cdd0 (master): The default highlight arguments of Exception#detailed_message is false

https://git.ruby-lang.org/ruby.git/commit/?id=98ca99cdd0

From 98ca99cdd090d17b7ec11e0c6f40936a728165a5 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Wed, 2 Feb 2022 15:08:10 +0900
Subject: The default highlight arguments of Exception#detailed_message is
 false

---
 error.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/error.c b/error.c
index be4c37cbac..6f925158ce 100644
--- a/error.c
+++ b/error.c
@@ -1263,7 +1263,7 @@ exc_s_to_tty_p(VALUE self) https://github.com/ruby/ruby/blob/trunk/error.c#L1263
 }
 
 static VALUE
-check_highlight_keyword(VALUE opt)
+check_highlight_keyword(VALUE opt, int auto_tty_detect)
 {
     VALUE highlight = Qnil;
 
@@ -1283,7 +1283,12 @@ check_highlight_keyword(VALUE opt) https://github.com/ruby/ruby/blob/trunk/error.c#L1283
     }
 
     if (NIL_P(highlight)) {
-	highlight = rb_stderr_tty_p() ? Qtrue : Qfalse;
+        if (auto_tty_detect) {
+            highlight = rb_stderr_tty_p() ? Qtrue : Qfalse;
+        }
+        else {
+            highlight = Qfalse;
+        }
     }
 
     return highlight;
@@ -1342,7 +1347,7 @@ exc_full_message(int argc, VALUE *argv, VALUE exc) https://github.com/ruby/ruby/blob/trunk/error.c#L1347
 
     rb_scan_args(argc, argv, "0:", &opt);
 
-    highlight = check_highlight_keyword(opt);
+    highlight = check_highlight_keyword(opt, 1);
     order = check_order_keyword(opt);
 
     str = rb_str_new2("");
@@ -1392,11 +1397,11 @@ exc_detailed_message(int argc, VALUE *argv, VALUE exc) https://github.com/ruby/ruby/blob/trunk/error.c#L1397
 
     rb_scan_args(argc, argv, "0:", &opt);
 
-    VALUE highlight = check_highlight_keyword(opt);
+    VALUE highlight = check_highlight_keyword(opt, 0);
 
     extern VALUE rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight);
 
-    return rb_decorate_message(CLASS_OF(exc), rb_get_message(exc), highlight);
+    return rb_decorate_message(CLASS_OF(exc), rb_get_message(exc), RTEST(highlight));
 }
 
 /*
-- 
cgit v1.2.1


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

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