summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-02-02 15:08:10 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-02-22 11:55:40 +0900
commit98ca99cdd090d17b7ec11e0c6f40936a728165a5 (patch)
tree257e74ddef4e448410b9d525ddbe0e226616a925 /error.c
parent35ff545bb689f5af93ac603ea1f512705e0dc249 (diff)
downloadruby-98ca99cdd090d17b7ec11e0c6f40936a728165a5.tar.gz
The default highlight arguments of Exception#detailed_message is false
Diffstat (limited to 'error.c')
-rw-r--r--error.c15
1 files 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)
}
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)
}
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)
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)
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));
}
/*