diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2017-12-27 18:35:57 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2017-12-27 18:35:57 (GMT) |
commit | 3a356ac57960643cd9433e183e0635e467e38a87 (patch) | |
tree | 8e9d00ed84d6f648aeb7f911faeb05e0d1a6cfd6 /src/util.cpp | |
parent | 27731a36c182f672fe4486c4a9ae390c4ee8a10f (diff) | |
parent | 818f0458205a2965f0a676265e2454450a4c3455 (diff) | |
download | Doxygen-3a356ac57960643cd9433e183e0635e467e38a87.zip Doxygen-3a356ac57960643cd9433e183e0635e467e38a87.tar.gz Doxygen-3a356ac57960643cd9433e183e0635e467e38a87.tar.bz2 |
Merge branch 'variadic' of https://github.com/mehw/doxygen into mehw-variadic
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp index 7a4bd65..6cc1fd3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -4600,7 +4600,7 @@ bool resolveRef(/* in */ const char *scName, QCString fullName = substitute(tsName,"#","::"); if (fullName.find("anonymous_namespace{")==-1) { - fullName = removeRedundantWhiteSpace(substitute(fullName,".","::")); + fullName = removeRedundantWhiteSpace(substitute(fullName,".","::",3)); } else { @@ -4773,7 +4773,7 @@ QCString linkToText(SrcLangExt lang,const char *link,bool isFileName) // replace # by :: result=substitute(result,"#","::"); // replace . by :: - if (!isFileName && result.find('<')==-1) result=substitute(result,".","::"); + if (!isFileName && result.find('<')==-1) result=substitute(result,".","::",3); // strip leading :: prefix if present if (result.at(0)==':' && result.at(1)==':') { @@ -5192,8 +5192,11 @@ 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) +/// 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 +/// number of consecutive \a src +QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq) { if (s.isEmpty() || src.isEmpty()) return s; const char *p, *q; @@ -5214,13 +5217,36 @@ QCString substitute(const QCString &s,const QCString &src,const QCString &dst) char *r; for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen) { - int l = (int)(q-p); + // search a consecutive sequence of src + int seq = 0, skip = 0; + if (skip_seq) + { + for (const char *n=q+srcLen; qstrncmp(n,src,srcLen)==0; seq=1+skip, n+=srcLen) + ++skip; // number of consecutive src after the current one + + // verify the allowed number of consecutive src to skip + if (skip_seq > 0 && skip_seq != seq) + seq = skip = 0; + } + + // skip a consecutive sequence of src when necessary + int l = (int)((q + seq * srcLen)-p); memcpy(r,p,l); r+=l; + + if (skip) + { + // skip only the consecutive src found after the current one + q += skip * srcLen; + // the next loop will skip the current src, aka (p=q+srcLen) + continue; + } + if (dst) memcpy(r,dst,dstLen); r+=dstLen; } qstrcpy(r,p); + result.resize(strlen(result.data())+1); //printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data()); return result; } |