summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew White <mehw.is.me@inventati.org>2017-07-22 19:15:02 (GMT)
committerMatthew White <mehw.is.me@inventati.org>2017-08-03 03:38:50 (GMT)
commit6b29c4e55009771545305fe3ec3ba92e8d0ba38e (patch)
tree61f1c285ab1b568034c72cfd8b80348e77215042
parentdaa2c0960aa5044990c3e06afe8c15694e8be48d (diff)
downloadDoxygen-6b29c4e55009771545305fe3ec3ba92e8d0ba38e.zip
Doxygen-6b29c4e55009771545305fe3ec3ba92e8d0ba38e.tar.gz
Doxygen-6b29c4e55009771545305fe3ec3ba92e8d0ba38e.tar.bz2
Fix/New: add variadic function args '...' support to @link
* src/util.h (substitute): add skip_seq to function declaration * src/util.cpp (substitute): implement skip_seq to keep unchanged a given number of sequential chars otherwise targeted for substitution * src/util.cpp (resolveRef): call substitute() with skip_seq set to 3 to keep each '...' sequence of chars unchanged For instance, the command {@link fun(int,...)} now keeps each '...' sequence of chars unchanged to reference fun(int,...). Before this patch, each '.' was substituted into '::' by resolveRef() calling substitute(), producing a weird reference to fun(int,::::::).
-rw-r--r--src/util.cpp34
-rw-r--r--src/util.h2
2 files changed, 31 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp
index e44f825..8fcd8e3 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -4594,7 +4594,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
{
@@ -5186,8 +5186,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;
@@ -5208,13 +5211,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;
}
diff --git a/src/util.h b/src/util.h
index af8a3b4..9b98d83 100644
--- a/src/util.h
+++ b/src/util.h
@@ -193,7 +193,7 @@ void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE)
QCString substituteClassNames(const QCString &s);
-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 = 0);
QCString clearBlock(const char *s,const char *begin,const char *end);