]>
diplodocus.org Git - nmh/blob - docs/historical/SRI-NOSC/subs.dir/smatch.c
3 /* switch match, or any unambiguous abbreviation */
4 /* exact match always wins, even if shares same root */
5 /* returns subscript in zero-terminated tbl[] of strings */
6 /* returns -1 if no match, -2 if ambiguous */
12 register char *sp
, *tcp
;
18 for (strlen
= length(string
), tp
= swp
; tcp
= tp
->sw
; tp
++) {
19 if(strlen
< abs(tp
->minchars
)) continue; /* no match */
20 for (sp
= string
; *sp
== *tcp
++; ) {
21 if (*sp
++ == 0) return(tp
-swp
); /* exact match */
24 if (*sp
!= ' ') continue; /* no match */
25 if (*--tcp
== 0) return(tp
-swp
); /* exact match */
27 if (firstone
== -1) firstone
= tp
-swp
; /* possible match */
28 else firstone
= -2; /* ambiguous */
36 return(i
< 0 ? -i
: i
);