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