Browse Source

[Project] Lua_magic: Support hex patterns

tags/2.0
Vsevolod Stakhov 4 years ago
parent
commit
5aed65dc5c
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      lualib/lua_magic/init.lua

+ 10
- 0
lualib/lua_magic/init.lua View File

@@ -42,6 +42,16 @@ local function process_patterns()
processed_patterns[#processed_patterns + 1] = {
match.string, match, pattern
}
elseif match.hex then
local hex_table = {}

for i=1,#match.hex,2 do
local subc = match.hex:sub(i, i + 1)
hex_table[#hex_table + 1] = string.format('\\x{%s}', subc)
end
processed_patterns[#processed_patterns + 1] = {
table.concat(hex_table), match, pattern
}
end
end
end

Loading…
Cancel
Save