summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2017-12-28 09:02:36 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2017-12-28 09:02:36 (GMT)
commit9538bfd15c99aceb619f426b30c87004c4820370 (patch)
treed73db0110b43928cdea13a3a49726b7aac24f670 /src
parent27731a36c182f672fe4486c4a9ae390c4ee8a10f (diff)
parentdd88186b18613388902e4921e5203375458783b6 (diff)
downloadDoxygen-9538bfd15c99aceb619f426b30c87004c4820370.zip
Doxygen-9538bfd15c99aceb619f426b30c87004c4820370.tar.gz
Doxygen-9538bfd15c99aceb619f426b30c87004c4820370.tar.bz2
Merge branch 'mehw-variadic'
Diffstat (limited to 'src')
-rw-r--r--src/doctokenizer.l3
-rw-r--r--src/util.cpp65
-rw-r--r--src/util.h1
3 files changed, 66 insertions, 3 deletions
diff --git a/src/doctokenizer.l b/src/doctokenizer.l
index 7545cba..90a8c55 100644
--- a/src/doctokenizer.l
+++ b/src/doctokenizer.l
@@ -360,8 +360,9 @@ SPCMD3 {CMD}form#[0-9]+
SPCMD4 {CMD}"::"
INOUT "inout"|"in"|"out"|("in"{BLANK}*","{BLANK}*"out")|("out"{BLANK}*","{BLANK}*"in")
PARAMIO {CMD}param{BLANK}*"["{BLANK}*{INOUT}{BLANK}*"]"
+VARARGS "..."
TEMPCHAR [a-z_A-Z0-9.,: \t\*\&\(\)\[\]]
-FUNCCHAR [a-z_A-Z0-9,:\<\> \t\^\*\&\[\]]
+FUNCCHAR [a-z_A-Z0-9,:\<\> \t\^\*\&\[\]]|{VARARGS}
FUNCPART {FUNCCHAR}*("("{FUNCCHAR}*")"{FUNCCHAR}*)?
SCOPESEP "::"|"#"|"."
TEMPLPART "<"{TEMPCHAR}*">"
diff --git a/src/util.cpp b/src/util.cpp
index 7a4bd65..7f87e19 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)==':')
{
@@ -5217,10 +5217,71 @@ QCString substitute(const QCString &s,const QCString &src,const QCString &dst)
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
+/// 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;
+ 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)
+ {
+ // 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 2f362fd..e3853b5 100644
--- a/src/util.h
+++ b/src/util.h
@@ -194,6 +194,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);
QCString clearBlock(const char *s,const char *begin,const char *end);