* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)genget.c 8.1 (Berkeley) %G%";
#define LOWER(x) (isupper(x) ? tolower(x) : (x))
* The prefix function returns 0 if *s1 is not a prefix
* of *s2. If *s1 exactly matches *s2, the negative of
* the length is returned. If *s1 is a prefix of *s2,
* the length of *s1 is returned.
while (LOWER(c1
) == LOWER(c2
)) {
return(*s1
? 0 : (*s2
? (s1
- os1
) : (os1
- s1
)));
static char *ambiguous
; /* special return value for command routines */
genget(name
, table
, stlen
)
char *name
; /* name to match */
char **table
; /* name entry in table */
register char **c
, **found
;
for (c
= table
; *c
!= 0; c
= (char **)((char *)c
+ stlen
)) {
if ((n
= isprefix(name
, *c
)) == 0)
if (n
< 0) /* exact match */
* Function call version of Ambiguous()
return((char **)s
== &ambiguous
);