Skip to content

Commit 4f28f62

Browse files
committed
More flexible and correct detection of direction of an argument
In the current version a line like: ``` uint8_t innInstances, ///< [inn]Number of CIP node instances. ``` was seen as an input parameter. Also not all combinations were checked (`[inout]` was OK but `[outin]` wasn't although `[in,out]` and `[out,in]` were working in the tokenizer. Line up the detection of the direction between the tokenizer and the method `extractDirection` Note: this problem was found when working on #7879.
1 parent d5916c0 commit 4f28f62

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/doctokenizer.l

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ SPCMD2 {CMD}[\\@<>&$#%~".+=|-]
378378
SPCMD3 {CMD}_form#[0-9]+
379379
SPCMD4 {CMD}"::"
380380
SPCMD5 {CMD}":"
381-
INOUT "inout"|"in"|"out"|("in"{BLANK}*","{BLANK}*"out")|("out"{BLANK}*","{BLANK}*"in")
381+
INOUT "in"|"out"|("in"{BLANK}*","?{BLANK}*"out")|("out"{BLANK}*","?{BLANK}*"in")
382382
PARAMIO {CMD}param{BLANK}*"["{BLANK}*{INOUT}{BLANK}*"]"
383383
VARARGS "..."
384384
TEMPCHAR [a-z_A-Z0-9.,: \t\*\&\(\)\[\]]

src/util.cpp

+19-4
Original file line numberDiff line numberDiff line change
@@ -8138,10 +8138,25 @@ QCString extractDirection(QCString &docs)
81388138
int l=0;
81398139
if (re.match(docs,0,&l)==0)
81408140
{
8141-
int inPos = docs.find("in", 1,FALSE);
8142-
int outPos = docs.find("out",1,FALSE);
8143-
bool input = inPos!=-1 && inPos<l;
8144-
bool output = outPos!=-1 && outPos<l;
8141+
QRegExp re_in("\\[ *in *\\]"); // [in]
8142+
QRegExp re_out("\\[ *out *\\]"); // [out]
8143+
QRegExp re_inout("\\[ *in *[,]? *out *\\]"); // [in,out]
8144+
QRegExp re_outin("\\[ *out *[,]? *in *\\]"); // [out,in]
8145+
int l_in = 0;
8146+
int l_out = 0;
8147+
int l_inout = 0;
8148+
int l_outin = 0;
8149+
int inPos = re_in.match(docs,0,&l_in);
8150+
int outPos = re_out.match(docs,0,&l_out);
8151+
int inoutPos = re_inout.match(docs,0,&l_inout);
8152+
int outinPos = re_outin.match(docs,0,&l_outin);
8153+
// we only take the first occurrence into account
8154+
bool input = (inPos!=-1 && l==l_in) ||
8155+
(inoutPos!=-1 && l==l_inout) ||
8156+
(outinPos!=-1 && l==l_outin);
8157+
bool output = (outPos!=-1 && l==l_out) ||
8158+
(inoutPos!=-1 && l==l_inout) ||
8159+
(outinPos!=-1 && l==l_outin);
81458160
if (input || output) // in,out attributes
81468161
{
81478162
docs = docs.mid(l); // strip attributes

0 commit comments

Comments
 (0)