diff options
author | Jeremy Evans <code@jeremyevans.net> | 2021-09-23 12:31:32 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2021-10-02 05:51:29 -0900 |
commit | 3f7da458a77f270d96e6a9f82177d6c90476c34d (patch) | |
tree | 24a13661f2ac94f9c4bf2437c1e7c241c3275b9e /encoding.c | |
parent | e0ef4899f3ef2561ae32275c2c3d11914e7343c7 (diff) |
Make encoding loading not issue warning
Instead of relying on setting an unsetting ruby_verbose, which is
not thread-safe, restructure require_internal and load_lock to
accept a warn argument for whether to warn, and add
rb_require_internal_silent to require without warnings. Use
rb_require_internal_silent when loading encoding.
Note this does not modify ruby_debug and errinfo handling, those
remain thread-unsafe.
Also silent requires when loading transcoders.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4887
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c index bc3d2f78f2..a162821e64 100644 --- a/encoding.c +++ b/encoding.c @@ -797,11 +797,12 @@ rb_enc_get_from_index(int index) return must_encindex(index); } +int rb_require_internal_silent(VALUE fname); + static int load_encoding(const char *name) { VALUE enclib = rb_sprintf("enc/%s.so", name); - VALUE verbose = ruby_verbose; VALUE debug = ruby_debug; VALUE errinfo; char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3; @@ -814,11 +815,9 @@ load_encoding(const char *name) ++s; } enclib = rb_fstring(enclib); - ruby_verbose = Qfalse; ruby_debug = Qfalse; errinfo = rb_errinfo(); - loaded = rb_require_internal(enclib); - ruby_verbose = verbose; + loaded = rb_require_internal_silent(enclib); ruby_debug = debug; rb_set_errinfo(errinfo); |