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