Added new output function _x(), XML escapes all arguments before printing

This commit is contained in:
Jason Perkins 2012-01-12 18:27:30 -05:00
parent 8c9c451bdb
commit 665ef8b86a
3 changed files with 27 additions and 3 deletions

View File

@ -59,7 +59,7 @@
local prjpath = vstudio.projectfile_ng(prj)
prjpath = path.translate(path.getrelative(slnpath, prjpath))
_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, prjpath, prj.uuid)
_x('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, prjpath, prj.uuid)
sln2005.projectdependencies_ng(prj)
_p('EndProject')
end

View File

@ -82,3 +82,15 @@
--
_p = io.printf
--
-- Another variation that calls esc() on all of its arguments before formatting.
--
_x = function(msg, ...)
for i,v in ipairs(arg) do
arg[i] = premake.esc(arg[i])
end
io.printf(msg, unpack(arg))
end

View File

@ -31,7 +31,6 @@
--
function suite.structureIsOkay_onCpp()
_ACTION = "vs2005"
prepare()
test.capture [[
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
@ -45,7 +44,6 @@ EndProject
--
function suite.structureIsOkay_onCSharp()
_ACTION = "vs2005"
language "C#"
prepare()
test.capture [[
@ -53,3 +51,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "MyProject.cspr
EndProject
]]
end
--
-- Project names should be XML escaped.
--
function suite.projectNamesAreEscaped()
prj.name = 'My "x64" Project';
prepare()
test.capture [[
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "My "x64" Project", "My "x64" Project.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
]]
end