2 Proprietary Rand Corporation
, 1981.
3 Further distribution of
this software
4 subject to the terms of the Rand
8 /* switch match, or any unambiguous abbreviation */
9 /* exact match always wins, even if shares same root */
10 /* returns subscript in zero-terminated tbl[] of strings */
11 /* returns -1 if no match, -2 if ambiguous */
16 register char *sp
, *tcp
, c
;
22 for (tp
=tbl
; tcp
= *tp
; tp
++) {
23 for (sp
= string
; *sp
== *tcp
++; ) {
24 if (*sp
++ == 0) return(tp
-tbl
); /* exact match */
27 if (*sp
!= ' ') continue; /* no match */
28 if (*--tcp
== 0) return(tp
-tbl
); /* exact match */
30 if (firstone
== -1) firstone
= tp
-tbl
; /* possible match */
31 else firstone
= -2; /* ambiguous */