summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-04 23:28:16 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-04 23:28:16 +0000
commit56f6c15dabadbb5d4cc0ba90ea3ee69210400511 (patch)
treec26a729bc65f6a03daa362f453b1d3740abb1857
parent6638b504b1ea1d092a75d02aa20674e540dd4b53 (diff)
backported a part of a569bc09e25a2ba813d0bec1228d9ff65330a3db
picked up by Jeremy Evans [Backport #17305] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--eval.c66
-rw-r--r--version.h2
2 files changed, 40 insertions, 28 deletions
diff --git a/eval.c b/eval.c
index 1eeaec56cb..47c9cac2b7 100644
--- a/eval.c
+++ b/eval.c
@@ -896,38 +896,20 @@ rb_need_block(void)
}
}
-/*! An equivalent of \c rescue clause.
- *
- * Equivalent to <code>begin .. rescue err_type .. end</code>
- *
- * \param[in] b_proc a function which potentially raises an exception.
- * \param[in] data1 the argument of \a b_proc
- * \param[in] r_proc a function which rescues an exception in \a b_proc.
- * \param[in] data2 the first argument of \a r_proc
- * \param[in] ... 1 or more exception classes. Must be terminated by \c (VALUE)0.
- *
- * First it calls the function \a b_proc, with \a data1 as the argument.
- * When \a b_proc raises an exception, it calls \a r_proc with \a data2 and
- * the exception object if the exception is a kind of one of the given
- * exception classes.
- *
- * \return the return value of \a b_proc if no exception occurs,
- * or the return value of \a r_proc if otherwise.
- * \sa rb_rescue
- * \sa rb_ensure
- * \sa rb_protect
- * \ingroup exception
+/*!
+ * \copydoc rb_rescue2
+ * \param[in] args exception classes, terminated by 0.
*/
-VALUE
-rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
- VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
+static VALUE
+rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
+ VALUE (* r_proc) (VALUE, VALUE), VALUE data2,
+ va_list args)
{
enum ruby_tag_type state;
rb_execution_context_t * volatile ec = GET_EC();
rb_control_frame_t *volatile cfp = ec->cfp;
volatile VALUE result = Qfalse;
volatile VALUE e_info = ec->errinfo;
- va_list args;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
@@ -950,14 +932,12 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
int handle = FALSE;
VALUE eclass;
- va_init_list(args, data2);
while ((eclass = va_arg(args, VALUE)) != 0) {
if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
handle = TRUE;
break;
}
}
- va_end(args);
if (handle) {
result = Qnil;
@@ -978,6 +958,38 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
/*! An equivalent of \c rescue clause.
*
+ * Equivalent to <code>begin .. rescue err_type .. end</code>
+ *
+ * \param[in] b_proc a function which potentially raises an exception.
+ * \param[in] data1 the argument of \a b_proc
+ * \param[in] r_proc a function which rescues an exception in \a b_proc.
+ * \param[in] data2 the first argument of \a r_proc
+ * \param[in] ... 1 or more exception classes. Must be terminated by \c (VALUE)0.
+ *
+ * First it calls the function \a b_proc, with \a data1 as the argument.
+ * When \a b_proc raises an exception, it calls \a r_proc with \a data2 and
+ * the exception object if the exception is a kind of one of the given
+ * exception classes.
+ *
+ * \return the return value of \a b_proc if no exception occurs,
+ * or the return value of \a r_proc if otherwise.
+ * \sa rb_rescue
+ * \sa rb_ensure
+ * \sa rb_protect
+ * \ingroup exception
+ */
+VALUE
+rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
+ VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
+{
+ va_list ap;
+ va_start(ap, data2);
+ return rb_vrescue2((VALUE (*)(VALUE))b_proc, data1, (VALUE (*)(VALUE, VALUE))r_proc, data2, ap);
+ va_end(ap);
+}
+
+/*! An equivalent of \c rescue clause.
+ *
* Equivalent to <code>begin .. rescue .. end</code>.
*
* It is same as
diff --git a/version.h b/version.h
index c4d0636924..b64ba5ea84 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.6.7"
#define RUBY_RELEASE_DATE "2021-04-05"
-#define RUBY_PATCHLEVEL 181
+#define RUBY_PATCHLEVEL 182
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 4