diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-13 01:00:16 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-13 02:26:49 +0900 |
commit | b56e5c6b9425a19c04d4e59410463155ea9db30c (patch) | |
tree | b7f39cb10c560fa5d0cf39519969a2b262f60c15 /ruby.c | |
parent | 546c5cfe4ce1335cb45f8e7b6d6da317c61509e7 (diff) |
Fix the precedence of `--backtrace-limit` option
In general, if the same option specifying a single value is given
multiple times at the same level, the last one overrides the earlier
ones, unless prohibited.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8212
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -897,6 +897,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) VALUE int_enc_name = opt->intern.enc.name; ruby_features_t feat = opt->features; ruby_features_t warn = opt->warn; + long backtrace_length_limit = opt->backtrace_length_limit; while (ISSPACE(*s)) s++; if (!*s) return; @@ -947,6 +948,9 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) } FEATURE_SET_RESTORE(opt->features, feat); FEATURE_SET_RESTORE(opt->warn, warn); + if (BACKTRACE_LENGTH_LIMIT_VALID_P(backtrace_length_limit)) { + opt->backtrace_length_limit = backtrace_length_limit; + } ruby_xfree(ptr); /* get rid of GC */ @@ -1453,7 +1457,7 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char ** if (errno == ERANGE || !BACKTRACE_LENGTH_LIMIT_VALID_P(n) || *e) { rb_raise(rb_eRuntimeError, "wrong limit for backtrace length"); } - else if (!OPT_BACKTRACE_LENGTH_LIMIT_VALID_P(opt)) { + else { opt->backtrace_length_limit = n; } } |