Skip to content

Commit c29b0e6

Browse files
committed
issue #10295 typedef of a function incorrectly output in HTML and PDF
1 parent 83116d0 commit c29b0e6

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/doxygen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,11 +2578,11 @@ static int findFunctionPtr(const std::string &type,SrcLangExt lang, int *pLength
25782578
return -1; // Fortran and VHDL do not have function pointers
25792579
}
25802580

2581-
static const reg::Ex re(R"(\([^)]*[*^][^)]*\))");
2581+
static const reg::Ex re(R"(\([^)]*[*&^][^)]*\))");
25822582
reg::Match match;
25832583
size_t i=std::string::npos;
25842584
size_t l=0;
2585-
if (reg::search(type,match,re)) // contains (...*...)
2585+
if (reg::search(type,match,re)) // contains (...*...) or (...&...) or (...^...)
25862586
{
25872587
i = match.position();
25882588
l = match.length();

src/scanner.l

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ static const char *stateToString(int state);
225225
static inline int computeIndent(const char *s,int startIndent);
226226
static inline void initMethodProtection(yyscan_t yyscanner,Protection prot);
227227
static QCString stripQuotes(const char *s);
228+
static QCString stripFuncPtr(const QCString &type);
228229
static bool nameIsOperator(QCString &name);
229230
void fixArgumentListForJavaScript(ArgumentList &al);
230231
static bool startOfRequiresExpression(const QCString &req);
@@ -3660,9 +3661,7 @@ NONLopt [^\n]*
36603661
yyextra->current->doc.resize(0);
36613662
yyextra->current->initializer.str(std::string());
36623663
yyextra->current->bitfields.resize(0);
3663-
int i=oldType.length();
3664-
while (i>0 && (oldType[i-1]=='*' || oldType[i-1]=='&' || oldType[i-1]==' ')) i--;
3665-
yyextra->current->type = oldType.left(i);
3664+
yyextra->current->type = stripFuncPtr(oldType);
36663665
}
36673666
else
36683667
{
@@ -4547,7 +4546,10 @@ NONLopt [^\n]*
45474546
}
45484547
<EndFuncPtr>")"{BNopt}/"(" { // a function pointer
45494548
lineCount(yyscanner);
4550-
yyextra->current->type+=yyextra->funcPtrType+")";
4549+
if (yyextra->funcPtrType!="(") // not just redundant braces
4550+
{
4551+
yyextra->current->type+=yyextra->funcPtrType+")";
4552+
}
45514553
BEGIN(FindMembers);
45524554
}
45534555
<EndFuncPtr>")"{BNopt}/"[" { // an array of variables
@@ -5445,11 +5447,7 @@ NONLopt [^\n]*
54455447
yyextra->lastCurlyContext = FindMembers;
54465448
if ( *yytext == ',' )
54475449
{
5448-
yyextra->current->type = yyextra->previous->type;
5449-
// we need to strip any trailing * and & (see bugs 623023 and 649103 for test cases)
5450-
int i=yyextra->current->type.length();
5451-
while (i>0 && (yyextra->current->type[i-1]=='*' || yyextra->current->type[i-1]=='&' || yyextra->current->type[i-1]==' ')) i--;
5452-
yyextra->current->type = yyextra->current->type.left(i);
5450+
yyextra->current->type = stripFuncPtr(yyextra->previous->type);
54535451
}
54545452
if ( *yytext == '{' )
54555453
{
@@ -7441,6 +7439,18 @@ static QCString stripQuotes(const char *s)
74417439
return name;
74427440
}
74437441
7442+
static QCString stripFuncPtr(const QCString &type)
7443+
{
7444+
// we need to strip any trailing * and & (see bugs 623023 and 649103 for test cases)
7445+
// also needed to reset the type for 'arr' to 'int' in 'typedef int (&fp)(), arr[2]'
7446+
int i=type.length();
7447+
bool funcPtr = i>0 && type[i-1]==')';
7448+
if (funcPtr) i--;
7449+
while (i>0 && (type[i-1]=='*' || type[i-1]=='&' || type[i-1]==' ')) i--;
7450+
if (funcPtr && i>0 && type[i-1]=='(') i--;
7451+
return type.left(i);
7452+
}
7453+
74447454
//-----------------------------------------------------------------
74457455
74467456
// return TRUE iff req holds the start of a requires expression

0 commit comments

Comments
 (0)