summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c12
-rw-r--r--ext/bigdecimal/extconf.rb1
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index da1b24a631..430707a4d6 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2560,6 +2560,10 @@ BigDecimal_clone(VALUE self)
return self;
}
+#ifdef HAVE_RB_OPTS_EXCEPTION_P
+int rb_opts_exception_p(VALUE opts, int default_value);
+#define opts_exception_p(opts) rb_opts_exception_p((opts), 1)
+#else
static int
opts_exception_p(VALUE opts)
{
@@ -2569,8 +2573,16 @@ opts_exception_p(VALUE opts)
kwds[0] = rb_intern_const("exception");
}
rb_get_kwargs(opts, kwds, 0, 1, &exception);
+ switch (exception) {
+ case Qtrue: case Qfalse:
+ break;
+ default:
+ rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE,
+ flagname, obj);
+ }
return exception != Qfalse;
}
+#endif
static Real *
BigDecimal_new(int argc, VALUE *argv)
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index a6a36304cc..7a7af10a2d 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -27,6 +27,7 @@ have_func("rb_rational_num", "ruby.h")
have_func("rb_rational_den", "ruby.h")
have_func("rb_array_const_ptr", "ruby.h")
have_func("rb_sym2str", "ruby.h")
+have_func("rb_opts_exception_p", "ruby.h")
if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__))
bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb"