Remove duplicated code in macro expansion
The code for macro existence checking and flag processing is exactly the same.
This commit is contained in:
parent
abcb0af241
commit
7d3a87ca18
|
@ -1492,35 +1492,18 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Special processing for flags */
|
/* XXX Special processing for flags and existance test */
|
||||||
if (*f == '-') {
|
if (*f == '-' || chkexist) {
|
||||||
if ((me == NULL && !negate) || /* Without -f, skip %{-f...} */
|
if ((me == NULL && !negate) || /* Without existance, skip %{?...} */
|
||||||
(me != NULL && negate)) { /* With -f, skip %{!-f...} */
|
(me != NULL && negate)) { /* With existance, skip %{!?...} */
|
||||||
s = se;
|
s = se;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g && g < ge) { /* Expand X in %{-f:X} */
|
if (g && g < ge) { /* Expand X in %{...:X} */
|
||||||
expandMacro(mb, g, gn);
|
expandMacro(mb, g, gn);
|
||||||
} else
|
} 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;
|
|
||||||
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*} */
|
|
||||||
expandMacro(mb, me->body, 0);
|
expandMacro(mb, me->body, 0);
|
||||||
}
|
}
|
||||||
s = se;
|
s = se;
|
||||||
|
|
Loading…
Reference in New Issue