1: #include "../h/rt.h"
2:
3: /*
4: * many(c,s,i,j) - find longest prefix of s[i:j] of characters in c.
5: */
6:
7: Xmany(nargs, arg4, arg3, arg2, arg1, arg0)
8: int nargs;
9: struct descrip arg4, arg3, arg2, arg1, arg0;
10: {
11: register int i, j;
12: int t, *cs, csbuf[CSETSIZE];
13: long l1, l2;
14: char sbuf[MAXSTRING];
15:
16: /*
17: * c must be a cset. s defaults to &subject; i defaults to &pos if s
18: * defaulted, 1 otherwise; j defaults to 0.
19: */
20: if (cvcset(&arg1, &cs, csbuf) == NULL)
21: runerr(104, &arg1);
22: if (defstr(&arg2, sbuf, &k_subject))
23: defint(&arg3, &l1, k_pos);
24: else
25: defint(&arg3, &l1, 1);
26: defint(&arg4, &l2, 0);
27:
28: /*
29: * Convert i and j to absolute positions and order them. If i == j,
30: * then the specified substring of s is the empty string and many
31: * fails.
32: */
33: i = cvpos(l1, STRLEN(arg2));
34: j = cvpos(l2, STRLEN(arg2));
35: if (i == j)
36: fail();
37: if (i > j) {
38: t = i;
39: i = j;
40: j = t;
41: }
42:
43: /*
44: * Fail if first character of s[i:j] isn't in c.
45: */
46: if (!tstb(STRLOC(arg2)[i-1], cs))
47: fail();
48:
49: /*
50: * Move i along s[i:j] until a character that is not in c is found or
51: * the end of the string is reached.
52: */
53: i++;
54: while (i < j && tstb(STRLOC(arg2)[i-1], cs))
55: i++;
56:
57: /*
58: * Return the position of the first character not in c.
59: */
60: arg0.type = D_INTEGER;
61: INTVAL(arg0) = i;
62: }
63:
64: Procblock(many,4)
Defined functions
Xmany
defined in line
7;
never used