Skip to content

Commit

Permalink
issue #10498 `cmakedefine01 macros are not documented
Browse files Browse the repository at this point in the history
Handle `#makedefine01` even when found in a file (normally it should have ben handled by CMake so we can only assume it to be defined with a value 0).
  • Loading branch information
albert-github committed Dec 20, 2023
1 parent d076ade commit 998ea0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pre.l
Expand Up @@ -416,6 +416,7 @@ WSopt [ \t\r]*
%x DefName
%x DefineArg
%x DefineText
%x CmakeDefName01
%x SkipCPPBlock
%x SkipCComment
%x ArgCopyCComment
Expand Down Expand Up @@ -957,6 +958,12 @@ WSopt [ \t\r]*
yyextra->yyColNr+=(int)yyleng;
BEGIN(DefName);
}
<Command>"cmakedefine01"{B}+ {
yyextra->potentialDefine += substitute(yytext,"cmakedefine01"," define");
//printf("!!!DefName\n");
yyextra->yyColNr+=(int)yyleng;
BEGIN(CmakeDefName01);
}
<Command>"ifdef"/{B}*"(" {
incrLevel(yyscanner);
yyextra->guardExpr.resize(0);
Expand Down Expand Up @@ -1274,7 +1281,7 @@ WSopt [ \t\r]*
}
yyextra->expectGuard=FALSE;
}
<DefName>{ID}/{B}*"\n" { // empty define
<DefName,CmakeDefName01>{ID}/{B}*"\n" { // empty define
yyextra->argMap.clear();
yyextra->defArgs = -1;
yyextra->defName = yytext;
Expand All @@ -1290,7 +1297,8 @@ WSopt [ \t\r]*
outputString(yyscanner,def);
yyextra->quoteArg=FALSE;
yyextra->insideComment=FALSE;
if (yyextra->insideCS) yyextra->defText="1"; // for C#, use "1" as define text
if (YY_START == CmakeDefName01) yyextra->defText = "0";
else if (yyextra->insideCS) yyextra->defText="1"; // for C#, use "1" as define text
BEGIN(DefineText);
}
else // define is a guard => hide
Expand Down
1 change: 1 addition & 0 deletions src/scanner.l
Expand Up @@ -2619,6 +2619,7 @@ NONLopt [^\n]*
yyextra->lastCPPContext = YY_START;
BEGIN( SkipCPP ) ;
}
<FindMembers,FindFields>{B}*"#"{B}*"cmakedefine01" |
<FindMembers,FindFields>{B}*"#"{B}*("cmake")?"define" {
if (yyextra->insidePHP)
REJECT;
Expand Down

0 comments on commit 998ea0e

Please sign in to comment.