[前][次][番号順一覧][スレッド一覧]

ruby-changes:69536

From: S.H <ko1@a...>
Date: Sat, 30 Oct 2021 19:24:59 +0900 (JST)
Subject: [ruby-changes:69536] a46c220320 (master): Add `rb_mod_exc_raise` function and replace duplicate code

https://git.ruby-lang.org/ruby.git/commit/?id=a46c220320

From a46c220320778c29612b80ebf2fee28a81eaa380 Mon Sep 17 00:00:00 2001
From: "S.H" <gamelinks007@g...>
Date: Sat, 30 Oct 2021 19:24:41 +0900
Subject: Add `rb_mod_exc_raise` function and replace duplicate code

---
 error.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/error.c b/error.c
index 65bf1721a2a..f9433ebe501 100644
--- a/error.c
+++ b/error.c
@@ -3188,36 +3188,41 @@ rb_syserr_new_path_in(const char *func_name, int n, VALUE path) https://github.com/ruby/ruby/blob/trunk/error.c#L3188
 }
 #endif
 
+NORETURN(static void rb_mod_exc_raise(VALUE exc, VALUE mod));
+
+static void
+rb_mod_exc_raise(VALUE exc, VALUE mod)
+{
+    rb_extend_object(exc, mod);
+    rb_exc_raise(exc);
+}
+
 void
 rb_mod_sys_fail(VALUE mod, const char *mesg)
 {
     VALUE exc = make_errno_exc(mesg);
-    rb_extend_object(exc, mod);
-    rb_exc_raise(exc);
+    rb_mod_exc_raise(exc, mod);
 }
 
 void
 rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
 {
     VALUE exc = make_errno_exc_str(mesg);
-    rb_extend_object(exc, mod);
-    rb_exc_raise(exc);
+    rb_mod_exc_raise(exc, mod);
 }
 
 void
 rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
 {
     VALUE exc = rb_syserr_new(e, mesg);
-    rb_extend_object(exc, mod);
-    rb_exc_raise(exc);
+    rb_mod_exc_raise(exc, mod);
 }
 
 void
 rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
 {
     VALUE exc = rb_syserr_new_str(e, mesg);
-    rb_extend_object(exc, mod);
-    rb_exc_raise(exc);
+    rb_mod_exc_raise(exc, mod);
 }
 
 static void
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]