string.explode() gains 'maxTokens' argument.
This commit is contained in:
parent
04a7cd1546
commit
28ebe8fce7
@ -1510,11 +1510,7 @@
|
||||
|
||||
function m.platformToolset(cfg)
|
||||
local tool, version = p.config.toolset(cfg)
|
||||
if version then
|
||||
if tonumber(version:sub(1,3)) ~= nil then
|
||||
version = "v" .. version
|
||||
end
|
||||
else
|
||||
if not version then
|
||||
local action = p.action.current()
|
||||
version = action.vstudio.platformToolset
|
||||
end
|
||||
|
@ -29,13 +29,19 @@
|
||||
-- formed by splitting on boundaries formed by `pattern`.
|
||||
--
|
||||
|
||||
function string.explode(s, pattern, plain)
|
||||
function string.explode(s, pattern, plain, maxTokens)
|
||||
if (pattern == '') then return false end
|
||||
local pos = 0
|
||||
local arr = { }
|
||||
for st,sp in function() return s:find(pattern, pos, plain) end do
|
||||
table.insert(arr, s:sub(pos, st-1))
|
||||
pos = sp + 1
|
||||
if maxTokens ~= nil and maxTokens > 0 then
|
||||
maxTokens = maxTokens - 1
|
||||
if maxTokens == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(arr, s:sub(pos))
|
||||
return arr
|
||||
|
@ -31,16 +31,22 @@
|
||||
|
||||
function p.tools.canonical(identifier)
|
||||
local parts
|
||||
if identifier:startswith("v") then
|
||||
parts = { "msc", identifier:sub(2) }
|
||||
elseif identifier:startswith("llvm-vs") then -- support LLVM toolset in VS
|
||||
parts = { "msc", "LLVM-vs" .. identifier:sub(8) }
|
||||
if identifier:startswith("v") then -- TODO: this should be deprecated?
|
||||
parts = { "msc", identifier }
|
||||
else
|
||||
parts = identifier:explode("-")
|
||||
parts = identifier:explode("-", true, 1)
|
||||
|
||||
-- hack to check for LLVM toolsets, which would be corrupted by the previous line
|
||||
if parts[1] == "msc" and parts[2] == "llvm" and parts[3]:startswith("vs") then
|
||||
parts = { parts[1], "LLVM-" .. parts[3] }
|
||||
-- couple of little hacks here to fix up version names
|
||||
if parts[2] ~= nil then
|
||||
-- 'msc-100' is accepted, but the code expects 'v100'
|
||||
if parts[1] == "msc" and tonumber(parts[2]:sub(1,3)) ~= nil then
|
||||
parts[2] = "v" .. parts[2]
|
||||
end
|
||||
|
||||
-- perform case-correction of the LLVM toolset
|
||||
if parts[2]:startswith("llvm-vs") then
|
||||
parts[2] = "LLVM-" .. parts[2]:sub(6)
|
||||
end
|
||||
end
|
||||
end
|
||||
return p.tools[parts[1]], parts[2]
|
||||
|
@ -96,14 +96,6 @@
|
||||
end
|
||||
|
||||
function suite.canOverrideFromScript_withLLVM()
|
||||
toolset "LLVM-vs2010"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PlatformToolset>LLVM-vs2010</PlatformToolset>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.canOverrideFromScript_withMscAndLLVM()
|
||||
toolset "msc-llvm-vs2014_xp"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
Reference in New Issue
Block a user