You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Macro parameters with type conversion are processed incorrectly #23
#defineMACRO(a) a
MACRO(((int)0))
MACRO((int)1)
MACRO(2)
results in output:
((int)0)
(int)
2
i.e. if a macro argument is preceded by a parenthesized expression, this expression itself is taken as an argument.
The following diff takes care of the problem:
diff --git a/lcpp.lua b/lcpp.lua
index 99daf75..4450dcd 100755
--- a/lcpp.lua+++ b/lcpp.lua@@ -1238,20 +1238,25 @@ local function replaceArgs(argsstr, repl)
argsstr = argsstr:sub(2,-2)
-- print('argsstr:'..argsstr)
local comma
+ local arg_acc = ''^M
for k, v, start, end_ in tokenizer(argsstr, LCPP_TOKENIZE_MACRO_ARGS) do
-- print("replaceArgs:" .. k .. "|" .. v)
if k == "ARGS" or k == "PARENTHESE" or k == "STRING_LITERAL" or
k == "FUNCTIONAL" or k == "SINGLE_CHARACTER_ARGS" then
- table.insert(args, v)+ arg_acc = arg_acc..v^M
comma = false
elseif k == "COMMA" then
if comma then
-- continued comma means empty parameter
table.insert(args, "")
+ else^M+ table.insert(args, arg_acc)^M+ arg_acc = ''^M
end
comma = true
end
end
+ table.insert(args, arg_acc)^M
local v = repl:gsub("%$(%d+)", function (m) return args[tonumber(m)] or "" end)
-- print("replaceArgs:" .. repl .. "|" .. tostring(#args) .. "|" .. v)
return v
Activity
Fix processing of macro arguments prefixed with parenthesized express…
Testcase for macro parameters with type conversion processed incorrectly
Fix the processing of macro parameters with type conversion