Skip to content

Commit

Permalink
More flexible and correct detection of direction of an argument
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
albert-github committed Jun 28, 2020
1 parent d5916c0 commit 4f28f62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/doctokenizer.l
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ SPCMD2 {CMD}[\\@<>&$#%~".+=|-]
SPCMD3 {CMD}_form#[0-9]+
SPCMD4 {CMD}"::"
SPCMD5 {CMD}":"
INOUT "inout"|"in"|"out"|("in"{BLANK}*","{BLANK}*"out")|("out"{BLANK}*","{BLANK}*"in")
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\*\&\(\)\[\]]
Expand Down
23 changes: 19 additions & 4 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8138,10 +8138,25 @@ QCString extractDirection(QCString &docs)
int l=0;
if (re.match(docs,0,&l)==0)
{
int inPos = docs.find("in", 1,FALSE);
int outPos = docs.find("out",1,FALSE);
bool input = inPos!=-1 && inPos<l;
bool output = outPos!=-1 && outPos<l;
QRegExp re_in("\\[ *in *\\]"); // [in]
QRegExp re_out("\\[ *out *\\]"); // [out]
QRegExp re_inout("\\[ *in *[,]? *out *\\]"); // [in,out]
QRegExp re_outin("\\[ *out *[,]? *in *\\]"); // [out,in]
int l_in = 0;
int l_out = 0;
int l_inout = 0;
int l_outin = 0;
int inPos = re_in.match(docs,0,&l_in);
int outPos = re_out.match(docs,0,&l_out);
int inoutPos = re_inout.match(docs,0,&l_inout);
int outinPos = re_outin.match(docs,0,&l_outin);
// we only take the first occurrence into account
bool input = (inPos!=-1 && l==l_in) ||
(inoutPos!=-1 && l==l_inout) ||
(outinPos!=-1 && l==l_outin);
bool output = (outPos!=-1 && l==l_out) ||
(inoutPos!=-1 && l==l_inout) ||
(outinPos!=-1 && l==l_outin);
if (input || output) // in,out attributes
{
docs = docs.mid(l); // strip attributes
Expand Down

0 comments on commit 4f28f62

Please sign in to comment.