diff options
| author | ruki <[email protected]> | 2021-12-24 22:23:35 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-24 22:23:35 +0800 |
| commit | 6ab8485ac0e8bf702cc15a278085e8e1b7e6f6a7 (patch) | |
| tree | 30603b21acf457707802e0cadd25e4a05e70c656 | |
| parent | fce3e08add943d72d3af8e6e11e8e006585266a3 (diff) | |
Update filter.lua
| -rw-r--r-- | xmake/core/base/filter.lua | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/xmake/core/base/filter.lua b/xmake/core/base/filter.lua index d7595679c..f0dae3061 100644 --- a/xmake/core/base/filter.lua +++ b/xmake/core/base/filter.lua @@ -171,15 +171,21 @@ function filter:handle(value) value = value:gsub("%%([%$%(%)%%])", function (ch) return escape_table1[ch] end) -- filter the builtin variables - return (value:gsub("%$%((.-)%)", function (variable) - + local values = {} + local variables = {} + value:gsub("%$%((.-)%)", function (variable) + table.insert(variables, variable) + end) + -- we cannot call self:get() in gsub, because it will trigger "attempt to yield a c-call boundary" + for _, variable in ipairs(variables) do -- escape "%$", "%(", "%)", "%%" to "$", "(", ")", "%" - variable = variable:gsub("[\001\002\003\004]", function (ch) return escape_table2[ch] end) - - -- get variable value - return self:get(variable) or "" - - end):gsub("[\001\002\003\004]", function (ch) return escape_table2[ch] end)) + local name = variable:gsub("[\001\002\003\004]", function (ch) return escape_table2[ch] end) + values[variable] = self:get(name) or "" + end + value = value:gsub("%$%((.-)%)", function (variable) + return values[variable] + end) + return value:gsub("[\001\002\003\004]", function (ch) return escape_table2[ch] end) end -- return module: filter |
