diff options
-rwxr-xr-x | scripts/gendeclarations.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/gendeclarations.lua b/scripts/gendeclarations.lua index ff69b18ae4..6358ea4778 100755 --- a/scripts/gendeclarations.lua +++ b/scripts/gendeclarations.lua @@ -188,23 +188,29 @@ local footer = [[ local non_static = header local static = header -local filepattern = '^#%a* %d+ "[^"]-/?([^"/]+)"' +local filepattern = '^#%a* (%d+) "[^"]-/?([^"/]+)"' local curfile init = 0 curfile = nil neededfile = fname:match('[^/]+$') +local declline = 0 +local declendpos = 0 while init ~= nil do init = text:find('\n', init) if init == nil then break end init = init + 1 + declline = declline + 1 if text:sub(init, init) == '#' then - file = text:match(filepattern, init) + local line, file = text:match(filepattern, init) if file ~= nil then curfile = file end + declline = tonumber(line) - 1 + elseif init < declendpos then + -- Skipping over declaration elseif curfile == neededfile then s = init e = pattern:match(text, init) @@ -225,13 +231,15 @@ while init ~= nil do declaration = declaration:gsub(' ?(%*+) ?', ' %1') declaration = declaration:gsub(' ?(FUNC_ATTR_)', ' %1') declaration = declaration:gsub(' $', '') - declaration = declaration .. ';\n' + declaration = declaration .. ';' + declaration = declaration .. ' // ' .. curfile .. ':' .. declline + declaration = declaration .. '\n' if text:sub(s, s + 5) == 'static' then static = static .. declaration else non_static = non_static .. declaration end - init = e + declendpos = e end end end |