(mineq): Rewrite. mineq("dumpcrap", "dump ") now yields ME_MISMATCH
instead of ME_PARTIAL. Closes #804611.
This commit is contained in:
parent
93c4fecfd6
commit
c16179eeae
1 changed files with 13 additions and 7 deletions
|
@ -67,16 +67,22 @@ stmtch(register s_char *obj, s_char *base, int off, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* do partial match comparison.
|
* Compare A with B, up to the first space in B.
|
||||||
|
* Return ME_EXACT if they are the same.
|
||||||
|
* Return ME_PARTIAL if A is a prefix of B.
|
||||||
|
* Else return ME_MISMATCH.
|
||||||
|
* Note: May read B beyond the first space, but not beyond a
|
||||||
|
* terminating 0.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mineq(register s_char *a, register s_char *b)
|
mineq(register s_char *a, register s_char *b)
|
||||||
{
|
{
|
||||||
do {
|
int i;
|
||||||
if (*a++ != *b++)
|
|
||||||
return ME_MISMATCH;
|
/* find common prefix: */
|
||||||
} while (*b != ' ' && *a != 0);
|
for (i = 0; a[i] != 0 && a[i] == b[i]; ++i) ;
|
||||||
if (*a == 0 && (*b == ' ' || *b == 0))
|
|
||||||
return ME_EXACT;
|
if (a[i] != 0) return ME_MISMATCH;
|
||||||
|
if (b[i] == 0 || b[i] == ' ') return ME_EXACT;
|
||||||
return ME_PARTIAL;
|
return ME_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue