summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-15 14:27:29 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commite9cb092b2d4ce21dbf124ea614adaa13e12178f0 (patch)
treece53a0281521078f0f7461f6ee477963c1aba464 /file.c
parent4606ec4925756d9e7b7c9648787d614be3102ced (diff)
rb_f_stat: 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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'file.c')
-rw-r--r--file.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/file.c b/file.c
index 74f2552fedd..ccfb3c18501 100644
--- a/file.c
+++ b/file.c
@@ -5299,14 +5299,7 @@ rb_f_test(int argc, VALUE *argv, VALUE _)
if (argc == 0) rb_check_arity(argc, 2, 3);
cmd = NUM2CHR(argv[0]);
if (cmd == 0) {
- unknown:
- /* unknown command */
- if (ISPRINT(cmd)) {
- rb_raise(rb_eArgError, "unknown command '%s%c'", cmd == '\'' || cmd == '\\' ? "\\" : "", cmd);
- }
- else {
- rb_raise(rb_eArgError, "unknown command \"\\x%02X\"", cmd);
- }
+ goto unknown;
}
if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) {
CHECK(1);
@@ -5432,7 +5425,14 @@ rb_f_test(int argc, VALUE *argv, VALUE _)
return Qfalse;
}
}
- goto unknown;
+ unknown:
+ /* unknown command */
+ if (ISPRINT(cmd)) {
+ rb_raise(rb_eArgError, "unknown command '%s%c'", cmd == '\'' || cmd == '\\' ? "\\" : "", cmd);
+ }
+ else {
+ rb_raise(rb_eArgError, "unknown command \"\\x%02X\"", cmd);
+ }
}