Remove duplicated code in macro expansion

The code for macro existence checking and flag processing
is exactly the same.
This commit is contained in:
Michael Schroeder 2020-02-06 21:17:08 +01:00 committed by Panu Matilainen
parent abcb0af241
commit 7d3a87ca18
1 changed files with 6 additions and 23 deletions

View File

@ -1492,35 +1492,18 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
}
}
/* XXX Special processing for flags */
if (*f == '-') {
if ((me == NULL && !negate) || /* Without -f, skip %{-f...} */
(me != NULL && negate)) { /* With -f, skip %{!-f...} */
/* XXX Special processing for flags and existance test */
if (*f == '-' || chkexist) {
if ((me == NULL && !negate) || /* Without existance, skip %{?...} */
(me != NULL && negate)) { /* With existance, skip %{!?...} */
s = se;
continue;
}
if (g && g < ge) { /* Expand X in %{-f:X} */
if (g && g < ge) { /* Expand X in %{...:X} */
expandMacro(mb, g, gn);
} else
if (me && me->body && *me->body) {/* Expand %{-f}/%{-f*} */
expandMacro(mb, me->body, 0);
}
s = se;
continue;
}
/* XXX Special processing for macro existence */
if (chkexist) {
if ((me == NULL && !negate) || /* Without -f, skip %{?f...} */
(me != NULL && negate)) { /* With -f, skip %{!?f...} */
s = se;
continue;
}
if (g && g < ge) { /* Expand X in %{?f:X} */
expandMacro(mb, g, gn);
} else
if (me && me->body && *me->body) { /* Expand %{?f}/%{?f*} */
if (me && me->body && *me->body) {/* Expand macro body */
expandMacro(mb, me->body, 0);
}
s = se;