Skip to content

Commit 78c3d1c

Browse files
committed
issue #10960 Variadic macro expansion with comments
1 parent e69bedc commit 78c3d1c

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/pre.l

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ WSopt [ \t\r]*
420420
%x SkipCPPBlock
421421
%x SkipCComment
422422
%x ArgCopyCComment
423+
%x ArgCopyCppComment
423424
%x CopyCComment
424425
%x SkipVerbatim
425426
%x SkipCondVerbatim
@@ -888,6 +889,13 @@ WSopt [ \t\r]*
888889
yyextra->defArgsStr+=yytext;
889890
BEGIN(ArgCopyCComment);
890891
}
892+
<FindDefineArgs>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
893+
yyextra->defArgsStr+=QCString("/**")+&yytext[3];
894+
BEGIN(ArgCopyCppComment);
895+
}
896+
<FindDefineArgs>{CPPC}[/!].*\n { // replace C++ single line style comment by C style comment
897+
yyextra->defArgsStr+=QCString("/**")+&yytext[3]+" */";
898+
}
891899
<FindDefineArgs>\" {
892900
yyextra->defArgsStr+=*yytext;
893901
BEGIN(ReadString);
@@ -923,6 +931,23 @@ WSopt [ \t\r]*
923931
<ArgCopyCComment>. {
924932
yyextra->defArgsStr+=yytext;
925933
}
934+
<ArgCopyCppComment>^{B}*
935+
<ArgCopyCppComment>{CPPC}[/!].*\n/{B}*{CPPC}[/!] { // replace multi line C++ style comment by C style comment
936+
const char *startContent = &yytext[3];
937+
if (startContent[0]=='<') startContent++;
938+
yyextra->defArgsStr+=startContent;
939+
}
940+
<ArgCopyCppComment>{CPPC}[/!].*\n { // replace C++ multie line style comment by C style comment
941+
const char *startContent = &yytext[3];
942+
if (startContent[0]=='<') startContent++;
943+
yyextra->defArgsStr+=QCString(startContent)+" */";
944+
BEGIN(FindDefineArgs);
945+
}
946+
<ArgCopyCppComment>. { // unexpected character
947+
unput(*yytext);
948+
yyextra->defArgsStr+=" */";
949+
BEGIN(FindDefineArgs);
950+
}
926951
<ReadString>"\"" {
927952
yyextra->defArgsStr+=*yytext;
928953
BEGIN(FindDefineArgs);
@@ -933,7 +958,7 @@ WSopt [ \t\r]*
933958
BEGIN(FindDefineArgs);
934959
}
935960

936-
<ReadString>{CPPC}|{CCS} {
961+
<ReadString>{CPPC}|{CCS} {
937962
yyextra->defArgsStr+=yytext;
938963
}
939964
<ReadString>\\/\r?\n { // line continuation

0 commit comments

Comments
 (0)