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:
parent
224e9c3835
commit
b5eeb3453e
Notes:
git
2020-06-29 11:06:50 +09:00
1 changed files with 10 additions and 6 deletions
16
signal.c
16
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;
|
||||
|
|
Loading…
Reference in a new issue