diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2022-11-13 11:01:09 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-11-13 02:02:02 +0000 |
commit | ef1c6109b12b78926b7cb31cd8b0d27b629a35c4 (patch) | |
tree | eeba5ba082d3dd6e1735913b3aa59a6bb8dea01c /ext/bigdecimal | |
parent | 74c6e6e565aad4cbf2e5b7a13c21e78361808404 (diff) | |
download | ruby-ef1c6109b12b78926b7cb31cd8b0d27b629a35c4.tar.gz |
[ruby/bigdecimal] Tweak check_rounding_mode_option
https://github.com/ruby/bigdecimal/commit/e1c6c9be25
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 40a825dfc7..5ae0b96ab4 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -630,18 +630,19 @@ check_rounding_mode_option(VALUE const opts) assert(RB_TYPE_P(opts, T_HASH)); if (NIL_P(opts)) - goto noopt; + goto no_opt; mode = rb_hash_lookup2(opts, ID2SYM(id_half), Qundef); if (mode == Qundef || NIL_P(mode)) - goto noopt; + goto no_opt; if (SYMBOL_P(mode)) mode = rb_sym2str(mode); else if (!RB_TYPE_P(mode, T_STRING)) { - VALUE str_mode = rb_check_string_type(mode); - if (NIL_P(str_mode)) goto invalid; - mode = str_mode; + VALUE str_mode = rb_check_string_type(mode); + if (NIL_P(str_mode)) + goto invalid; + mode = str_mode; } s = RSTRING_PTR(mode); l = RSTRING_LEN(mode); @@ -659,13 +660,11 @@ check_rounding_mode_option(VALUE const opts) default: break; } + invalid: - if (NIL_P(mode)) - rb_raise(rb_eArgError, "invalid rounding mode: nil"); - else - rb_raise(rb_eArgError, "invalid rounding mode: %"PRIsVALUE, mode); + rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", mode); - noopt: + no_opt: return VpGetRoundMode(); } |