Make %{define foo body} not use the free-field parsing
This means no special new line processing and '\' unescaping. Thus "%{define foo body}" works similar to "%define foo {body}" except that the parsing in spec files works because copyNextLineFromOFI() knows how to deal with macros.
This commit is contained in:
parent
374c0edac0
commit
c00d85fb5e
|
@ -662,7 +662,11 @@ doDefine(MacroBuf mb, const char * se, int level, int expandbody, size_t *parsed
|
|||
b = be = oe + 1;
|
||||
sbody = s;
|
||||
SKIPBLANK(s, c);
|
||||
if (c == '{') { /* XXX permit silent {...} grouping */
|
||||
if (!parsed) {
|
||||
strcpy(b, s);
|
||||
be = b + strlen(b);
|
||||
s += strlen(s);
|
||||
} else if (c == '{') { /* XXX permit silent {...} grouping */
|
||||
if ((se = matchchar(s, c, '}')) == NULL) {
|
||||
mbErr(mb, 1, _("Macro %%%s has unterminated body\n"), n);
|
||||
se = s; /* XXX W2DO? */
|
||||
|
@ -1718,10 +1722,11 @@ static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
|||
{
|
||||
MacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||
int rc;
|
||||
size_t parsed = 0;
|
||||
|
||||
/* XXX just enough to get by */
|
||||
mb->mc = mc;
|
||||
doDefine(mb, macro, level, 0, NULL);
|
||||
doDefine(mb, macro, level, 0, &parsed);
|
||||
rc = mb->error;
|
||||
_free(mb);
|
||||
return rc;
|
||||
|
|
|
@ -313,6 +313,8 @@ runroot rpm --eval "%{getncpus:5}"
|
|||
runroot rpm --eval "%{define:}"
|
||||
runroot rpm --eval "%{define:foo}"
|
||||
runroot rpm --eval "%{define:foo bar}%{foo}"
|
||||
runroot rpm --eval "%{define foo}"
|
||||
runroot rpm --eval "%{define foo bar baz\baz}%{foo}"
|
||||
runroot rpm --eval "%{dump:foo}"
|
||||
runroot rpm --eval "%{shrink:%%%%}"
|
||||
runroot rpm --eval "%{shrink %%%%}"
|
||||
|
@ -326,6 +328,7 @@ dir
|
|||
/hello/%%
|
||||
|
||||
bar
|
||||
bar baz\baz
|
||||
%%
|
||||
%%
|
||||
%%
|
||||
|
@ -337,6 +340,7 @@ error: %getncpus: unexpected argument
|
|||
error: %getncpus: unexpected argument
|
||||
error: Macro % has illegal name (%define)
|
||||
error: Macro %foo has empty body
|
||||
error: Macro %foo has empty body
|
||||
error: %dump: unexpected argument
|
||||
])
|
||||
AT_CLEANUP
|
||||
|
|
Loading…
Reference in New Issue