|
|
1.1 root 1: /*
2: * Routines for determining if a name is a built-in function.
3: */
4:
5: #include "ilink.h"
6:
7: /*
8: * btable is an array of the names of the Icon builtin functions.
9: */
10: char *btable[] = {
11: #define FncDef(p) "p",
12: #include "../h/fdef.h"
13: #undef FncDef
14: };
15:
16: #define NBUILTIN (sizeof(btable)/sizeof(char *))
17:
18: /*
19: * blocate - binary search for a builtin function.
20: * If found, returns pointer to entry.
21: */
22:
23: blocate(s)
24: register char *s;
25: {
26: register int test, cmp;
27: int low, high;
28:
29: low = 0;
30: high = NBUILTIN;
31: do {
32: test = (low + high) / 2;
33: if ((cmp = strcmp(btable[test], s)) < 0)
34: low = test + 1;
35: else if (cmp > 0)
36: high = test;
37: else
38: return (test + 1);
39: } while (low < high);
40: return 0;
41: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.