summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeromake <[email protected]>2023-11-01 23:24:20 +0800
committerzeromake <[email protected]>2023-11-01 23:24:20 +0800
commit552f8e7af8846c4aa87040361bf8a1727d8c15d5 (patch)
treed8d8b9aedda5b8f061d1bba7746c0e67b6843557
parent63a5c56f2b26a46729800d1447b721604ffbcbf3 (diff)
fix: binaryfind use match pattern
-rw-r--r--xmake/includes/check/check_sizeof.lua12
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua6
2 files changed, 7 insertions, 11 deletions
diff --git a/xmake/includes/check/check_sizeof.lua b/xmake/includes/check/check_sizeof.lua
index 3ae1dafea..c4921fbf9 100644
--- a/xmake/includes/check/check_sizeof.lua
+++ b/xmake/includes/check/check_sizeof.lua
@@ -30,14 +30,6 @@
--
local binary_match = 'INFO:size%[(%d+)%]'
-local function _match(content)
- local match = content:match(binary_match)
- if match == nil then
- return false
- end
- return true, match
-end
-
local check_sizeof_template = [[
#define SIZE (sizeof(${TYPE}))
static char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
@@ -66,7 +58,7 @@ function check_sizeof(definition, typename, opt)
interp_save_scope()
option(optname)
set_showmenu(false)
- add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = _match})
+ add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = binary_match})
if opt.links then
add_links(opt.links)
end
@@ -115,7 +107,7 @@ function configvar_check_sizeof(definition, typename, opt)
interp_save_scope()
option(optname)
set_showmenu(false)
- add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = _match})
+ add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = binary_match})
if opt.default == nil then
set_configvar(defname, defval or 1, {quote = opt.quote})
end
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index d74499ea3..310c55fa0 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -259,7 +259,11 @@ function main(snippets, opt)
end
if opt.binaryfind then
local content = io.readfile(binaryfile, {encoding = "binary"})
- return opt.binaryfind(content)
+ local match = content:match(opt.binaryfind)
+ if match == nil then
+ return false
+ end
+ return true, match
end
return true
end,