From 9d5bd8e4576431ffe3cbfb63be33dedacc32223f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 29 Jun 2017 20:33:15 +0800 Subject: fix vformat with args and %% format --- xmake/core/sandbox/modules/string.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xmake/core/sandbox/modules/string.lua') 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, ...) -- cgit v1.3.1