diff options
| author | ruki <[email protected]> | 2019-06-04 22:41:25 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-04 10:08:31 +0800 |
| commit | 18663d52e5ff484eea423f88cbf52cc10c5721f3 (patch) | |
| tree | 3e1e147713b4ca50276b676b9b346f52f893708b /xmake/modules | |
| parent | 255d51be7e7ed10a13a4cd55b5aae55079ab4bb9 (diff) | |
improve string.split
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/devel/git/ls_remote.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/pkg_config.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/package/manager/find_package.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/manager/install_package.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/tools/gcc/parse_deps.lua | 2 |
8 files changed, 14 insertions, 14 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 99c9b982f..3859358d3 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -313,7 +313,7 @@ function _include_deps(self, outdata) -- translate it local results = {} local uniques = {} - for _, line in ipairs(outdata:split("\r\n")) do + for _, line in ipairs(outdata:split("\r\n", {plain = true})) do -- get includefile local includefile = _include_note(self, line) @@ -410,7 +410,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- filter includes notes: "Note: including file: xxx.h", @note maybe not english language local results = "" - for _, line in ipairs(tostring(errors):split("\r\n")) do + for _, line in ipairs(tostring(errors):split("\r\n", {plain = true})) do if not _include_note(self, line) then results = results .. line .. "\r\n" end @@ -430,7 +430,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) end if #output:trim() > 0 then local lines = {} - for _, line in ipairs(output:split("\r\n")) do + for _, line in ipairs(output:split("\r\n", {plain = true})) do if line:match("warning %a+[0-9]+%s*:") then table.insert(lines, line) end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 8396c1746..ad4104cd9 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -425,7 +425,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) os.tryrm(objectfile) -- parse and strip errors - local lines = errors and tostring(errors):split('\n') or {} + local lines = errors and tostring(errors):split('\n', {plain = true}) or {} if not option.get("verbose") then -- find the start line of error @@ -452,7 +452,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) function (ok, outdata, errdata) -- show warnings? if ok and errdata and #errdata > 0 and (option.get("diagnosis") or option.get("warning")) then - local lines = errdata:split('\n') + local lines = errdata:split('\n', {plain = true}) if #lines > 0 then local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\n") cprint("${color.warning}%s", warnings) diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 066e86cc9..568c6aef9 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -309,7 +309,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) os.tryrm(objectfile) -- find the start line of error - local lines = tostring(errors):split("\n") + local lines = tostring(errors):split("\n", {plain = true}) local start = 0 for index, line in ipairs(lines) do if line:find("error:", 1, true) or line:find("错误:", 1, true) then @@ -334,7 +334,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- print some warnings if warnings and #warnings > 0 and (option.get("verbose") or option.get("warning")) then - cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n')) + cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n', {plain = true}), 1, 8), '\n')) end -- generate the dependent includes diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua index e7e37b8ac..391b85caf 100644 --- a/xmake/modules/devel/git/ls_remote.lua +++ b/xmake/modules/devel/git/ls_remote.lua @@ -58,7 +58,7 @@ function main(reftype, url) for _, line in ipairs(data:split('\n')) do -- parse commit and ref - local refinfo = line:split('%s+') + local refinfo = line:split('%s') -- get commit local commit = refinfo[1] diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkg_config.lua index 174dd7bd2..2e645379f 100644 --- a/xmake/modules/lib/detect/pkg_config.lua +++ b/xmake/modules/lib/detect/pkg_config.lua @@ -65,7 +65,7 @@ function info(name, opt) -- init result result = {} - for _, flag in ipairs(flags:split('%s*')) do + for _, flag in ipairs(flags:split('%s')) do -- get links local link = flag:match("%-l(.*)") diff --git a/xmake/modules/package/manager/find_package.lua b/xmake/modules/package/manager/find_package.lua index d9391d1a5..287747d17 100644 --- a/xmake/modules/package/manager/find_package.lua +++ b/xmake/modules/package/manager/find_package.lua @@ -159,7 +159,7 @@ function main(name, opt) opt.mode = opt.mode or config.mode() or "release" -- get package manager name - local manager_name, package_name = unpack(name:split("::", true)) + local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) if package_name == nil then package_name = manager_name manager_name = nil @@ -169,7 +169,7 @@ function main(name, opt) -- get package name and require version local require_version = nil - package_name, require_version = unpack(package_name:trim():split("%s+")) + package_name, require_version = unpack(package_name:trim():split("%s")) opt.version = require_version or opt.version -- find package diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index b46062c42..1a5451758 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -92,7 +92,7 @@ function main(name, opt) opt.mode = opt.mode or config.mode() or "release" -- get package manager name - local manager_name, package_name = unpack(name:split("::", true)) + local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) if package_name == nil then package_name = manager_name manager_name = nil @@ -102,7 +102,7 @@ function main(name, opt) -- get package name and require version local require_version = nil - package_name, require_version = unpack(package_name:trim():split("%s+")) + package_name, require_version = unpack(package_name:trim():split("%s")) opt.version = require_version or opt.version -- do install package diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 382a3dcdf..4d38aede9 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -64,7 +64,7 @@ function main(depsdata) -- parse results local results = {} local data = depsdata:gsub("\\\n", "") - for _, line in ipairs(data:split("\n")) do + for _, line in ipairs(data:split("\n", {plain = true})) do local p = line:find(':', 1, true) if p then line = line:sub(p + 1) |
