test: fix formatc.lua oddity on OSX/gcc

The primitive C canonicalizer we use to strip out duplicate header
declarations and keep luajit's ffi happy, didn't work properly in this case.

What happened is this (in /usr/include/ctype.h):

__DARWIN_CTYPE_TOP_inline int
isspecial(int _c)
{
        return (__istype(_c, _CTYPE_T));
}

Gets preprocessed to something like:

__inline int
isspecial(int _c)
{
        return (__istype(_c, _CTYPE_T));
}

On OSX/gcc. The formatter wasn't recognizing this entire function as
something to put on a single line because it naively just checks for
"static" or "inline" for that, but not "__inline".

This error doesn't occur on OSX/clang. Without looking further into it, I
guess that __DARWIN_CTYPE_TOP_inline gets defined to inline on clang, but
__inline on gcc, for some reason.

This helps issue #1572 along.
This commit is contained in:
Nicolas Hillegeer 2014-12-12 00:48:50 +01:00
parent dd25b2e5ae
commit 522a15f1c0

View File

@ -149,8 +149,7 @@ local C_keywords = set {
-- }; -- };
-- --
-- would become: -- would become:
-- struct mystruct -- struct mystruct { int a; int b; };
-- { int a; int b; };
-- --
-- The first one will have a lot of false positives (the line '{' for -- The first one will have a lot of false positives (the line '{' for
-- example), the second one is more unique. -- example), the second one is more unique.
@ -179,7 +178,8 @@ local function formatc(str)
-- static and/or inline usually indicate an inline header function, -- static and/or inline usually indicate an inline header function,
-- which has no trailing ';', so we have to add a newline after the -- which has no trailing ';', so we have to add a newline after the
-- '}' ourselves. -- '}' ourselves.
if token[1] == 'static' or token[1] == 'inline' then local tok = token[1]
if tok == 'static' or tok == 'inline' or tok == '__inline' then
end_at_brace = true end_at_brace = true
end end
elseif typ == 'preprocessor' then elseif typ == 'preprocessor' then