(comtch, stmtch): Make more similar, document. No functional changes.
This commit is contained in:
parent
18fdb41bd0
commit
66eaa28f92
2 changed files with 14 additions and 11 deletions
|
@ -56,7 +56,7 @@ stmtch(char *needle, void *haystack, ptrdiff_t offs, size_t elt_size)
|
|||
case ME_MISMATCH:
|
||||
break;
|
||||
case ME_PARTIAL:
|
||||
if (res != M_NOTFOUND)
|
||||
if (res >= 0)
|
||||
return M_NOTUNIQUE;
|
||||
res = i;
|
||||
break;
|
||||
|
|
|
@ -58,8 +58,10 @@ intmatch(register int value, register int *ptr, int size)
|
|||
}
|
||||
|
||||
/*
|
||||
* find a matching command from coms[]. Return status is:
|
||||
* >= 0: match found, value is array entry in coms[]
|
||||
* Search for COMMAND in COMS[], return its index.
|
||||
* Return M_NOTFOUND if there are no matches, M_NOTUNIQUE if there are
|
||||
* several, M_IGNORE if the command should be ignored.
|
||||
* Ignore commands that require more permissions than COMSTAT.
|
||||
*/
|
||||
int
|
||||
comtch(register s_char *command, struct cmndstr *coms, int comstat,
|
||||
|
@ -67,7 +69,6 @@ comtch(register s_char *command, struct cmndstr *coms, int comstat,
|
|||
{
|
||||
register struct cmndstr *com;
|
||||
register int status;
|
||||
register int i;
|
||||
|
||||
if (command == 0 || *command == 0)
|
||||
return M_IGNORE;
|
||||
|
@ -75,14 +76,16 @@ comtch(register s_char *command, struct cmndstr *coms, int comstat,
|
|||
for (com = coms; com->c_form != 0; com++) {
|
||||
if ((com->c_permit & comstat) != com->c_permit && !god)
|
||||
continue;
|
||||
if ((i = mineq(command, com->c_form)) == ME_MISMATCH)
|
||||
continue;
|
||||
if (i == ME_EXACT)
|
||||
return com - coms;
|
||||
/* partial */
|
||||
if (status != M_NOTFOUND)
|
||||
switch (mineq(command, com->c_form)) {
|
||||
case ME_MISMATCH:
|
||||
break;
|
||||
case ME_PARTIAL:
|
||||
if (status >= 0)
|
||||
return M_NOTUNIQUE;
|
||||
status = com - coms;
|
||||
case ME_EXACT:
|
||||
return com - coms;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue