summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-17 14:28:54 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commitb5eeb3453e7c3047ce3e4f39e8ae89af4fafb16f (patch)
tree30463c63cc4464d4b6ef74c41885d954c6721bb7 /signal.c
parent224e9c383598a9f09a5fa5736a098be538316311 (diff)
downloadruby-b5eeb3453e7c3047ce3e4f39e8ae89af4fafb16f.tar.gz
trap_handler: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/signal.c b/signal.c
index 5361b8c232..d479ca90dc 100644
--- a/signal.c
+++ b/signal.c
@@ -1209,6 +1209,14 @@ trap_handler(VALUE *cmd, int sig)
*cmd = command;
RSTRING_GETMEM(command, cptr, len);
switch (len) {
+ sig_ign:
+ func = SIG_IGN;
+ *cmd = Qtrue;
+ break;
+ sig_dfl:
+ func = default_handler(sig);
+ *cmd = 0;
+ break;
case 0:
goto sig_ign;
break;
@@ -1223,14 +1231,10 @@ trap_handler(VALUE *cmd, int sig)
break;
case 7:
if (memcmp(cptr, "SIG_IGN", 7) == 0) {
-sig_ign:
- func = SIG_IGN;
- *cmd = Qtrue;
+ goto sig_ign;
}
else if (memcmp(cptr, "SIG_DFL", 7) == 0) {
-sig_dfl:
- func = default_handler(sig);
- *cmd = 0;
+ goto sig_dfl;
}
else if (memcmp(cptr, "DEFAULT", 7) == 0) {
goto sig_dfl;