1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
卜部昌平 2020-06-17 14:28:54 +09:00
parent 224e9c3835
commit b5eeb3453e
Notes: git 2020-06-29 11:06:50 +09:00

View file

@ -1209,6 +1209,14 @@ trap_handler(VALUE *cmd, int sig)
*cmd = command; *cmd = command;
RSTRING_GETMEM(command, cptr, len); RSTRING_GETMEM(command, cptr, len);
switch (len) { switch (len) {
sig_ign:
func = SIG_IGN;
*cmd = Qtrue;
break;
sig_dfl:
func = default_handler(sig);
*cmd = 0;
break;
case 0: case 0:
goto sig_ign; goto sig_ign;
break; break;
@ -1223,14 +1231,10 @@ trap_handler(VALUE *cmd, int sig)
break; break;
case 7: case 7:
if (memcmp(cptr, "SIG_IGN", 7) == 0) { if (memcmp(cptr, "SIG_IGN", 7) == 0) {
sig_ign: goto sig_ign;
func = SIG_IGN;
*cmd = Qtrue;
} }
else if (memcmp(cptr, "SIG_DFL", 7) == 0) { else if (memcmp(cptr, "SIG_DFL", 7) == 0) {
sig_dfl: goto sig_dfl;
func = default_handler(sig);
*cmd = 0;
} }
else if (memcmp(cptr, "DEFAULT", 7) == 0) { else if (memcmp(cptr, "DEFAULT", 7) == 0) {
goto sig_dfl; goto sig_dfl;