mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-23 13:52:29 +01:00
Rename handle_ifndefs to handle_ifdefs
This commit is contained in:
parent
c7e165f170
commit
6a612874c2
14
text.lua
14
text.lua
@ -132,22 +132,22 @@ function utf8(number)
|
|||||||
return string.char(256 - math.pow(2, 8 - i - 1) + number) .. result -- 256 = math.pow(2, 8)
|
return string.char(256 - math.pow(2, 8 - i - 1) + number) .. result -- 256 = math.pow(2, 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
function handle_ifndefs(code, vars)
|
function handle_ifdefs(code, vars)
|
||||||
local finalcode = {}
|
local finalcode = {}
|
||||||
local endif
|
local endif
|
||||||
local after_endif = -1
|
local after_endif = -1
|
||||||
local ifndef_pos, after_ifndef = string.find(code, "--IFNDEF", 1, true)
|
local ifdef_pos, after_ifdef = string.find(code, "--IFDEF", 1, true)
|
||||||
while ifndef_pos do
|
while ifdef_pos do
|
||||||
table.insert(finalcode,
|
table.insert(finalcode,
|
||||||
string.sub(code, after_endif + 2, ifndef_pos - 1))
|
string.sub(code, after_endif + 2, ifdef_pos - 1))
|
||||||
local linebreak = string.find(code, "\n", after_ifndef + 1, true)
|
local linebreak = string.find(code, "\n", after_ifdef + 1, true)
|
||||||
local varname = string.sub(code, after_ifndef + 2, linebreak - 1)
|
local varname = string.sub(code, after_ifdef + 2, linebreak - 1)
|
||||||
endif, after_endif = string.find(code, "--ENDIF", linebreak + 1, true)
|
endif, after_endif = string.find(code, "--ENDIF", linebreak + 1, true)
|
||||||
if not endif then break end
|
if not endif then break end
|
||||||
if vars[varname] then
|
if vars[varname] then
|
||||||
table.insert(finalcode, string.sub(code, linebreak + 1, endif - 1))
|
table.insert(finalcode, string.sub(code, linebreak + 1, endif - 1))
|
||||||
end
|
end
|
||||||
ifndef_pos, after_ifndef = string.find(code, "--IFNDEF",
|
ifdef_pos, after_ifdef = string.find(code, "--IFDEF",
|
||||||
after_endif + 1, true)
|
after_endif + 1, true)
|
||||||
end
|
end
|
||||||
table.insert(finalcode, string.sub(code, after_endif + 2))
|
table.insert(finalcode, string.sub(code, after_endif + 2))
|
||||||
|
Loading…
Reference in New Issue
Block a user