Skip to content

Commit

Permalink
Add variadic arguments support to @link and @ref, aka '...' arguments…
Browse files Browse the repository at this point in the history
…, fixes
  • Loading branch information
Dimitri van Heesch committed Dec 28, 2017
1 parent 3a356ac commit dd88186
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5192,6 +5192,41 @@ QCString showFileDefMatches(const FileNameDict *fnDict,const char *n)

//----------------------------------------------------------------------

/// substitute all occurrences of \a src in \a s by \a dst
QCString substitute(const QCString &s,const QCString &src,const QCString &dst)
{
if (s.isEmpty() || src.isEmpty()) return s;
const char *p, *q;
int srcLen = src.length();
int dstLen = dst.length();
int resLen;
if (srcLen!=dstLen)
{
int count;
for (count=0, p=s.data(); (q=strstr(p,src))!=0; p=q+srcLen) count++;
resLen = s.length()+count*(dstLen-srcLen);
}
else // result has same size as s
{
resLen = s.length();
}
QCString result(resLen+1);
char *r;
for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen)
{
int l = (int)(q-p);
memcpy(r,p,l);
r+=l;

if (dst) memcpy(r,dst,dstLen);
r+=dstLen;
}
qstrcpy(r,p);
//printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
return result;
}


/// substitute all occurrences of \a src in \a s by \a dst, but skip
/// each consecutive sequence of \a src where the number consecutive
/// \a src matches \a skip_seq; if \a skip_seq is negative, skip any
Expand Down
3 changes: 2 additions & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE)

QCString substituteClassNames(const QCString &s);

QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq = 0);
QCString substitute(const QCString &s,const QCString &src,const QCString &dst);
QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq);

QCString clearBlock(const char *s,const char *begin,const char *end);

Expand Down

0 comments on commit dd88186

Please sign in to comment.