diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2017-12-28 09:01:43 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2017-12-28 09:01:43 (GMT) |
commit | dd88186b18613388902e4921e5203375458783b6 (patch) | |
tree | d73db0110b43928cdea13a3a49726b7aac24f670 /src/util.cpp | |
parent | 3a356ac57960643cd9433e183e0635e467e38a87 (diff) | |
download | Doxygen-dd88186b18613388902e4921e5203375458783b6.zip Doxygen-dd88186b18613388902e4921e5203375458783b6.tar.gz Doxygen-dd88186b18613388902e4921e5203375458783b6.tar.bz2 |
Add variadic arguments support to @link and @ref, aka '...' arguments, fixes
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index 6cc1fd3..7f87e19 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 |