Skip to content

Commit

Permalink
feature_option: do not goto into a branch
Browse files Browse the repository at this point in the history
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
  • Loading branch information
shyouhei committed Jun 29, 2020
1 parent 689dd3a commit 7cf4625
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ruby.c
Expand Up @@ -911,9 +911,7 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable)
if (NAME_MATCH_P(#bit, str, len)) {set |= mask = FEATURE_BIT(bit); FEATURE_FOUND;}
EACH_FEATURES(SET_FEATURE, ;);
if (NAME_MATCH_P("all", str, len)) {
found:
FEATURE_SET_TO(*argp, mask, (mask & enable));
return;
goto found;
}
#if AMBIGUOUS_FEATURE_NAMES
if (matched == 1) goto found;
Expand All @@ -933,6 +931,11 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable)
rb_warn("unknown argument for --%s: `%.*s'",
enable ? "enable" : "disable", len, str);
rb_warn("features are [%.*s].", (int)strlen(list), list);
return;

found:
FEATURE_SET_TO(*argp, mask, (mask & enable));
return;
}

static void
Expand Down

0 comments on commit 7cf4625

Please sign in to comment.