summaryrefslogtreecommitdiff
path: root/xmake/core/sandbox/modules/string.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-06-29 20:33:15 +0800
committerruki <[email protected]>2017-06-29 20:33:15 +0800
commit9d5bd8e4576431ffe3cbfb63be33dedacc32223f (patch)
tree701771277f378ccd23d02ff5c35afb7b869fa78b /xmake/core/sandbox/modules/string.lua
parent0f9ddb186bff17c0c430118860503532b72c5cce (diff)
fix vformat with args and %% format
Diffstat (limited to 'xmake/core/sandbox/modules/string.lua')
-rw-r--r--xmake/core/sandbox/modules/string.lua5
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, ...)