diff options
| author | ruki <[email protected]> | 2017-06-29 20:33:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-29 20:33:15 +0800 |
| commit | 9d5bd8e4576431ffe3cbfb63be33dedacc32223f (patch) | |
| tree | 701771277f378ccd23d02ff5c35afb7b869fa78b /xmake/core/sandbox/modules/string.lua | |
| parent | 0f9ddb186bff17c0c430118860503532b72c5cce (diff) | |
fix vformat with args and %% format
Diffstat (limited to 'xmake/core/sandbox/modules/string.lua')
| -rw-r--r-- | xmake/core/sandbox/modules/string.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/xmake/core/sandbox/modules/string.lua b/xmake/core/sandbox/modules/string.lua index d698c9e71..2506ae35e 100644 --- a/xmake/core/sandbox/modules/string.lua +++ b/xmake/core/sandbox/modules/string.lua @@ -23,6 +23,7 @@ -- -- load modules +local utils = require("base/utils") local string = require("base/string") local sandbox = require("sandbox/sandbox") @@ -50,8 +51,8 @@ function sandbox_string.vformat(format, ...) local result = format if #{...} > 0 then - -- escape "%$", "%(", "%)" to '$', '(', ')' - format = format:gsub("%%([%$%(%)])", "%%%%%1") + -- escape "%$", "%(", "%)", "%%" to '$', '(', ')', '%%' + format = format:gsub("%%([%$%(%)%%])", function (ch) return utils.ifelse(ch ~= "%", "%%" .. ch, "%%%%") end) -- try to format it result = string.format(format, ...) |
