зеркало из https://github.com/github/ruby.git
Set backtrace length limit at last
Command line options should have higher precedence than the same options in shebang and `RUBYOPT`.
This commit is contained in:
Родитель
dbbc3583ba
Коммит
db3b8f84f5
|
@ -23,6 +23,7 @@ typedef struct ruby_cmdline_options {
|
|||
ruby_features_t features;
|
||||
ruby_features_t warn;
|
||||
unsigned int dump;
|
||||
int backtrace_length_limit;
|
||||
#if USE_RJIT
|
||||
struct rb_rjit_options rjit;
|
||||
#endif
|
||||
|
|
11
ruby.c
11
ruby.c
|
@ -217,6 +217,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
|
|||
#elif defined(YJIT_FORCE_ENABLE)
|
||||
opt->features.set |= FEATURE_BIT(yjit);
|
||||
#endif
|
||||
opt->backtrace_length_limit = -1;
|
||||
|
||||
return opt;
|
||||
}
|
||||
|
@ -892,6 +893,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;
|
||||
int backtrace_length_limit = opt->backtrace_length_limit;
|
||||
|
||||
opt->src.enc.name = opt->ext.enc.name = opt->intern.enc.name = 0;
|
||||
|
||||
|
@ -941,6 +943,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 >= 0) {
|
||||
opt->backtrace_length_limit = backtrace_length_limit;
|
||||
}
|
||||
|
||||
ruby_xfree(ptr);
|
||||
/* get rid of GC */
|
||||
|
@ -1445,7 +1450,7 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
|
|||
char *e;
|
||||
long n = strtol(s, &e, 10);
|
||||
if (errno == ERANGE || n < 0 || *e) rb_raise(rb_eRuntimeError, "wrong limit for backtrace length");
|
||||
rb_backtrace_length_limit = n;
|
||||
opt->backtrace_length_limit = (int)n;
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eRuntimeError,
|
||||
|
@ -2329,6 +2334,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
}
|
||||
if (opt->dump & dump_exit_bits) return Qtrue;
|
||||
|
||||
if (opt->backtrace_length_limit >= 0) {
|
||||
rb_backtrace_length_limit = opt->backtrace_length_limit;
|
||||
}
|
||||
|
||||
rb_define_readonly_boolean("$-p", opt->do_print);
|
||||
rb_define_readonly_boolean("$-l", opt->do_line);
|
||||
rb_define_readonly_boolean("$-a", opt->do_split);
|
||||
|
|
Загрузка…
Ссылка в новой задаче