Fix find_symbol() returning wrong symbol
Stop find_symbol() from exiting too early when have multiple matching symbols (static and non-static). Ignore non-static symbols (those with fnumber == -1) unless found nothing else. Fixes #20.
This commit is contained in:
parent
014528254b
commit
e35f9c9a21
@ -2722,24 +2722,28 @@ static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int a
|
|||||||
|| automaton<0 && sym->states==NULL
|
|| automaton<0 && sym->states==NULL
|
||||||
|| automaton>=0 && sym->states!=NULL && state_getfsa(sym->states->next->index)==automaton)
|
|| automaton>=0 && sym->states!=NULL && state_getfsa(sym->states->next->index)==automaton)
|
||||||
{
|
{
|
||||||
if (cmptag==NULL)
|
if (cmptag==NULL && sym->fnumber==fnumber)
|
||||||
return sym; /* return first match */
|
return sym; /* return first match */
|
||||||
/* return closest match or first match; count number of matches */
|
/* return closest match or first match; count number of matches */
|
||||||
if (firstmatch==NULL)
|
if (firstmatch==NULL)
|
||||||
firstmatch=sym;
|
firstmatch=sym;
|
||||||
assert(cmptag!=NULL);
|
if (cmptag!=NULL && *cmptag==0)
|
||||||
if (*cmptag==0)
|
|
||||||
count++;
|
count++;
|
||||||
if (*cmptag==sym->tag) {
|
if (cmptag!=NULL && *cmptag==sym->tag) {
|
||||||
*cmptag=1; /* good match found, set number of matches to 1 */
|
firstmatch=sym; /* good match found */
|
||||||
return sym;
|
if (sym->fnumber==fnumber)
|
||||||
|
break;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* */
|
} /* */
|
||||||
sym=sym->next;
|
sym=sym->next;
|
||||||
} /* while */
|
} /* while */
|
||||||
if (cmptag!=NULL && firstmatch!=NULL)
|
if (cmptag!=NULL && firstmatch!=NULL) {
|
||||||
|
if (*cmptag==0)
|
||||||
*cmptag=count;
|
*cmptag=count;
|
||||||
|
else
|
||||||
|
*cmptag=1; /* set number of matches to 1 */
|
||||||
|
} /* if */
|
||||||
return firstmatch;
|
return firstmatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user