(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:
|
case ME_MISMATCH:
|
||||||
break;
|
break;
|
||||||
case ME_PARTIAL:
|
case ME_PARTIAL:
|
||||||
if (res != M_NOTFOUND)
|
if (res >= 0)
|
||||||
return M_NOTUNIQUE;
|
return M_NOTUNIQUE;
|
||||||
res = i;
|
res = i;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,8 +58,10 @@ intmatch(register int value, register int *ptr, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find a matching command from coms[]. Return status is:
|
* Search for COMMAND in COMS[], return its index.
|
||||||
* >= 0: match found, value is array entry in coms[]
|
* 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
|
int
|
||||||
comtch(register s_char *command, struct cmndstr *coms, int comstat,
|
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 struct cmndstr *com;
|
||||||
register int status;
|
register int status;
|
||||||
register int i;
|
|
||||||
|
|
||||||
if (command == 0 || *command == 0)
|
if (command == 0 || *command == 0)
|
||||||
return M_IGNORE;
|
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++) {
|
for (com = coms; com->c_form != 0; com++) {
|
||||||
if ((com->c_permit & comstat) != com->c_permit && !god)
|
if ((com->c_permit & comstat) != com->c_permit && !god)
|
||||||
continue;
|
continue;
|
||||||
if ((i = mineq(command, com->c_form)) == ME_MISMATCH)
|
switch (mineq(command, com->c_form)) {
|
||||||
continue;
|
case ME_MISMATCH:
|
||||||
if (i == ME_EXACT)
|
break;
|
||||||
|
case ME_PARTIAL:
|
||||||
|
if (status >= 0)
|
||||||
|
return M_NOTUNIQUE;
|
||||||
|
status = com - coms;
|
||||||
|
case ME_EXACT:
|
||||||
return com - coms;
|
return com - coms;
|
||||||
/* partial */
|
}
|
||||||
if (status != M_NOTFOUND)
|
|
||||||
return M_NOTUNIQUE;
|
|
||||||
status = com - coms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue