1# This script is used to check that a given awk executable 2# implements the match() and substr() functions appropriately. 3# 4# These were introduced in nawk/gawk, but the original awk 5# does not have them. 6# 7END { 8 RSTART=0 9 RLENGTH=0 10 s1="A real world example" 11 if (! match(s1,"world")) { 12 print "Fail match" 13 } else if (RSTART != 8) { 14 print "Fail RSTART ="RSTART 15 } else if (RLENGTH != 5) { 16 print "Fail RLENGTH ="RLENGTH 17 } else { 18 s2=substr(s1,RSTART,RLENGTH) 19 if (s2 != "world") { 20 print "Fail substr="s2 21 } else { 22 print "Pass" 23 } 24 } 25} 26