-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
match of macro argument name happens inside the identifier sometimes #21
Comments
This diff takes care of the problem (although needs more testing, including here mostly for comments): diff --git a/lcpp.lua b/lcpp.lua
index 9ac5088..4d1defb 100755
--- a/lcpp.lua
+++ b/lcpp.lua
@@ -1273,11 +1273,11 @@ local function parseFunction(state, input)
for argname in argsstr:gmatch(IDENTIFIER) do
noargs = noargs + 1
-- avoid matching substring of another identifier (eg. attrib matches __attribute__ and replace it)
- repl = repl:gsub("(#*)(%s*)("..argname..")([_%w]?)", function (s1, s2, s3, s4)
- if #s4 <= 0 then
+ repl = repl:gsub("(#*)(%s*)([_%w]?)("..argname..")([_%w]?)", function (s1, s2, s3, s4, s5)
+ if (#s5 <= 0) and (#s3 <= 0) then
return (#s1 == 1) and ("\"$"..noargs.."\"") or (s1..s2.."$"..noargs)
else
- return s1..s2..s3..s4
+ return s1..s2..s3..s4..s5
end
end)
end
|
ayourtch
added a commit
to ayourtch/lcpp
that referenced
this issue
Aug 18, 2016
ayourtch
added a commit
to ayourtch/lcpp
that referenced
this issue
Aug 22, 2016
ayourtch
added a commit
to ayourtch/lcpp
that referenced
this issue
Aug 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiling this code, reduced from a real world include file:
Results in output "typedef uniou16 16u8", the correct result should be "typedef union 16u8".
The text was updated successfully, but these errors were encountered: