diff --git a/qse/lib/awk/misc.c b/qse/lib/awk/misc.c index b00e8ed4..9c030b12 100644 --- a/qse/lib/awk/misc.c +++ b/qse/lib/awk/misc.c @@ -1,5 +1,5 @@ /* - * $Id: misc.c 210 2009-06-24 08:29:33Z hyunghwan.chung $ + * $Id: misc.c 219 2009-06-30 13:14:39Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -57,7 +57,6 @@ qse_long_t qse_awk_strxtolong ( /*while (QSE_AWK_ISSPACE(awk,*p)) p++;*/ /* check for a sign */ - /*while (*p != QSE_T('\0')) */ while (p < end) { if (*p == QSE_T('-')) @@ -102,7 +101,6 @@ qse_long_t qse_awk_strxtolong ( } /* process the digits */ - /*while (*p != QSE_T('\0'))*/ while (p < end) { if (*p >= QSE_T('0') && *p <= QSE_T('9')) diff --git a/qse/regress/awk/cou-026.awk b/qse/regress/awk/cou-026.awk index 0597c6d9..d61636f9 100644 --- a/qse/regress/awk/cou-026.awk +++ b/qse/regress/awk/cou-026.awk @@ -1,3 +1,34 @@ BEGIN { FS = "\t"; } + { pop[$4] += $3; } -END { for (name in pop) print name, pop[name]; } + +END { + + count = 0; + for (name in pop) + { + for (i = 0; i < count; i++) + { + if (name < x[i]) + { + for (j = count; j > i; j--) + { + x[j] = x[j-1]; + y[j] = y[j-1]; + } + break; + } + } + + x[i] = name; + y[i] = pop[name]; + count++; + } + + + for (i = 0; i < count; i++) + { + print x[i], y[i]; + } + +} diff --git a/qse/regress/awk/quicksort.awk b/qse/regress/awk/quicksort.awk index d17abca6..a7d68731 100644 --- a/qse/regress/awk/quicksort.awk +++ b/qse/regress/awk/quicksort.awk @@ -35,7 +35,6 @@ function qsort(A, left, right, i, last) { last = left for (i = left+1; i <= right; i++) { -# print A[i] "/" A[left] "....." (A[i] < A[left]) if (A[i] < A[left]) { swap(A, ++last, i) diff --git a/qse/regress/awk/regress.out b/qse/regress/awk/regress.out new file mode 100644 index 00000000..e8853ac2 --- /dev/null +++ b/qse/regress/awk/regress.out @@ -0,0 +1,1861 @@ +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-001.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 275 +Canada 25 +China 1032 +USA 237 +Brazil 134 +India 746 +Mexico 78 +France 55 +Japan 120 +Germany 61 +England 56 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-002.awk cou.dat &1 +-------------------------------------------------------------------------------- + COUNTRY AREA POP CONTINENT + + USSR 8649 275 Asia + Canada 3852 25 North America + China 3705 1032 Asia + USA 3615 237 North America + Brazil 3286 134 South America + India 1267 746 Asia + Mexico 762 78 North America + France 211 55 Europe + Japan 144 120 Asia + Germany 96 61 Europe + England 94 56 Europe + + TOTAL 25681 2819 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-003.awk cou.dat &1 +-------------------------------------------------------------------------------- +India 1267 746 Asia +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-004.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +USA 3615 237 North America +Mexico 762 78 North America +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-005.awk cou.dat &1 +-------------------------------------------------------------------------------- +Canada 3852 25 North America +Brazil 3286 134 South America +Mexico 762 78 North America +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-006.awk cou.dat &1 +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-007.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-008.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-009.awk cou.dat &1 +-------------------------------------------------------------------------------- +Canada 3852 25 North America +USA 3615 237 North America +Brazil 3286 134 South America +Mexico 762 78 North America +France 211 55 Europe +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-010.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-011.awk cou.dat &1 +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-012.awk cou.dat &1 +-------------------------------------------------------------------------------- +China 3705 1032 Asia +India 1267 746 Asia +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-013.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-014.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-015.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-016.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-017.awk cou.dat &1 +-------------------------------------------------------------------------------- +Canada 3852 25 North America +China 3705 1032 Asia +USA 3615 237 North America +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-018.awk cou.dat &1 +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-019.awk cou.dat &1 +-------------------------------------------------------------------------------- +cou.dat: USSR 8649 275 Asia +cou.dat: Canada 3852 25 North America +cou.dat: China 3705 1032 Asia +cou.dat: USA 3615 237 North America +cou.dat: Brazil 3286 134 South America +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-020.awk cou.dat &1 +-------------------------------------------------------------------------------- +cou.dat: USSR 8649 275 Asia +cou.dat: Canada 3852 25 North America +cou.dat: China 3705 1032 Asia +cou.dat: USA 3615 237 North America +cou.dat: Brazil 3286 134 South America +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-021.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649000 +China 3705000 +India 1267000 +Japan 144000 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-022.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia +Canada 3852 25 NA +China 3705 1032 Asia +USA 3615 237 NA +Brazil 3286 134 SA +India 1267 746 Asia +Mexico 762 78 NA +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-023.awk cou.dat &1 +-------------------------------------------------------------------------------- +USSR 8649 275 Asia 31.7956 +Canada 3852 25 North America 6.49013 +China 3705 1032 Asia 278.543 +USA 3615 237 North America 65.5602 +Brazil 3286 134 South America 40.7791 +India 1267 746 Asia 588.792 +Mexico 762 78 North America 102.362 +France 211 55 Europe 260.664 +Japan 144 120 Asia 833.333 +Germany 96 61 Europe 635.417 +England 94 56 Europe 595.745 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-024.awk cou.dat &1 +-------------------------------------------------------------------------------- +Total population of the 4 Asian countries is 2173 million. +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-025.awk cou.dat &1 +-------------------------------------------------------------------------------- +Asian population is 2173 million. +European population is 172 million. +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-026.awk cou.dat &1 +-------------------------------------------------------------------------------- +Asia 2173 +Europe 172 +North America 340 +South America 134 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f cou-027.awk cou.dat &1 +-------------------------------------------------------------------------------- + Asia 2173 + North America 340 + Europe 172 + South America 134 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-001.awk emp.dat &1 +-------------------------------------------------------------------------------- +Kathy 40 +Mark 100 +Mary 121 +Susie 76.5 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-002.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth +Dan +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-003.awk emp.dat &1 +-------------------------------------------------------------------------------- +3 Beth 0 +3 Dan 0 +3 Kathy 10 +3 Mark 20 +3 Mary 22 +3 Susie 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-004.awk emp.dat &1 +-------------------------------------------------------------------------------- +1 Beth 4.00 0 +2 Dan 3.74 0 +3 Kathy 4.00 10 +4 Mark 5.00 20 +5 Mary 5.50 22 +6 Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-005.awk emp.dat &1 +-------------------------------------------------------------------------------- +total pay for Beth is 0 +total pay for Dan is 0 +total pay for Kathy is 40 +total pay for Mark is 100 +total pay for Mary is 121 +total pay for Susie is 76.5 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-006.awk emp.dat &1 +-------------------------------------------------------------------------------- +total pay for Beth is $0.00 +total pay for Dan is $0.00 +total pay for Kathy is $40.00 +total pay for Mark is $100.00 +total pay for Mary is $121.00 +total pay for Susie is $76.50 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-007.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth $ 0.00 +Dan $ 0.00 +Kathy $ 40.00 +Mark $100.00 +Mary $121.00 +Susie $ 76.50 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-008.awk emp.dat &1 +-------------------------------------------------------------------------------- +Mark 5.00 20 +Mary 5.50 22 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-009.awk emp.dat &1 +-------------------------------------------------------------------------------- +$100.00 for Mark +$121.00 for Mary +$76.50 for Susie +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-010.awk emp.dat &1 +-------------------------------------------------------------------------------- +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-011.awk emp.dat &1 +-------------------------------------------------------------------------------- +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-012.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-013.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mark 5.00 20 +Mary 5.50 22 +Mary 5.50 22 +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-014.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-015.awk emp.dat &1 +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-016.awk emp.dat &1 +-------------------------------------------------------------------------------- +NAME RATE HOURS + +Beth 4.00 0 +Dan 3.74 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-017.awk emp.dat &1 +-------------------------------------------------------------------------------- +3 employees worked more than 15 hours +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-018.awk emp.dat &1 +-------------------------------------------------------------------------------- +6 employees +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-019.awk emp.dat &1 +-------------------------------------------------------------------------------- +6 employees +total pay is 337.5 +average pay is 56.25 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-020.awk emp.dat &1 +-------------------------------------------------------------------------------- +highest hourly rage: 5.50 for Mary +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-021.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth Dan Kathy Mark Mary Susie +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-022.awk emp.dat &1 +-------------------------------------------------------------------------------- +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-023.awk emp.dat &1 +-------------------------------------------------------------------------------- +Beth 4 +Dan 3 +Kathy 5 +Mark 4 +Mary 4 +Susie 5 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-024.awk emp.dat &1 +-------------------------------------------------------------------------------- +6 lines, 18 words, 77 characters +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-025.awk emp.dat &1 +-------------------------------------------------------------------------------- +no employees are paid more than $6/hour +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-026.awk emp.dat &1 +-------------------------------------------------------------------------------- +Susie 4.25 18 +Mary 5.50 22 +Mark 5.00 20 +Kathy 4.00 10 +Dan 3.74 0 +Beth 4.00 0 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f emp-027.awk emp.dat &1 +-------------------------------------------------------------------------------- +Susie 4.25 18 +Mary 5.50 22 +Mark 5.00 20 +Kathy 4.00 10 +Dan 3.74 0 +Beth 4.00 0 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f adr-001.awk adr.dat &1 +-------------------------------------------------------------------------------- +James Brown 012-345-678 +Richie Ren 02-3473-9192 +Toh WeeKung 9102-1203 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f adr-002.awk adr.dat &1 +-------------------------------------------------------------------------------- +James Brown Somewhere over the rainbow 012-345-678 +Toh WeeKung Singapore 9102-1203 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f unr-001.awk unr.dat &1 +-------------------------------------------------------------------------------- +Beth 4 0 +Dan 3.74 0 +0 4.00 10 +Mark 5.00 20 +Mary 5.5 22 +Susie 4.25 18 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --strictnaming=off --newline=on -o- -f lang-001.awk &1 +-------------------------------------------------------------------------------- +function f (__p0) +{ + print __p0; +} + +BEGIN { + f ("hello"); +} + +hello +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-002.awk &1 +-------------------------------------------------------------------------------- +function f (__p0) +{ + print __p0; + f ("my hello"); +} + +BEGIN { + f (10); +} + +10 +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +my hello +ERROR: CODE [23] LINE [6] block nested too deeply +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-003.awk &1 +-------------------------------------------------------------------------------- +function fn (__p0) +{ + __p0 = 20; +} + +BEGIN { + f = 50; + fn (100); + print f; +} + +50 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-004.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [60] LINE [3] function 'a' redefined +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-005.awk &1 +-------------------------------------------------------------------------------- +function a (__p0) +{ + print __p0; +} + +BEGIN { + local __l0, __l1; + { + __l0 = 50; + { + __l1 = 30; + print __l1; + } + print __l0; + } + a (100); +} + +30 +50 +100 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-006.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [61] LINE [5] global variable 'a' redefined +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --implicit=on --explicit=on --newline=on -o- -f lang-007.awk &1 +-------------------------------------------------------------------------------- +global __g17; + +function fn () +{ + a = 20; + return a; +} + +BEGIN { + __g17 = 30; + print fn (); + print __g17; +} + +20 +30 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-008.awk &1 +-------------------------------------------------------------------------------- +global x; + +BEGIN { + local __l0, __l1; + x = 1; + { + __l0 = 2; + { + __l1 = 3; + print __l1; + } + print __l0; + } + print x; +} + +3 +2 +1 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on --strictnaming=off -o- -f lang-009.awk lang-009.awk &1 +-------------------------------------------------------------------------------- +function a (__p0) +{ + print __p0; +} + +BEGIN { + local __l0; + __l0 = 20; +} + +END { + a (1000); +} +1000 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-010.awk this is just a test &1 +-------------------------------------------------------------------------------- +BEGIN { + print "ARGC=",ARGC; + for (i in ARGV) + { + print (("ARGV[" i) "]"),ARGV[i]; + } + print "----------------------"; + print "ARGC=",ARGC; + split ("111 22 333 555 666 777",ARGV); + for (i in ARGV) + { + print (("ARGV[" i) "]"),ARGV[i]; + } + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10i] is positive\n",10); + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10f] is positive\n",10); + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10E] is positive\n",10124.1123); + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10G] is positive\n",10124.1123); + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10g] is positive\n",10124.1123); + if ((ARGC >= 0)) + printf ("ARGC [%++#10.10f] is positive\n",10124.1123); + printf ("[%d], [%f], [%s]\n",10124.1123,10124.1123,10124.1123); + printf ("[%-10c] [% 0*.*d]\n",65,45,48,(-(1))); + print sprintf ("abc%d %*.*d %c %s %c",10,20,30,40,"good","good",75.34); +} + +ARGC= 6 +ARGV[0] qseawk +ARGV[1] this +ARGV[2] is +ARGV[3] just +ARGV[4] a +ARGV[5] test +---------------------- +ARGC= 6 +ARGV[1] 111 +ARGV[2] 22 +ARGV[3] 333 +ARGV[4] 555 +ARGV[5] 666 +ARGV[6] 777 +ARGC [+0000000010] is positive +ARGC [+10.0000000000] is positive +ARGC [+1.0124112300E+04] is positive +ARGC [+10124.11230] is positive +ARGC [+10124.11230] is positive +ARGC [+10124.1123000000] is positive +[10124], [10124.112300], [10124.1] +[A ] [-000000000000000000000000000000000000000000000001] +abc10 000000000000000000000000000040 g good K +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-011.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + a[1,2,3] = 20; + a[4,5,6] = 30; + for (i in a) + { + n = split (i,k,SUBSEP); + for (j = 1; (j <= n); (j)++) + { + print k[j]; + } + print "-------------------"; + } + if (((1,2,3) in a)) + { + print ("(1,2,3) in a ==> " a[1,2,3]); + } + else + { + print "(1,2,3) not in a"; + } + if (((4,5) in a)) + { + print ("(4,5) in a ==> " a[4,5]); + } + else + { + print "(4,5) not in a"; + } +} + +1 +2 +3 +------------------- +4 +5 +6 +------------------- +(1,2,3) in a ==> 20 +(4,5) not in a +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-012.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + OFS = " "; + print "1==1 :",(1 == 1); + print "1==0 :",(1 == 0); + print "1.0==1 :",(1.0 == 1); + print "1.1==1 :",(1.1 == 1); + print "1.0!=1 :",(1.0 != 1); + print "1.1!=1 :",(1.1 != 1); + print ""abc" == "abc"",("abc" == "abc"); + print ""abc" != "abc"",("abc" != "abc"); + print "--------------------------"; + print "a == "" :",(a == ""); + print "a >= "" :",(a >= ""); + print "a <= "" :",(a <= ""); + print "a > "" :",(a > ""); + print "a < "" :",(a < ""); + print "--------------------------"; + print "a == " " :",(a == " "); + print "a >= " " :",(a >= " "); + print "a <= " " :",(a <= " "); + print "a > " " :",(a > " "); + print "a < " " :",(a < " "); + print "--------------------------"; + print """ == a :",("" == a); + print """ >= a:",("" >= a); + print """ <= a:",("" <= a); + print """ > a:",("" > a); + print """ < a:",("" < a); + print "--------------------------"; + print "" " == a :",(" " == a); + print "" " >= a:",(" " >= a); + print "" " <= a:",(" " <= a); + print "" " > a:",(" " > a); + print "" " < a:",(" " < a); + print "--------------------------"; + print "10 == "10"",(10 == "10"); + print "10 != "10"",(10 != "10"); + print "10 >= "10"",(10 >= "10"); + print "10 <= "10"",(10 <= "10"); + print "10 > "10"",(10 > "10"); + print "10 < "10"",(10 < "10"); + print "--------------------------"; + print "10 == "11"",(10 == "11"); + print "10 != "11"",(10 != "11"); + print "10 >= "11"",(10 >= "11"); + print "10 <= "11"",(10 <= "11"); + print "10 > "11"",(10 > "11"); + print "10 < "11"",(10 < "11"); + print "--------------------------"; + print "11 == "10"",(11 == "10"); + print "11 != "10"",(11 != "10"); + print "11 >= "10"",(11 >= "10"); + print "11 <= "10"",(11 <= "10"); + print "11 > "10"",(11 > "10"); + print "11 < "10"",(11 < "10"); + print "--------------------------"; + print "010 == "8"",(010 == "8"); + print "010 != "8"",(010 != "8"); + print "010 >= "8"",(010 >= "8"); + print "010 <= "8"",(010 <= "8"); + print "010 > "8"",(010 > "8"); + print "010 < "8"",(010 < "8"); + print "--------------------------"; + print "10 == "10.0"",(10 == "10.0"); + print "10 != "10.0"",(10 != "10.0"); + print "10 >= "10.0"",(10 >= "10.0"); + print "10 <= "10.0"",(10 <= "10.0"); + print "10 > "10.0"",(10 > "10.0"); + print "10 < "10.0"",(10 < "10.0"); + print "--------------------------"; + print "10.0 == "10"",(10.0 == "10"); + print "10.0 != "10"",(10.0 != "10"); + print "10.0 >= "10"",(10.0 >= "10"); + print "10.0 <= "10"",(10.0 <= "10"); + print "10.0 > "10"",(10.0 > "10"); + print "10.0 < "10"",(10.0 < "10"); + print "--------------------------"; + print ""10" == 10.0",("10" == 10.0); + print ""10" != 10.0",("10" != 10.0); + print ""10" >= 10.0",("10" >= 10.0); + print ""10" <= 10.0",("10" <= 10.0); + print ""10" > 10.0",("10" > 10.0); + print ""10" < 10.0",("10" < 10.0); + print "--------------------------"; + print ""10" == 10.1",("10" == 10.1); + print ""10" != 10.1",("10" != 10.1); + print ""10" >= 10.1",("10" >= 10.1); + print ""10" <= 10.1",("10" <= 10.1); + print ""10" > 10.1",("10" > 10.1); + print ""10" < 10.1",("10" < 10.1); + print (0.234 + 1.01123); + print 12345678901234567890E20; + print .123; + print (+(.123)); + print (-(.123)); + print .123E-; + print (+(.123E-)); + print (-(.123E-)); + print ((-(.123E-)) + "123"); +} + +1==1 : 1 +1==0 : 0 +1.0==1 : 1 +1.1==1 : 0 +1.0!=1 : 0 +1.1!=1 : 1 +"abc" == "abc" 1 +"abc" != "abc" 0 +-------------------------- +a == "" : 1 +a >= "" : 1 +a <= "" : 1 +a > "" : 0 +a < "" : 0 +-------------------------- +a == " " : 0 +a >= " " : 0 +a <= " " : 1 +a > " " : 0 +a < " " : 1 +-------------------------- +"" == a : 1 +"" >= a: 1 +"" <= a: 1 +"" > a: 0 +"" < a: 0 +-------------------------- +" " == a : 0 +" " >= a: 1 +" " <= a: 0 +" " > a: 1 +" " < a: 0 +-------------------------- +10 == "10" 1 +10 != "10" 0 +10 >= "10" 1 +10 <= "10" 1 +10 > "10" 0 +10 < "10" 0 +-------------------------- +10 == "11" 0 +10 != "11" 1 +10 >= "11" 0 +10 <= "11" 1 +10 > "11" 0 +10 < "11" 1 +-------------------------- +11 == "10" 0 +11 != "10" 1 +11 >= "10" 1 +11 <= "10" 0 +11 > "10" 1 +11 < "10" 0 +-------------------------- +010 == "8" 1 +010 != "8" 0 +010 >= "8" 1 +010 <= "8" 1 +010 > "8" 0 +010 < "8" 0 +-------------------------- +10 == "10.0" 0 +10 != "10.0" 1 +10 >= "10.0" 0 +10 <= "10.0" 1 +10 > "10.0" 0 +10 < "10.0" 1 +-------------------------- +10.0 == "10" 1 +10.0 != "10" 0 +10.0 >= "10" 1 +10.0 <= "10" 1 +10.0 > "10" 0 +10.0 < "10" 0 +-------------------------- +"10" == 10.0 1 +"10" != 10.0 0 +"10" >= 10.0 1 +"10" <= 10.0 1 +"10" > 10.0 0 +"10" < 10.0 0 +-------------------------- +"10" == 10.1 0 +"10" != 10.1 1 +"10" >= 10.1 0 +"10" <= 10.1 1 +"10" > 10.1 0 +"10" < 10.1 1 +1.24523 +1.23457e+39 +0.123 +0.123 +-0.123 +0.123 +0.123 +-0.123 +122.877 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-013.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + CONVFMT = "%s"; + printf ("%s\n",10.34); +} + +ERROR: CODE [118] LINE [3] recursion detected in format conversion +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-014.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + a = (10 + 20); + b = (10 + 20); + c = (10 + 20); + print a,b,c; +} + +30 30 30 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-015.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [23] LINE [3] block nested too deeply +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-016.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + printf "[[[[[%s]]]]\n",sprintf ("abc %s abc",sprintf ("def %s %s",sprintf ("%s %s %s","xyz",1.2342,"xyz"),sprintf ("ttt %s tttt",123.12))); + printf "[[[[%s]]]]\n",sprintf ("ttt %s tttt",123.12); +} + +[[[[[abc def xyz 1.2342 xyz ttt 123.12 tttt abc]]]] +[[[[ttt 123.12 tttt]]]] +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-017.awk &1 +-------------------------------------------------------------------------------- +function gety () +{ + return (y)++; +} + +function getx () +{ + if ((x == 2)) + error (); + return (x)++; +} + +function main () +{ + x = 0; + y = 0; + print (getx () + gety ()); + print (getx () + gety ()); + print (getx () + gety ()); + print (getx () + gety ()); + return 999; +} + +function error () +{ + exit 200; +} + +BEGIN { + main (); +} + +END { + print "END OF PROGRAM"; + return 10; +} +END { + print "END OF PROGRAM 2"; + exit 100; +} +END { + print "END OF PROGRAM 3"; + exit 900; +} +0 +2 +END OF PROGRAM +END OF PROGRAM 2 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --call main --newline=on -o- -f lang-017.awk &1 +-------------------------------------------------------------------------------- +function gety () +{ + return (y)++; +} + +function getx () +{ + if ((x == 2)) + error (); + return (x)++; +} + +function main () +{ + x = 0; + y = 0; + print (getx () + gety ()); + print (getx () + gety ()); + print (getx () + gety ()); + print (getx () + gety ()); + return 999; +} + +function error () +{ + exit 200; +} + +BEGIN { + main (); +} + +END { + print "END OF PROGRAM"; + return 10; +} +END { + print "END OF PROGRAM 2"; + exit 100; +} +END { + print "END OF PROGRAM 3"; + exit 900; +} +0 +2 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-018.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [65] LINE [1] duplicate global variable 'ARGV' +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-019.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [67] LINE [1] '+' not a valid parameter name +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-020.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [68] LINE [1] '+' not a valid variable name +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-021.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [68] LINE [3] '+' not a valid variable name +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-022.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [39] LINE [2] a left parenthesis expected in place of '=' +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-023.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [44] LINE [5] a colon expected in place of ';' +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-024.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + local __l0; + __l0 = 21; + print ((__l0 > 20))?1:2; +} + +1 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-025.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20; + delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix; +} + +ERROR: CODE [92] LINE [3] variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-026.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + abc[20] = "abc"; + print abc[20]; + abc = 10; + print abc; +} + +abc +ERROR: CODE [100] LINE [4] map 'abc' not assignable with a scalar +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-027.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [31] LINE [2] invalid character '' +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-028.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [59] LINE [2] intrinsic function 'substr' redefined +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-029.awk &1 +-------------------------------------------------------------------------------- +ERROR: CODE [60] LINE [9] function 'abc' redefined +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-030.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + print (1 + 0); + print (0B11111111 + 0); + print (10 + 0); + print (0x10 + 0); + print (0b00000010 + 0); + print (0b + 0); + print (0x + 0); + print "-----------------------"; + print ((+(1)) + 0); + print ((+(0B11111111)) + 0); + print ((+(10)) + 0); + print ((+(0x10)) + 0); + print ((+(0b00000010)) + 0); + print ((+(0b)) + 0); + print ((+(0x)) + 0); + print "-----------------------"; + print ((-(1)) + 0); + print ((-(0B11111111)) + 0); + print ((-(10)) + 0); + print ((-(0x10)) + 0); + print ((-(0b00000010)) + 0); + print ((-(0b)) + 0); + print ((-(0x)) + 0); +} + +1 +255 +10 +16 +2 +0 +0 +----------------------- +1 +255 +10 +16 +2 +0 +0 +----------------------- +-1 +-255 +-10 +-16 +-2 +0 +0 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk --newline=on -o- -f lang-031.awk &1 +-------------------------------------------------------------------------------- +BEGIN { + print match ("hhhheeeo",/e+/); + print RSTART,RLENGTH; + print match ("heeeo",/e/); + print RSTART,RLENGTH; + print match ("heeeo",/t/); + print RSTART,RLENGTH; + print "--------------------------"; + print match ("hhhheeeo","e+"); + print RSTART,RLENGTH; + print match ("heeeo","e"); + print RSTART,RLENGTH; + print match ("heeeo","t"); + print RSTART,RLENGTH; + print "--------------------------"; +} + +5 +5 3 +2 +2 1 +0 +0 -1 +-------------------------- +5 +5 3 +2 +2 1 +0 +0 -1 +-------------------------- +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f quicksort.awk quicksort.dat &1 +-------------------------------------------------------------------------------- +0.0000000000 +0.11111111111111111111111111111 +1 +0xA +11.2839091 +12 +29 +0b11111 +34 +35 +92 +301 +493 +19123 +1.E12 +99X +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f quicksort2.awk quicksort2.dat &1 +-------------------------------------------------------------------------------- +0.0000000000 +0.11111111111111111111111111111 +1 +0xA +11.2839091 +12 +29 +0b11111 +34 +35 +92 +301 +493 +19123 +1.E12 +99X +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f asm.awk asm.s &1 +-------------------------------------------------------------------------------- +549 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f stripcomment.awk stripcomment.dat &1 +-------------------------------------------------------------------------------- + + +#include +int main () +{ + + printf ("hello, world\n"); + return 0; +} +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f wordfreq.awk wordfreq.awk &1 +-------------------------------------------------------------------------------- +distinctions 1 +list 1 +0 3 +1 1 +end 1 +punctuation 1 +blank 2 +remove 2 +freq 3 +for 2 +_ 2 +a 2 +in 1 +i 4 +word 4 +nf 1 +of 1 +gsub 2 +tolower 1 +alnum 2 +wordfreq 1 +awk 1 +print 2 +frequencies 1 +case 1 +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f hanoi.awk &1 +-------------------------------------------------------------------------------- +0 54321 +1 +2 + +0 5432 +1 1 +2 + +0 543 +1 1 +2 2 + +0 543 +1 +2 21 + +0 54 +1 3 +2 21 + +0 541 +1 3 +2 2 + +0 541 +1 32 +2 + +0 54 +1 321 +2 + +0 5 +1 321 +2 4 + +0 5 +1 32 +2 41 + +0 52 +1 3 +2 41 + +0 521 +1 3 +2 4 + +0 521 +1 +2 43 + +0 52 +1 1 +2 43 + +0 5 +1 1 +2 432 + +0 5 +1 +2 4321 + +0 +1 5 +2 4321 + +0 1 +1 5 +2 432 + +0 1 +1 52 +2 43 + +0 +1 521 +2 43 + +0 3 +1 521 +2 4 + +0 3 +1 52 +2 41 + +0 32 +1 5 +2 41 + +0 321 +1 5 +2 4 + +0 321 +1 54 +2 + +0 32 +1 541 +2 + +0 3 +1 541 +2 2 + +0 3 +1 54 +2 21 + +0 +1 543 +2 21 + +0 1 +1 543 +2 2 + +0 1 +1 5432 +2 + +0 +1 54321 +2 + +-------------------------------------------------------------------------------- +../../cmd/awk/qseawk -f indent.awk indent.dat &1 +-------------------------------------------------------------------------------- +#!/bin/sh + +if [ $# -ne 0 ] +then + echo "not the right usage" + exit 1 +fi + +while true +do + sleep 20 +done diff --git a/qse/regress/awk/regress.sh b/qse/regress/awk/regress.sh index 33bb32fe..d36d7e1d 100755 --- a/qse/regress/awk/regress.sh +++ b/qse/regress/awk/regress.sh @@ -2,22 +2,34 @@ echo_so() { - echo "--------------------------------------------------------------------------------" - #tput smso + tput smso while [ $# -gt 0 ] do echo -n "$1 " shift done echo - #tput rmso + tput rmso +} + +echo_title() +{ + echo "--------------------------------------------------------------------------------" + while [ $# -gt 0 ] + do + echo -n "$1 " + echo -n "$1 " >/dev/stderr + shift + done + echo + echo > /dev/stderr echo "--------------------------------------------------------------------------------" } print_usage() { - echo "Usage: $0 init" - echo " $0 test" + echo_so "Usage: $0 init" + echo_so " $0 test" } ################### @@ -26,6 +38,7 @@ print_usage() QSEAWK=${QSEAWK:=../../cmd/awk/qseawk} TMPFILE="${TMPFILE:=./regress.temp}" +OUTFILE="${OUTFILE:=./regress.out}" PROGS=" cou-001.awk/cou.dat// @@ -137,31 +150,54 @@ PROGS=" exit 1; } -echo "${PROGS}" > "${TMPFILE}" +run_scripts() +{ + echo "${PROGS}" > "${TMPFILE}" + + while read prog + do + [ -z "${prog}" ] && continue + + script="`echo ${prog} | cut -d/ -f1`" + datafile="`echo ${prog} | cut -d/ -f2`" + redinfile="`echo ${prog} | cut -d/ -f3`" + awkopts="`echo ${prog} | cut -d/ -f4`" + + [ -z "${script}" ] && continue + [ -f "${script}" ] || + { + echo_so "${script} not found" + continue + } + + [ -z "${redinfile}" ] && redinfile="/dev/stdin" + + echo_title "${QSEAWK} ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1" + ${QSEAWK} ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1 + + done < "${TMPFILE}" + + rm -f "${TMPFILE}" +} -while read prog -do - [ -z "${prog}" ] && continue - - script="`echo ${prog} | cut -d/ -f1`" - datafile="`echo ${prog} | cut -d/ -f2`" - redinfile="`echo ${prog} | cut -d/ -f3`" - awkopts="`echo ${prog} | cut -d/ -f4`" - - [ -z "${script}" ] && continue - [ -f "${script}" ] || - { - echo_so "${script} not found" - continue +case $1 in +init) + run_scripts > "${OUTFILE}" + ;; +test) + run_scripts > "${OUTFILE}.temp" + diff -q "${OUTFILE}" "${OUTFILE}.temp" || { + echo_so "ERROR: ${OUTFILE} differs from ${OUTFILE}.temp." + echo_so " Check the scripts and output files for any errors." + exit 1 } - - [ -z "${redinfile}" ] && redinfile="/dev/stdin" - - echo_so "${QSEAWK} ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1" - ${QSEAWK} ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1 - -done < "${TMPFILE}" - -rm -f "${TMPFILE}" - + rm -f "${OUTFILE}.temp" + ;; +*) + echo_so "USAGE: $0 init" + echo_so " $0 test" + exit 1 + ;; +esac + exit 0 diff --git a/qse/regress/awk/wordfreq.awk b/qse/regress/awk/wordfreq.awk index ce38bfcb..1dca75a1 100644 --- a/qse/regress/awk/wordfreq.awk +++ b/qse/regress/awk/wordfreq.awk @@ -10,7 +10,6 @@ for (i = 1; i <= NF; i++) freq[$i]++; } -#/[^kkka-bcx-dd-y]|abc|def/ END { for (word in freq)