1: #include "../h/rt.h"
2:
3: /*
4: * any(c,s,i,j) - test if first character of s[i:j] is in c.
5: */
6:
7: Xany(nargs, arg4, arg3, arg2, arg1, arg0)
8: int nargs;
9: struct descrip arg4, arg3, arg2, arg1, arg0;
10: {
11: register int i, j;
12: long l1, l2;
13: int *cs, csbuf[CSETSIZE];
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 positions in s. If i == j then the specified
30: * substring of s is empty and any fails. Otherwise make i the smaller of
31: * the two. (j is of no further use.)
32: */
33: i = cvpos(l1, STRLEN(arg2));
34: j = cvpos(l2, STRLEN(arg2));
35: if (i == j)
36: fail();
37: if (i > j)
38: i = j;
39:
40: /*
41: * If s[i] is not in the cset c, fail.
42: */
43: if (!tstb(STRLOC(arg2)[i-1], cs))
44: fail();
45:
46: /*
47: * Return pos(s[i+1]).
48: */
49: arg0.type = D_INTEGER;
50: INTVAL(arg0) = i + 1;
51: }
52:
53: Procblock(any,4)
Defined functions
Xany
defined in line
7;
never used