xref: /freebsd/contrib/one-true-awk/testdir/T.recache (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1echo T.recache: test re cache in b.c
2	# thanks to ross ridge for this horror
3
4awk=${awk-../a.out}
5
6echo b >foo1
7$awk '
8BEGIN {
9        #
10        # Fill up DFA cache with run-time REs that have all been
11        # used twice.
12        #
13        CACHE_SIZE=64
14        for(i = 0; i < CACHE_SIZE; i++) {
15                for(j = 0; j < 2; j++) {
16                        "" ~ i "";
17                }
18        }
19        #
20        # Now evalutate an expression that uses two run-time REs
21        # that have never been used before.  The second RE will
22        # push the first out of the cache while the first RE is
23        # still needed.
24        #
25        x = "a"
26        reg1 = "[Aa]"
27        reg2 = "A"
28        sub(reg1, x ~ reg2 ? "B" : "b", x)
29
30        print x
31}
32' >foo2
33diff foo1 foo2 || echo 'BAD: T.recache'
34