diff options
| author | ruki <[email protected]> | 2017-06-13 20:51:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-13 20:51:15 +0800 |
| commit | 0ee5a8ae20143a27ca051e56712beeddb02e7b4a (patch) | |
| tree | 7b56ea1b629a0d37b7124fb7abaafdeb273ffd8a /xmake/core/base | |
| parent | 48529599248c9bdd43b53def4be7113d226060ef (diff) | |
fix filter escape and find_path bug
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/filter.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/xmake/core/base/filter.lua b/xmake/core/base/filter.lua index f9744bf61..465a55499 100644 --- a/xmake/core/base/filter.lua +++ b/xmake/core/base/filter.lua @@ -31,6 +31,10 @@ local table = require("base/table") local utils = require("base/utils") local string = require("base/string") +-- globals +local escape_table1 = {["$"] = "\001", ["("] = "\002", [")"] = "\003"} +local escape_table2 = {["\001"] = "$", ["\002"] = "(", ["\003"] = ")"} + -- new filter instance function filter.new() @@ -155,10 +159,19 @@ function filter:handle(value) -- check assert(type(value) == "string") + -- escape "%$", "%(", "%)" to "\001", "\002", "\003" + value = value:gsub("%%([%$%(%)])", function (ch) return escape_table1[ch] end) + -- filter the builtin variables return (value:gsub("%$%((.-)%)", function (variable) + + -- escape "%$", "%(", "%)" to "$", "(", ")" + variable = variable:gsub("[\001\002\003]", function (ch) return escape_table2[ch] end) + + -- get variable value return self:get(variable) or "" - end)) + + end):gsub("[\001\002\003]", function (ch) return escape_table2[ch] end)) end -- return module: filter |
