Skip to content

Commit 3b39913

Browse files
committed
issue #9005: Function prototype matching @fn command, but link between both is not made
1 parent f3b9e55 commit 3b39913

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/markdown.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,16 +517,22 @@ int Markdown::isSpecialCommand(const char *data,int offset,int size)
517517
return endOfLabel(data_,offset_,size_);
518518
};
519519

520-
static const auto endOfFunc = [](const char *data_,int offset_,int size_) -> int
520+
static const auto endOfFuncLike = [](const char *data_,int offset_,int size_,bool allowSpaces) -> int
521521
{
522522
if (offset_<size_ && data_[offset_]==' ') // we expect a space before the name
523523
{
524524
char c=0;
525525
offset_++;
526526
// skip over spaces
527-
while (offset_<size_ && data_[offset_]==' ') offset_++;
528-
// skip over name
529-
while (offset_<size_ && (c=data_[offset_])!=' ' && c!='\n' && c!='(') offset_++;
527+
while (offset_<size_ && data_[offset_]==' ')
528+
{
529+
offset_++;
530+
}
531+
// skip over name (and optionally type)
532+
while (offset_<size_ && (c=data_[offset_])!='\n' && (allowSpaces || c!=' ') && c!='(')
533+
{
534+
offset_++;
535+
}
530536
if (c=='(') // find the end of the function
531537
{
532538
int count=1;
@@ -543,9 +549,14 @@ int Markdown::isSpecialCommand(const char *data,int offset,int size)
543549
return 0;
544550
};
545551

552+
static const auto endOfFunc = [](const char *data_,int offset_,int size_) -> int
553+
{
554+
return endOfFuncLike(data_,offset_,size_,true);
555+
};
556+
546557
static const auto endOfGuard = [](const char *data_,int offset_,int size_) -> int
547558
{
548-
return endOfFunc(data_,offset_,size_);
559+
return endOfFuncLike(data_,offset_,size_,false);
549560
};
550561

551562
static const std::unordered_map<std::string,EndCmdFunc> cmdNames =

0 commit comments

Comments
 (0)