%trace mb states at the beginning/end of expandMacro must be equal
Macro %trace switched on in a nested stage level writes the trace until the level is leaved to a lower stage level. This did not work e.g. for macros containing several condition macros. For example: %prep %define Branch1() {%trace %global Leaf1 "1"} %define Branch2() {%global Leaf2 "2"} %define Main() {%{?test1: %Branch1} %{?test1: %Branch2}} %Main with the result: 4> %global^Leaf1 "1" 2> %{?test1: %Branch2}^ 3> %Branch2^ 4> %global^Leaf2 "2" It was because macro expansion is context free. This patch fixes it.
This commit is contained in:
parent
b052d69474
commit
fa39cb730d
|
@ -985,6 +985,8 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
|
|||
const char * lastc;
|
||||
int chkexist;
|
||||
char *source = NULL;
|
||||
int store_macro_trace;
|
||||
int store_expand_trace;
|
||||
|
||||
/*
|
||||
* Always make a (terminated) copy of the source string.
|
||||
|
@ -1007,6 +1009,8 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
|
|||
mb->nb = blen;
|
||||
}
|
||||
tpos = mb->tpos; /* save expansion pointer for printExpand */
|
||||
store_macro_trace = mb->macro_trace;
|
||||
store_expand_trace = mb->expand_trace;
|
||||
|
||||
if (++mb->depth > max_macro_depth) {
|
||||
rpmlog(RPMLOG_ERR,
|
||||
|
@ -1317,6 +1321,8 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
|
|||
mb->depth--;
|
||||
if (mb->error != 0 || mb->expand_trace)
|
||||
printExpansion(mb, mb->buf+tpos, mb->buf+mb->tpos);
|
||||
mb->macro_trace = store_macro_trace;
|
||||
mb->expand_trace = store_expand_trace;
|
||||
exit:
|
||||
_free(source);
|
||||
return mb->error;
|
||||
|
|
Loading…
Reference in New Issue