ruby-changes:65766
From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 08:28:28 +0900 (JST)
Subject: [ruby-changes:65766] 56f6c15dab (ruby_2_6): backported a part of a569bc09e25a2ba813d0bec1228d9ff65330a3db
https://git.ruby-lang.org/ruby.git/commit/?id=56f6c15dab From 56f6c15dabadbb5d4cc0ba90ea3ee69210400511 Mon Sep 17 00:00:00 2001 From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Sun, 4 Apr 2021 23:28:16 +0000 Subject: 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 --- eval.c | 66 +++++++++++++++++++++++++++++++++++++-------------------------- version.h | 2 +- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/eval.c b/eval.c index 1eeaec5..47c9cac 100644 --- a/eval.c +++ b/eval.c @@ -896,38 +896,20 @@ rb_need_block(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L896 } } -/*! 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, https://github.com/ruby/ruby/blob/trunk/eval.c#L932 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, https://github.com/ruby/ruby/blob/trunk/eval.c#L958 /*! 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 c4d0636..b64ba5e 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/