Skip to content

Commit 9538bfd

Browse files
author
Dimitri van Heesch
committed
Merge branch 'mehw-variadic'
2 parents 27731a3 + dd88186 commit 9538bfd

11 files changed

+1022
-3
lines changed

src/doctokenizer.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ SPCMD3 {CMD}form#[0-9]+
360360
SPCMD4 {CMD}"::"
361361
INOUT "inout"|"in"|"out"|("in"{BLANK}*","{BLANK}*"out")|("out"{BLANK}*","{BLANK}*"in")
362362
PARAMIO {CMD}param{BLANK}*"["{BLANK}*{INOUT}{BLANK}*"]"
363+
VARARGS "..."
363364
TEMPCHAR [a-z_A-Z0-9.,: \t\*\&\(\)\[\]]
364-
FUNCCHAR [a-z_A-Z0-9,:\<\> \t\^\*\&\[\]]
365+
FUNCCHAR [a-z_A-Z0-9,:\<\> \t\^\*\&\[\]]|{VARARGS}
365366
FUNCPART {FUNCCHAR}*("("{FUNCCHAR}*")"{FUNCCHAR}*)?
366367
SCOPESEP "::"|"#"|"."
367368
TEMPLPART "<"{TEMPCHAR}*">"

src/util.cpp

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4600,7 +4600,7 @@ bool resolveRef(/* in */ const char *scName,
46004600
QCString fullName = substitute(tsName,"#","::");
46014601
if (fullName.find("anonymous_namespace{")==-1)
46024602
{
4603-
fullName = removeRedundantWhiteSpace(substitute(fullName,".","::"));
4603+
fullName = removeRedundantWhiteSpace(substitute(fullName,".","::",3));
46044604
}
46054605
else
46064606
{
@@ -4773,7 +4773,7 @@ QCString linkToText(SrcLangExt lang,const char *link,bool isFileName)
47734773
// replace # by ::
47744774
result=substitute(result,"#","::");
47754775
// replace . by ::
4776-
if (!isFileName && result.find('<')==-1) result=substitute(result,".","::");
4776+
if (!isFileName && result.find('<')==-1) result=substitute(result,".","::",3);
47774777
// strip leading :: prefix if present
47784778
if (result.at(0)==':' && result.at(1)==':')
47794779
{
@@ -5217,10 +5217,71 @@ QCString substitute(const QCString &s,const QCString &src,const QCString &dst)
52175217
int l = (int)(q-p);
52185218
memcpy(r,p,l);
52195219
r+=l;
5220+
5221+
if (dst) memcpy(r,dst,dstLen);
5222+
r+=dstLen;
5223+
}
5224+
qstrcpy(r,p);
5225+
//printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
5226+
return result;
5227+
}
5228+
5229+
5230+
/// substitute all occurrences of \a src in \a s by \a dst, but skip
5231+
/// each consecutive sequence of \a src where the number consecutive
5232+
/// \a src matches \a skip_seq; if \a skip_seq is negative, skip any
5233+
/// number of consecutive \a src
5234+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq)
5235+
{
5236+
if (s.isEmpty() || src.isEmpty()) return s;
5237+
const char *p, *q;
5238+
int srcLen = src.length();
5239+
int dstLen = dst.length();
5240+
int resLen;
5241+
if (srcLen!=dstLen)
5242+
{
5243+
int count;
5244+
for (count=0, p=s.data(); (q=strstr(p,src))!=0; p=q+srcLen) count++;
5245+
resLen = s.length()+count*(dstLen-srcLen);
5246+
}
5247+
else // result has same size as s
5248+
{
5249+
resLen = s.length();
5250+
}
5251+
QCString result(resLen+1);
5252+
char *r;
5253+
for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen)
5254+
{
5255+
// search a consecutive sequence of src
5256+
int seq = 0, skip = 0;
5257+
if (skip_seq)
5258+
{
5259+
for (const char *n=q+srcLen; qstrncmp(n,src,srcLen)==0; seq=1+skip, n+=srcLen)
5260+
++skip; // number of consecutive src after the current one
5261+
5262+
// verify the allowed number of consecutive src to skip
5263+
if (skip_seq > 0 && skip_seq != seq)
5264+
seq = skip = 0;
5265+
}
5266+
5267+
// skip a consecutive sequence of src when necessary
5268+
int l = (int)((q + seq * srcLen)-p);
5269+
memcpy(r,p,l);
5270+
r+=l;
5271+
5272+
if (skip)
5273+
{
5274+
// skip only the consecutive src found after the current one
5275+
q += skip * srcLen;
5276+
// the next loop will skip the current src, aka (p=q+srcLen)
5277+
continue;
5278+
}
5279+
52205280
if (dst) memcpy(r,dst,dstLen);
52215281
r+=dstLen;
52225282
}
52235283
qstrcpy(r,p);
5284+
result.resize(strlen(result.data())+1);
52245285
//printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
52255286
return result;
52265287
}

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE)
194194
QCString substituteClassNames(const QCString &s);
195195

196196
QCString substitute(const QCString &s,const QCString &src,const QCString &dst);
197+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq);
197198

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
3+
<compounddef id="067__link__varargs_8cpp" kind="file" language="C++">
4+
<compoundname>067_link_varargs.cpp</compoundname>
5+
<innerclass refid="class_test" prot="public">Test</innerclass>
6+
<sectiondef kind="func">
7+
<memberdef kind="function" id="067__link__varargs_8cpp_1affb6da6cff1b57cdf8efc0123dceac9b" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
8+
<type>void</type>
9+
<definition>void func</definition>
10+
<argsstring>(int p)</argsstring>
11+
<name>func</name>
12+
<param>
13+
<type>int</type>
14+
<declname>p</declname>
15+
</param>
16+
<briefdescription>
17+
</briefdescription>
18+
<detaileddescription>
19+
<para>A function </para>
20+
</detaileddescription>
21+
<inbodydescription>
22+
</inbodydescription>
23+
<location file="067_link_varargs.cpp" line="11" column="1"/>
24+
</memberdef>
25+
<memberdef kind="function" id="067__link__varargs_8cpp_1a106e01084409028d1b41f5ad83fb82c1" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
26+
<type>void</type>
27+
<definition>void func</definition>
28+
<argsstring>(int p,...)</argsstring>
29+
<name>func</name>
30+
<param>
31+
<type>int</type>
32+
<declname>p</declname>
33+
</param>
34+
<param>
35+
<type>...</type>
36+
</param>
37+
<briefdescription>
38+
</briefdescription>
39+
<detaileddescription>
40+
<para>Overloaded function taking variadic arguments </para>
41+
</detaileddescription>
42+
<inbodydescription>
43+
</inbodydescription>
44+
<location file="067_link_varargs.cpp" line="15" column="1"/>
45+
</memberdef>
46+
</sectiondef>
47+
<briefdescription>
48+
</briefdescription>
49+
<detaileddescription>
50+
<para>See <ref refid="067__link__varargs_8cpp_1a106e01084409028d1b41f5ad83fb82c1" kindref="member">the function</ref> for more info. See the <ref refid="class_test" kindref="compound">test</ref> class. </para>
51+
</detaileddescription>
52+
<location file="067_link_varargs.cpp"/>
53+
</compounddef>
54+
</doxygen>

testing/067_link_varargs.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// objective: test \link command with function variadic arguments '...'
2+
// check: 067__link__varargs_8cpp.xml
3+
4+
/** \file
5+
* See \link func(int,...) the function\endlink for more info.
6+
* See the \link Test test\endlink class.
7+
*/
8+
9+
/** A function
10+
*/
11+
void func(int p);
12+
13+
/** Overloaded function taking variadic arguments
14+
*/
15+
void func(int p, ...);
16+
17+
/** A test */
18+
class Test
19+
{
20+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
3+
<compounddef id="068__ref__varargs_8cpp" kind="file" language="C++">
4+
<compoundname>068_ref_varargs.cpp</compoundname>
5+
<innerclass refid="class_test" prot="public">Test</innerclass>
6+
<sectiondef kind="func">
7+
<memberdef kind="function" id="068__ref__varargs_8cpp_1affb6da6cff1b57cdf8efc0123dceac9b" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
8+
<type>void</type>
9+
<definition>void func</definition>
10+
<argsstring>(int p)</argsstring>
11+
<name>func</name>
12+
<param>
13+
<type>int</type>
14+
<declname>p</declname>
15+
</param>
16+
<briefdescription>
17+
</briefdescription>
18+
<detaileddescription>
19+
<para>A function </para>
20+
</detaileddescription>
21+
<inbodydescription>
22+
</inbodydescription>
23+
<location file="068_ref_varargs.cpp" line="11" column="1"/>
24+
</memberdef>
25+
<memberdef kind="function" id="068__ref__varargs_8cpp_1a106e01084409028d1b41f5ad83fb82c1" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
26+
<type>void</type>
27+
<definition>void func</definition>
28+
<argsstring>(int p,...)</argsstring>
29+
<name>func</name>
30+
<param>
31+
<type>int</type>
32+
<declname>p</declname>
33+
</param>
34+
<param>
35+
<type>...</type>
36+
</param>
37+
<briefdescription>
38+
</briefdescription>
39+
<detaileddescription>
40+
<para>Overloaded function taking variadic arguments </para>
41+
</detaileddescription>
42+
<inbodydescription>
43+
</inbodydescription>
44+
<location file="068_ref_varargs.cpp" line="15" column="1"/>
45+
</memberdef>
46+
</sectiondef>
47+
<briefdescription>
48+
</briefdescription>
49+
<detaileddescription>
50+
<para>See <ref refid="068__ref__varargs_8cpp_1a106e01084409028d1b41f5ad83fb82c1" kindref="member">the function</ref> for more info. See the <ref refid="class_test" kindref="compound">test</ref> class. </para>
51+
</detaileddescription>
52+
<location file="068_ref_varargs.cpp"/>
53+
</compounddef>
54+
</doxygen>

testing/068_ref_varargs.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// objective: test \ref command with function variadic arguments '...'
2+
// check: 068__ref__varargs_8cpp.xml
3+
4+
/** \file
5+
* See \ref func(int,...) "the function" for more info.
6+
* See the \ref Test "test" class.
7+
*/
8+
9+
/** A function
10+
*/
11+
void func(int p);
12+
13+
/** Overloaded function taking variadic arguments
14+
*/
15+
void func(int p, ...);
16+
17+
/** A test */
18+
class Test
19+
{
20+
};

0 commit comments

Comments
 (0)