From e337e01d46f350ec94a06441c7f559605693c822 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 27 Jun 2009 07:05:19 +0000 Subject: [PATCH] fixed a few minor bugs --- qse/cmd/awk/asm.awk | 52 --------- qse/cmd/awk/cou-001.out | 15 --- qse/cmd/awk/cou-002.out | 29 ----- qse/cmd/awk/cou-003.out | 6 -- qse/cmd/awk/cou-004.out | 5 - qse/cmd/awk/cou-005.out | 6 -- qse/cmd/awk/cou-006.out | 5 - qse/cmd/awk/cou-007.out | 6 -- qse/cmd/awk/cou-008.out | 6 -- qse/cmd/awk/cou-009.out | 9 -- qse/cmd/awk/cou-010.out | 6 -- qse/cmd/awk/cou-011.out | 2 - qse/cmd/awk/cou-012.out | 4 - qse/cmd/awk/cou-013.out | 9 -- qse/cmd/awk/cou-014.out | 9 -- qse/cmd/awk/cou-015.out | 9 -- qse/cmd/awk/cou-016.out | 9 -- qse/cmd/awk/cou-017.out | 5 - qse/cmd/awk/cou-018.out | 2 - qse/cmd/awk/cou-019.out | 9 -- qse/cmd/awk/cou-020.out | 9 -- qse/cmd/awk/cou-021.out | 8 -- qse/cmd/awk/cou-022.out | 27 ----- qse/cmd/awk/cou-023.out | 20 ---- qse/cmd/awk/cou-024.out | 9 -- qse/cmd/awk/cou-025.out | 14 --- qse/cmd/awk/cou-026.out | 16 --- qse/cmd/awk/cou-027.out | 18 ---- qse/cmd/awk/emp-001.out | 8 -- qse/cmd/awk/emp-002.out | 6 -- qse/cmd/awk/emp-003.out | 10 -- qse/cmd/awk/emp-004.out | 10 -- qse/cmd/awk/emp-005.out | 10 -- qse/cmd/awk/emp-006.out | 10 -- qse/cmd/awk/emp-007.out | 10 -- qse/cmd/awk/emp-008.out | 4 - qse/cmd/awk/emp-009.out | 7 -- qse/cmd/awk/emp-010.out | 3 - qse/cmd/awk/emp-011.out | 3 - qse/cmd/awk/emp-012.out | 7 -- qse/cmd/awk/emp-013.out | 11 -- qse/cmd/awk/emp-014.out | 7 -- qse/cmd/awk/emp-015.out | 20 ---- qse/cmd/awk/emp-016.out | 17 --- qse/cmd/awk/emp-017.out | 8 -- qse/cmd/awk/emp-018.out | 4 - qse/cmd/awk/emp-019.out | 12 --- qse/cmd/awk/emp-020.out | 9 -- qse/cmd/awk/emp-021.out | 8 -- qse/cmd/awk/emp-022.out | 8 -- qse/cmd/awk/emp-023.out | 10 -- qse/cmd/awk/emp-024.out | 9 -- qse/cmd/awk/emp-025.out | 12 --- qse/cmd/awk/emp-026.out | 18 ---- qse/cmd/awk/emp-027.out | 15 --- qse/cmd/awk/emp-ko.data | 6 -- qse/cmd/awk/manifest | 1 - qse/cmd/awk/mkjar.bat | 8 -- qse/cmd/awk/wordfreq.awk | 20 ---- qse/include/qse/awk/Awk.hpp | 4 +- qse/include/qse/awk/awk.h | 4 +- qse/lib/awk/err.c | 12 +-- qse/lib/awk/fnc.c | 8 +- qse/lib/awk/parse.c | 17 +-- qse/lib/awk/rio.c | 10 +- qse/lib/awk/run.c | 16 ++- qse/regress/awk/asm.d1 | 14 --- qse/regress/awk/{asm.d2 => asm.dat} | 0 qse/{cmd => regress}/awk/asm.s | 0 qse/{cmd => regress}/awk/cou-001.awk | 0 qse/{cmd => regress}/awk/cou-002.awk | 2 +- qse/{cmd => regress}/awk/cou-003.awk | 0 qse/{cmd => regress}/awk/cou-004.awk | 0 qse/{cmd => regress}/awk/cou-005.awk | 0 qse/{cmd => regress}/awk/cou-006.awk | 0 qse/{cmd => regress}/awk/cou-007.awk | 0 qse/{cmd => regress}/awk/cou-008.awk | 0 qse/{cmd => regress}/awk/cou-009.awk | 0 qse/{cmd => regress}/awk/cou-010.awk | 0 qse/{cmd => regress}/awk/cou-011.awk | 0 qse/{cmd => regress}/awk/cou-012.awk | 0 qse/{cmd => regress}/awk/cou-013.awk | 0 qse/{cmd => regress}/awk/cou-014.awk | 0 qse/{cmd => regress}/awk/cou-015.awk | 0 qse/{cmd => regress}/awk/cou-016.awk | 0 qse/{cmd => regress}/awk/cou-017.awk | 0 qse/{cmd => regress}/awk/cou-018.awk | 0 qse/{cmd => regress}/awk/cou-019.awk | 0 qse/{cmd => regress}/awk/cou-020.awk | 0 qse/{cmd => regress}/awk/cou-021.awk | 0 qse/{cmd => regress}/awk/cou-022.awk | 0 qse/{cmd => regress}/awk/cou-023.awk | 0 qse/{cmd => regress}/awk/cou-024.awk | 0 qse/{cmd => regress}/awk/cou-025.awk | 0 qse/{cmd => regress}/awk/cou-026.awk | 0 qse/{cmd => regress}/awk/cou-027.awk | 0 .../awk/cou-en.data => regress/awk/cou.dat} | 0 qse/regress/awk/emp.d | 6 -- .../awk/emp-en.data => regress/awk/emp.dat} | 0 qse/regress/awk/indent.awk | 56 ++++++++++ .../awk/{quicksort.d => quicksort.dat} | 0 .../awk/{quicksort2.d => quicksort2.dat} | 0 qse/regress/awk/regress.sh | 101 ++++++++++++------ .../awk/{stripcomment.d => stripcomment.dat} | 0 qse/regress/awk/wordfreq.awk | 2 - 105 files changed, 164 insertions(+), 703 deletions(-) delete mode 100644 qse/cmd/awk/asm.awk delete mode 100644 qse/cmd/awk/cou-001.out delete mode 100644 qse/cmd/awk/cou-002.out delete mode 100644 qse/cmd/awk/cou-003.out delete mode 100644 qse/cmd/awk/cou-004.out delete mode 100644 qse/cmd/awk/cou-005.out delete mode 100644 qse/cmd/awk/cou-006.out delete mode 100644 qse/cmd/awk/cou-007.out delete mode 100644 qse/cmd/awk/cou-008.out delete mode 100644 qse/cmd/awk/cou-009.out delete mode 100644 qse/cmd/awk/cou-010.out delete mode 100644 qse/cmd/awk/cou-011.out delete mode 100644 qse/cmd/awk/cou-012.out delete mode 100644 qse/cmd/awk/cou-013.out delete mode 100644 qse/cmd/awk/cou-014.out delete mode 100644 qse/cmd/awk/cou-015.out delete mode 100644 qse/cmd/awk/cou-016.out delete mode 100644 qse/cmd/awk/cou-017.out delete mode 100644 qse/cmd/awk/cou-018.out delete mode 100644 qse/cmd/awk/cou-019.out delete mode 100644 qse/cmd/awk/cou-020.out delete mode 100644 qse/cmd/awk/cou-021.out delete mode 100644 qse/cmd/awk/cou-022.out delete mode 100644 qse/cmd/awk/cou-023.out delete mode 100644 qse/cmd/awk/cou-024.out delete mode 100644 qse/cmd/awk/cou-025.out delete mode 100644 qse/cmd/awk/cou-026.out delete mode 100644 qse/cmd/awk/cou-027.out delete mode 100644 qse/cmd/awk/emp-001.out delete mode 100644 qse/cmd/awk/emp-002.out delete mode 100644 qse/cmd/awk/emp-003.out delete mode 100644 qse/cmd/awk/emp-004.out delete mode 100644 qse/cmd/awk/emp-005.out delete mode 100644 qse/cmd/awk/emp-006.out delete mode 100644 qse/cmd/awk/emp-007.out delete mode 100644 qse/cmd/awk/emp-008.out delete mode 100644 qse/cmd/awk/emp-009.out delete mode 100644 qse/cmd/awk/emp-010.out delete mode 100644 qse/cmd/awk/emp-011.out delete mode 100644 qse/cmd/awk/emp-012.out delete mode 100644 qse/cmd/awk/emp-013.out delete mode 100644 qse/cmd/awk/emp-014.out delete mode 100644 qse/cmd/awk/emp-015.out delete mode 100644 qse/cmd/awk/emp-016.out delete mode 100644 qse/cmd/awk/emp-017.out delete mode 100644 qse/cmd/awk/emp-018.out delete mode 100644 qse/cmd/awk/emp-019.out delete mode 100644 qse/cmd/awk/emp-020.out delete mode 100644 qse/cmd/awk/emp-021.out delete mode 100644 qse/cmd/awk/emp-022.out delete mode 100644 qse/cmd/awk/emp-023.out delete mode 100644 qse/cmd/awk/emp-024.out delete mode 100644 qse/cmd/awk/emp-025.out delete mode 100644 qse/cmd/awk/emp-026.out delete mode 100644 qse/cmd/awk/emp-027.out delete mode 100644 qse/cmd/awk/emp-ko.data delete mode 100644 qse/cmd/awk/manifest delete mode 100644 qse/cmd/awk/mkjar.bat delete mode 100644 qse/cmd/awk/wordfreq.awk delete mode 100644 qse/regress/awk/asm.d1 rename qse/regress/awk/{asm.d2 => asm.dat} (100%) rename qse/{cmd => regress}/awk/asm.s (100%) rename qse/{cmd => regress}/awk/cou-001.awk (100%) rename qse/{cmd => regress}/awk/cou-002.awk (85%) rename qse/{cmd => regress}/awk/cou-003.awk (100%) rename qse/{cmd => regress}/awk/cou-004.awk (100%) rename qse/{cmd => regress}/awk/cou-005.awk (100%) rename qse/{cmd => regress}/awk/cou-006.awk (100%) rename qse/{cmd => regress}/awk/cou-007.awk (100%) rename qse/{cmd => regress}/awk/cou-008.awk (100%) rename qse/{cmd => regress}/awk/cou-009.awk (100%) rename qse/{cmd => regress}/awk/cou-010.awk (100%) rename qse/{cmd => regress}/awk/cou-011.awk (100%) rename qse/{cmd => regress}/awk/cou-012.awk (100%) rename qse/{cmd => regress}/awk/cou-013.awk (100%) rename qse/{cmd => regress}/awk/cou-014.awk (100%) rename qse/{cmd => regress}/awk/cou-015.awk (100%) rename qse/{cmd => regress}/awk/cou-016.awk (100%) rename qse/{cmd => regress}/awk/cou-017.awk (100%) rename qse/{cmd => regress}/awk/cou-018.awk (100%) rename qse/{cmd => regress}/awk/cou-019.awk (100%) rename qse/{cmd => regress}/awk/cou-020.awk (100%) rename qse/{cmd => regress}/awk/cou-021.awk (100%) rename qse/{cmd => regress}/awk/cou-022.awk (100%) rename qse/{cmd => regress}/awk/cou-023.awk (100%) rename qse/{cmd => regress}/awk/cou-024.awk (100%) rename qse/{cmd => regress}/awk/cou-025.awk (100%) rename qse/{cmd => regress}/awk/cou-026.awk (100%) rename qse/{cmd => regress}/awk/cou-027.awk (100%) rename qse/{cmd/awk/cou-en.data => regress/awk/cou.dat} (100%) delete mode 100644 qse/regress/awk/emp.d rename qse/{cmd/awk/emp-en.data => regress/awk/emp.dat} (100%) create mode 100644 qse/regress/awk/indent.awk rename qse/regress/awk/{quicksort.d => quicksort.dat} (100%) rename qse/regress/awk/{quicksort2.d => quicksort2.dat} (100%) rename qse/regress/awk/{stripcomment.d => stripcomment.dat} (100%) diff --git a/qse/cmd/awk/asm.awk b/qse/cmd/awk/asm.awk deleted file mode 100644 index e0bc6345..00000000 --- a/qse/cmd/awk/asm.awk +++ /dev/null @@ -1,52 +0,0 @@ -# -# $Id: asm.awk,v 1.4 2007/09/27 11:33:45 bacon Exp $ -# -# Taken from the book "The AWK Programming Language" -# aseawk++ -si asm.awk -a asm.s -nostripspaces -baseone -# - -BEGIN { - srcfile = ARGV[1]; - ARGV[1] = ""; - tempfile = "asm.temp"; - n = split("const get put ld st add sub jpos jz j halt", x); - for (i = 1; i <= n; i++) op[x[i]] = i - 1; - -# PASS 1 - FS = "[ \t]+"; - while (getline 0) { - sub (/#.*/, ""); - symtab[$1] = nextmem; - - if ($2 != "") { - print $2 "\t" $3 >tempfile; - nextmem++; - } - } - close (tempfile); - -# PASS 2 - nextmem = 0; - while (getline 0) { - if ($2 !~ /^[0-9]*$/) $2 = symtab[$2]; - mem[nextmem++] = 1000 * op[$1] + $2; - } - -# INTERPRETER - for (pc = 0; pc >= 0; ) { - addr = mem[pc] % 1000; - code = int(mem[pc++] / 1000); - if (code == op["get"]) { if (getline acc <= 0) acc = 0; } - else if (code == op["put"]) { print acc; } - else if (code == op["st"]) { mem[addr] = acc; } - else if (code == op["ld"]) { acc = mem[addr]; } - else if (code == op["add"]) { acc += mem[addr]; } - else if (code == op["sub"]) { acc -= mem[addr]; } - else if (code == op["jpos"]) { if (acc > 0) pc = addr; } - else if (code == op["jz"]) { if (acc == 0) pc = addr; } - else if (code == op["j"]) { pc = addr; } - else if (code == op["halt"]) { pc = -1; } - else { pc = -1; } - } -} - diff --git a/qse/cmd/awk/cou-001.out b/qse/cmd/awk/cou-001.out deleted file mode 100644 index b3842fbd..00000000 --- a/qse/cmd/awk/cou-001.out +++ /dev/null @@ -1,15 +0,0 @@ -{ - print $1,$3; -} - -USSR 275 -Canada 25 -China 1032 -USA 237 -Brazil 134 -India 746 -Mexico 78 -France 55 -Japan 120 -Germany 61 -England 56 diff --git a/qse/cmd/awk/cou-002.out b/qse/cmd/awk/cou-002.out deleted file mode 100644 index e8e10501..00000000 --- a/qse/cmd/awk/cou-002.out +++ /dev/null @@ -1,29 +0,0 @@ -BEGIN { - FS = " "; - printf ("%10s %6s %5s %s\n\n","COUNTRY","AREA","POP","CONTINENT"); -} - -{ - printf ("%10s %6d %5d %s\n",$1,$2,$3,$4); - area = (area + $2); - pop = (pop + $3); -} - -END { - printf ("\n%10s %6d %5d\n","TOTAL",area,pop); -} - 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 diff --git a/qse/cmd/awk/cou-003.out b/qse/cmd/awk/cou-003.out deleted file mode 100644 index 05417c26..00000000 --- a/qse/cmd/awk/cou-003.out +++ /dev/null @@ -1,6 +0,0 @@ -(($3 / $2) >= 0.5) - -India 1267 746 Asia -Japan 144 120 Asia -Germany 96 61 Europe -England 94 56 Europe diff --git a/qse/cmd/awk/cou-004.out b/qse/cmd/awk/cou-004.out deleted file mode 100644 index bb237a77..00000000 --- a/qse/cmd/awk/cou-004.out +++ /dev/null @@ -1,5 +0,0 @@ -($0 >= "M") - -USSR 8649 275 Asia -USA 3615 237 North America -Mexico 762 78 North America diff --git a/qse/cmd/awk/cou-005.out b/qse/cmd/awk/cou-005.out deleted file mode 100644 index 345dae8f..00000000 --- a/qse/cmd/awk/cou-005.out +++ /dev/null @@ -1,6 +0,0 @@ -($1 < $4) - -Canada 3852 25 North America -Brazil 3286 134 South America -Mexico 762 78 North America -England 94 56 Europe diff --git a/qse/cmd/awk/cou-006.out b/qse/cmd/awk/cou-006.out deleted file mode 100644 index 7de5b826..00000000 --- a/qse/cmd/awk/cou-006.out +++ /dev/null @@ -1,5 +0,0 @@ -($2 < $3) - -India 1267 746 Asia -Mexico 762 78 North America -France 211 55 Europe diff --git a/qse/cmd/awk/cou-007.out b/qse/cmd/awk/cou-007.out deleted file mode 100644 index 5b1f4af7..00000000 --- a/qse/cmd/awk/cou-007.out +++ /dev/null @@ -1,6 +0,0 @@ -/Asia/ - -USSR 8649 275 Asia -China 3705 1032 Asia -India 1267 746 Asia -Japan 144 120 Asia diff --git a/qse/cmd/awk/cou-008.out b/qse/cmd/awk/cou-008.out deleted file mode 100644 index d681dfc0..00000000 --- a/qse/cmd/awk/cou-008.out +++ /dev/null @@ -1,6 +0,0 @@ -($4 ~ /Asia/) - -USSR 8649 275 Asia -China 3705 1032 Asia -India 1267 746 Asia -Japan 144 120 Asia diff --git a/qse/cmd/awk/cou-009.out b/qse/cmd/awk/cou-009.out deleted file mode 100644 index df78739f..00000000 --- a/qse/cmd/awk/cou-009.out +++ /dev/null @@ -1,9 +0,0 @@ -($4 !~ /Asia/) - -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 diff --git a/qse/cmd/awk/cou-010.out b/qse/cmd/awk/cou-010.out deleted file mode 100644 index 6b66e924..00000000 --- a/qse/cmd/awk/cou-010.out +++ /dev/null @@ -1,6 +0,0 @@ -($0 ~ /Asia/) - -USSR 8649 275 Asia -China 3705 1032 Asia -India 1267 746 Asia -Japan 144 120 Asia diff --git a/qse/cmd/awk/cou-011.out b/qse/cmd/awk/cou-011.out deleted file mode 100644 index 1f009317..00000000 --- a/qse/cmd/awk/cou-011.out +++ /dev/null @@ -1,2 +0,0 @@ -($2 !~ /^[0-9]+$/) - diff --git a/qse/cmd/awk/cou-012.out b/qse/cmd/awk/cou-012.out deleted file mode 100644 index 636c837d..00000000 --- a/qse/cmd/awk/cou-012.out +++ /dev/null @@ -1,4 +0,0 @@ -(($4 == "Asia") && ($3 > 500)) - -China 3705 1032 Asia -India 1267 746 Asia diff --git a/qse/cmd/awk/cou-013.out b/qse/cmd/awk/cou-013.out deleted file mode 100644 index b0f594db..00000000 --- a/qse/cmd/awk/cou-013.out +++ /dev/null @@ -1,9 +0,0 @@ -(($4 == "Asia") || ($4 == "Europe")) - -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 diff --git a/qse/cmd/awk/cou-014.out b/qse/cmd/awk/cou-014.out deleted file mode 100644 index eae34bfa..00000000 --- a/qse/cmd/awk/cou-014.out +++ /dev/null @@ -1,9 +0,0 @@ -($4 ~ /^(Asia|Europe)$/) - -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 diff --git a/qse/cmd/awk/cou-015.out b/qse/cmd/awk/cou-015.out deleted file mode 100644 index 28616eda..00000000 --- a/qse/cmd/awk/cou-015.out +++ /dev/null @@ -1,9 +0,0 @@ -(/Asia/ || /Europe/) - -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 diff --git a/qse/cmd/awk/cou-016.out b/qse/cmd/awk/cou-016.out deleted file mode 100644 index 68a43190..00000000 --- a/qse/cmd/awk/cou-016.out +++ /dev/null @@ -1,9 +0,0 @@ -/Asia|Europe/ - -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 diff --git a/qse/cmd/awk/cou-017.out b/qse/cmd/awk/cou-017.out deleted file mode 100644 index 0beca645..00000000 --- a/qse/cmd/awk/cou-017.out +++ /dev/null @@ -1,5 +0,0 @@ -/Canada/,/USA/ - -Canada 3852 25 North America -China 3705 1032 Asia -USA 3615 237 North America diff --git a/qse/cmd/awk/cou-018.out b/qse/cmd/awk/cou-018.out deleted file mode 100644 index 77442148..00000000 --- a/qse/cmd/awk/cou-018.out +++ /dev/null @@ -1,2 +0,0 @@ -/Eurpoe/,/Africa/ - diff --git a/qse/cmd/awk/cou-019.out b/qse/cmd/awk/cou-019.out deleted file mode 100644 index 90fdcbc4..00000000 --- a/qse/cmd/awk/cou-019.out +++ /dev/null @@ -1,9 +0,0 @@ -(FNR == 1),(FNR == 5) { - print ((FILENAME ": ") $0); -} - -cou-en.data: USSR 8649 275 Asia -cou-en.data: Canada 3852 25 North America -cou-en.data: China 3705 1032 Asia -cou-en.data: USA 3615 237 North America -cou-en.data: Brazil 3286 134 South America diff --git a/qse/cmd/awk/cou-020.out b/qse/cmd/awk/cou-020.out deleted file mode 100644 index 12deeda3..00000000 --- a/qse/cmd/awk/cou-020.out +++ /dev/null @@ -1,9 +0,0 @@ -(FNR <= 5) { - print ((FILENAME ": ") $0); -} - -cou-en.data: USSR 8649 275 Asia -cou-en.data: Canada 3852 25 North America -cou-en.data: China 3705 1032 Asia -cou-en.data: USA 3615 237 North America -cou-en.data: Brazil 3286 134 South America diff --git a/qse/cmd/awk/cou-021.out b/qse/cmd/awk/cou-021.out deleted file mode 100644 index 7dfe4dad..00000000 --- a/qse/cmd/awk/cou-021.out +++ /dev/null @@ -1,8 +0,0 @@ -($4 == "Asia") { - print $1,(1000 * $2); -} - -USSR 8649000 -China 3705000 -India 1267000 -Japan 144000 diff --git a/qse/cmd/awk/cou-022.out b/qse/cmd/awk/cou-022.out deleted file mode 100644 index b415ed26..00000000 --- a/qse/cmd/awk/cou-022.out +++ /dev/null @@ -1,27 +0,0 @@ -BEGIN { - FS = OFS = " "; -} - -($4 == "North America") { - $4 = "NA"; -} - -($4 == "South America") { - $4 = "SA"; -} - -{ - print; -} - -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 diff --git a/qse/cmd/awk/cou-023.out b/qse/cmd/awk/cou-023.out deleted file mode 100644 index 853ae1e1..00000000 --- a/qse/cmd/awk/cou-023.out +++ /dev/null @@ -1,20 +0,0 @@ -BEGIN { - FS = OFS = " "; -} - -{ - $5 = ((1000 * $3) / $2); - print; -} - -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 diff --git a/qse/cmd/awk/cou-024.out b/qse/cmd/awk/cou-024.out deleted file mode 100644 index 98aae883..00000000 --- a/qse/cmd/awk/cou-024.out +++ /dev/null @@ -1,9 +0,0 @@ -($4 == "Asia") { - pop = (pop + $3); - n = (n + 1); -} - -END { - print "Total population of the",n,"Asian countries is",pop,"million."; -} -Total population of the 4 Asian countries is 2173 million. diff --git a/qse/cmd/awk/cou-025.out b/qse/cmd/awk/cou-025.out deleted file mode 100644 index 503ccd18..00000000 --- a/qse/cmd/awk/cou-025.out +++ /dev/null @@ -1,14 +0,0 @@ -/Asia/ { - pop["Asia"] += $3; -} - -/Europe/ { - pop["Europe"] += $3; -} - -END { - print "Asian population is",pop["Asia"],"million."; - print "European population is",pop["Europe"],"million."; -} -Asian population is 2173 million. -European population is 172 million. diff --git a/qse/cmd/awk/cou-026.out b/qse/cmd/awk/cou-026.out deleted file mode 100644 index 6d05a7e1..00000000 --- a/qse/cmd/awk/cou-026.out +++ /dev/null @@ -1,16 +0,0 @@ -BEGIN { - FS = " "; -} - -{ - pop[$4] += $3; -} - -END { - for (name in pop) - print name,pop[name]; -} -Europe 172 -South America 134 -North America 340 -Asia 2173 diff --git a/qse/cmd/awk/cou-027.out b/qse/cmd/awk/cou-027.out deleted file mode 100644 index a2242899..00000000 --- a/qse/cmd/awk/cou-027.out +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN { - FS = " "; -} - -{ - pop[$4] += $3; -} - -END { - for (c in pop) - printf ("%15s %6d\n",c,pop[c]) | "sort -t' ' -k2 -rn"; - close ("sort -t' ' -k2 -rn"); - sleep (1); -} - Asia 2173 - North America 340 - Europe 172 - South America 134 diff --git a/qse/cmd/awk/emp-001.out b/qse/cmd/awk/emp-001.out deleted file mode 100644 index 9d894bb6..00000000 --- a/qse/cmd/awk/emp-001.out +++ /dev/null @@ -1,8 +0,0 @@ -($3 > 0) { - print $1,($2 * $3); -} - -Kathy 40 -Mark 100 -Mary 121 -Susie 76.5 diff --git a/qse/cmd/awk/emp-002.out b/qse/cmd/awk/emp-002.out deleted file mode 100644 index 8f669f7e..00000000 --- a/qse/cmd/awk/emp-002.out +++ /dev/null @@ -1,6 +0,0 @@ -($3 == 0) { - print $1; -} - -Beth -Dan diff --git a/qse/cmd/awk/emp-003.out b/qse/cmd/awk/emp-003.out deleted file mode 100644 index 8c37c7e9..00000000 --- a/qse/cmd/awk/emp-003.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - print NF,$1,$NF; -} - -3 Beth 0 -3 Dan 0 -3 Kathy 10 -3 Mark 20 -3 Mary 22 -3 Susie 18 diff --git a/qse/cmd/awk/emp-004.out b/qse/cmd/awk/emp-004.out deleted file mode 100644 index 5bb7e8af..00000000 --- a/qse/cmd/awk/emp-004.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - print NR,$0; -} - -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 diff --git a/qse/cmd/awk/emp-005.out b/qse/cmd/awk/emp-005.out deleted file mode 100644 index fc0c9e81..00000000 --- a/qse/cmd/awk/emp-005.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - print "total pay for",$1,"is",($2 * $3); -} - -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 diff --git a/qse/cmd/awk/emp-006.out b/qse/cmd/awk/emp-006.out deleted file mode 100644 index 3ba88ebb..00000000 --- a/qse/cmd/awk/emp-006.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - printf ("total pay for %s is $%.2f\n",$1,($2 * $3)); -} - -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 diff --git a/qse/cmd/awk/emp-007.out b/qse/cmd/awk/emp-007.out deleted file mode 100644 index b0603f79..00000000 --- a/qse/cmd/awk/emp-007.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - printf ("%-8s $%6.2f\n",$1,($2 * $3)); -} - -Beth $ 0.00 -Dan $ 0.00 -Kathy $ 40.00 -Mark $100.00 -Mary $121.00 -Susie $ 76.50 diff --git a/qse/cmd/awk/emp-008.out b/qse/cmd/awk/emp-008.out deleted file mode 100644 index 019e78b7..00000000 --- a/qse/cmd/awk/emp-008.out +++ /dev/null @@ -1,4 +0,0 @@ -($2 >= 5) - -Mark 5.00 20 -Mary 5.50 22 diff --git a/qse/cmd/awk/emp-009.out b/qse/cmd/awk/emp-009.out deleted file mode 100644 index 76deb332..00000000 --- a/qse/cmd/awk/emp-009.out +++ /dev/null @@ -1,7 +0,0 @@ -(($2 * $3) > 50) { - printf ("$%.2f for %s\n",($2 * $3),$1); -} - -$100.00 for Mark -$121.00 for Mary -$76.50 for Susie diff --git a/qse/cmd/awk/emp-010.out b/qse/cmd/awk/emp-010.out deleted file mode 100644 index eaa876ae..00000000 --- a/qse/cmd/awk/emp-010.out +++ /dev/null @@ -1,3 +0,0 @@ -($1 == "Susie") - -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-011.out b/qse/cmd/awk/emp-011.out deleted file mode 100644 index c0d44782..00000000 --- a/qse/cmd/awk/emp-011.out +++ /dev/null @@ -1,3 +0,0 @@ -/Susie/ - -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-012.out b/qse/cmd/awk/emp-012.out deleted file mode 100644 index 73946169..00000000 --- a/qse/cmd/awk/emp-012.out +++ /dev/null @@ -1,7 +0,0 @@ -(($2 >= 4) || ($3 >= 20)) - -Beth 4.00 0 -Kathy 4.00 10 -Mark 5.00 20 -Mary 5.50 22 -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-013.out b/qse/cmd/awk/emp-013.out deleted file mode 100644 index 0b69688a..00000000 --- a/qse/cmd/awk/emp-013.out +++ /dev/null @@ -1,11 +0,0 @@ -($2 >= 4) - -($3 >= 20) - -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 diff --git a/qse/cmd/awk/emp-014.out b/qse/cmd/awk/emp-014.out deleted file mode 100644 index cde00a5a..00000000 --- a/qse/cmd/awk/emp-014.out +++ /dev/null @@ -1,7 +0,0 @@ -(!((($2 < 4) && ($3 < 20)))) - -Beth 4.00 0 -Kathy 4.00 10 -Mark 5.00 20 -Mary 5.50 22 -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-015.out b/qse/cmd/awk/emp-015.out deleted file mode 100644 index 3c696f7e..00000000 --- a/qse/cmd/awk/emp-015.out +++ /dev/null @@ -1,20 +0,0 @@ -(NF != 3) { - print $0,"number of fields is not equal to 3"; -} - -($2 < 3.35) { - print $0,"rate is below minimum wage"; -} - -($2 > 10) { - print $0,"rate exceeds $10 per hour"; -} - -($3 < 0) { - print $0,"negative hours worked"; -} - -($3 > 60) { - print $0,"too many hours worked"; -} - diff --git a/qse/cmd/awk/emp-016.out b/qse/cmd/awk/emp-016.out deleted file mode 100644 index 46f95c08..00000000 --- a/qse/cmd/awk/emp-016.out +++ /dev/null @@ -1,17 +0,0 @@ -BEGIN { - print "NAME RATE HOURS"; - print ""; -} - -{ - print; -} - -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 diff --git a/qse/cmd/awk/emp-017.out b/qse/cmd/awk/emp-017.out deleted file mode 100644 index e7e5ac24..00000000 --- a/qse/cmd/awk/emp-017.out +++ /dev/null @@ -1,8 +0,0 @@ -($3 > 15) { - emp = (emp + 1); -} - -END { - print emp,"employees worked more than 15 hours"; -} -3 employees worked more than 15 hours diff --git a/qse/cmd/awk/emp-018.out b/qse/cmd/awk/emp-018.out deleted file mode 100644 index fd8fa49f..00000000 --- a/qse/cmd/awk/emp-018.out +++ /dev/null @@ -1,4 +0,0 @@ -END { - print NR,"employees"; -} -6 employees diff --git a/qse/cmd/awk/emp-019.out b/qse/cmd/awk/emp-019.out deleted file mode 100644 index 3126ff30..00000000 --- a/qse/cmd/awk/emp-019.out +++ /dev/null @@ -1,12 +0,0 @@ -{ - pay = (pay + ($2 * $3)); -} - -END { - print NR,"employees"; - print "total pay is",pay; - print "average pay is",(pay / NR); -} -6 employees -total pay is 337.5 -average pay is 56.25 diff --git a/qse/cmd/awk/emp-020.out b/qse/cmd/awk/emp-020.out deleted file mode 100644 index 5f2a54f3..00000000 --- a/qse/cmd/awk/emp-020.out +++ /dev/null @@ -1,9 +0,0 @@ -($2 > maxrate) { - maxrate = $2; - maxemp = $1; -} - -END { - print "highest hourly rage:",maxrate,"for",maxemp; -} -highest hourly rage: 5.50 for Mary diff --git a/qse/cmd/awk/emp-021.out b/qse/cmd/awk/emp-021.out deleted file mode 100644 index 676a8bdc..00000000 --- a/qse/cmd/awk/emp-021.out +++ /dev/null @@ -1,8 +0,0 @@ -{ - names = ((names $1) " "); -} - -END { - print names; -} -Beth Dan Kathy Mark Mary Susie diff --git a/qse/cmd/awk/emp-022.out b/qse/cmd/awk/emp-022.out deleted file mode 100644 index 9e0bc46c..00000000 --- a/qse/cmd/awk/emp-022.out +++ /dev/null @@ -1,8 +0,0 @@ -{ - last = $0; -} - -END { - print last; -} -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-023.out b/qse/cmd/awk/emp-023.out deleted file mode 100644 index 0852ccaa..00000000 --- a/qse/cmd/awk/emp-023.out +++ /dev/null @@ -1,10 +0,0 @@ -{ - print $1,length ($1); -} - -Beth 4 -Dan 3 -Kathy 5 -Mark 4 -Mary 4 -Susie 5 diff --git a/qse/cmd/awk/emp-024.out b/qse/cmd/awk/emp-024.out deleted file mode 100644 index a1af1cfb..00000000 --- a/qse/cmd/awk/emp-024.out +++ /dev/null @@ -1,9 +0,0 @@ -{ - nc = ((nc + length ($0)) + 1); - nw = (nw + NF); -} - -END { - print NR,"lines,",nw,"words,",nc,"characters"; -} -6 lines, 18 words, 77 characters diff --git a/qse/cmd/awk/emp-025.out b/qse/cmd/awk/emp-025.out deleted file mode 100644 index 69b10629..00000000 --- a/qse/cmd/awk/emp-025.out +++ /dev/null @@ -1,12 +0,0 @@ -($2 > 6) { - n = (n + 1); - pay = (pay + ($2 * $3)); -} - -END { - if ((n > 0)) - print n,"employees, total pay is",pay,"average pay is",(pay / n); - else - print "no employees are paid more than $6/hour"; -} -no employees are paid more than $6/hour diff --git a/qse/cmd/awk/emp-026.out b/qse/cmd/awk/emp-026.out deleted file mode 100644 index 2ac7bf5a..00000000 --- a/qse/cmd/awk/emp-026.out +++ /dev/null @@ -1,18 +0,0 @@ -{ - line[NR] = $0; -} - -END { - i = NR; - while ((i > 0)) - { - print line[i]; - i = (i - 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 diff --git a/qse/cmd/awk/emp-027.out b/qse/cmd/awk/emp-027.out deleted file mode 100644 index a1601e46..00000000 --- a/qse/cmd/awk/emp-027.out +++ /dev/null @@ -1,15 +0,0 @@ -{ - line[NR] = $0; -} - -END { - i = NR; - for (i = NR; (i > 0); i = (i - 1)) - print line[i]; -} -Susie 4.25 18 -Mary 5.50 22 -Mark 5.00 20 -Kathy 4.00 10 -Dan 3.74 0 -Beth 4.00 0 diff --git a/qse/cmd/awk/emp-ko.data b/qse/cmd/awk/emp-ko.data deleted file mode 100644 index 54f11456..00000000 --- a/qse/cmd/awk/emp-ko.data +++ /dev/null @@ -1,6 +0,0 @@ -베쓰 4.00 0 -단 3.74 0 -케이티 4.00 10 -마크 5.00 20 -메리 5.50 22 -수지 4.25 18 diff --git a/qse/cmd/awk/manifest b/qse/cmd/awk/manifest deleted file mode 100644 index 1f820fc1..00000000 --- a/qse/cmd/awk/manifest +++ /dev/null @@ -1 +0,0 @@ -Main-Class: QseAwk diff --git a/qse/cmd/awk/mkjar.bat b/qse/cmd/awk/mkjar.bat deleted file mode 100644 index c204e6ac..00000000 --- a/qse/cmd/awk/mkjar.bat +++ /dev/null @@ -1,8 +0,0 @@ -cd ..\..\.. -move ase\cmd\awk\AwkApplet*.class . -jar cvf AwkApplet.jar *.class ase\cmd\awk\*.class ase\awk\*.class -move AwkApplet.jar ase\cmd\awk -cd ase\cmd\awk - -copy ..\..\awk\aseawk_jni.dll . -jarsigner -keystore ase.store AwkApplet.jar asecert diff --git a/qse/cmd/awk/wordfreq.awk b/qse/cmd/awk/wordfreq.awk deleted file mode 100644 index 4e922ab3..00000000 --- a/qse/cmd/awk/wordfreq.awk +++ /dev/null @@ -1,20 +0,0 @@ -# wordfreq.awk --- print list of word frequencies - -{ - $0 = tolower($0); # remove case distinctions - - # remove punctuation - a=0; - gsub(/[^[:alnum:]_[:blank:]]/, " ", $a); - #gsub(/[^[:alnum:]_[:blank:]]/, " "); - - for (i = 1; i <= NF; i++) freq[$i]++; -} -#/[^kkka-bcx-dd-y]|abc|def/ - -END { - for (word in freq) - print word, freq[word]; -} - - diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index b4c7aa3b..c6d2b663 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.hpp 212 2009-06-25 07:39:27Z hyunghwan.chung $ + * $Id: Awk.hpp 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -509,8 +509,8 @@ public: ERR_FNCUSER = QSE_AWK_EFNCUSER, ERR_FNCIMPL = QSE_AWK_EFNCIMPL, ERR_IOUSER = QSE_AWK_EIOUSER, - ERR_IONONE = QSE_AWK_EIONONE, ERR_IOIMPL = QSE_AWK_EIOIMPL, + ERR_IONMNF = QSE_AWK_EIONMNF, ERR_IONMEM = QSE_AWK_EIONMEM, ERR_IONMNL = QSE_AWK_EIONMNL, ERR_FMTARG = QSE_AWK_EFMTARG, diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index bdb0b734..b972fb13 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h 212 2009-06-25 07:39:27Z hyunghwan.chung $ + * $Id: awk.h 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -655,8 +655,8 @@ enum qse_awk_errnum_t QSE_AWK_EFNCUSER, /* wrong intrinsic function implementation */ QSE_AWK_EFNCIMPL, /* intrinsic function handler failed */ QSE_AWK_EIOUSER, /* wrong user io handler implementation */ - QSE_AWK_EIONONE, /* no such io name found */ QSE_AWK_EIOIMPL, /* i/o callback returned an error */ + QSE_AWK_EIONMNF, /* no such io name found */ QSE_AWK_EIONMEM, /* i/o name empty */ QSE_AWK_EIONMNL, /* i/o name contains '\0' */ QSE_AWK_EFMTARG, /* arguments to format string not sufficient */ diff --git a/qse/lib/awk/err.c b/qse/lib/awk/err.c index 8845e6e7..2bbbfdb6 100644 --- a/qse/lib/awk/err.c +++ b/qse/lib/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c 212 2009-06-25 07:39:27Z hyunghwan.chung $ + * $Id: err.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -39,7 +39,7 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum) QSE_T("file or data too big"), QSE_T("system too busy"), QSE_T("is a directory"), - QSE_T("i/o error"), + QSE_T("IO error"), QSE_T("cannot open '${0}'"), QSE_T("cannot read '${0}'"), @@ -143,10 +143,10 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum) QSE_T("wrong implementation of intrinsic function handler"), QSE_T("intrinsic function handler returned an error"), QSE_T("wrong implementation of user-defined io handler"), - QSE_T("no such io name found"), - QSE_T("i/o handler returned an error"), - QSE_T("i/o name empty"), - QSE_T("i/o name '${0}' containing a null character"), + QSE_T("IO handler returned an error"), + QSE_T("no such IO name found"), + QSE_T("IO name empty"), + QSE_T("IO name '${0}' containing a null character"), QSE_T("not sufficient arguments to formatting sequence"), QSE_T("recursion detected in format conversion"), QSE_T("invalid character in CONVFMT"), diff --git a/qse/lib/awk/fnc.c b/qse/lib/awk/fnc.c index f498316a..2f1317f3 100644 --- a/qse/lib/awk/fnc.c +++ b/qse/lib/awk/fnc.c @@ -1,5 +1,5 @@ /* - * $Id: fnc.c 211 2009-06-24 09:50:10Z hyunghwan.chung $ + * $Id: fnc.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -282,7 +282,7 @@ static int fnc_close ( n = qse_awk_rtx_closeio (run, name); /* - if (n == -1 && run->errinf.num != QSE_AWK_EIONONE) + if (n == -1 && run->errinf.num != QSE_AWK_EIONMNF) { if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, name); @@ -316,13 +316,13 @@ static int flush_io ( { /* if (run->errinf.num == QSE_AWK_EIOIMPL) n = -1; - else if (run->errinf.num == QSE_AWK_EIONONE) + else if (run->errinf.num == QSE_AWK_EIONMNF) { if (n != 0) n = -2; } else n = -99; */ - if (run->errinf.num == QSE_AWK_EIONONE) + if (run->errinf.num == QSE_AWK_EIONMNF) { if (n != 0) n = -2; } diff --git a/qse/lib/awk/parse.c b/qse/lib/awk/parse.c index 8a7d811d..aa232a1d 100644 --- a/qse/lib/awk/parse.c +++ b/qse/lib/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c 212 2009-06-25 07:39:27Z hyunghwan.chung $ + * $Id: parse.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -3039,11 +3039,15 @@ static qse_awk_nde_t* parse_primary (qse_awk_t* awk, qse_size_t line) { qse_awk_nde_t* tmp; - if (get_token(awk) <= -1) + do { - qse_awk_clrpt (awk, nde); - return QSE_NULL; - } + if (get_token(awk) <= -1) + { + qse_awk_clrpt (awk, nde); + return QSE_NULL; + } + } + while (MATCH(awk,TOKEN_NEWLINE)); tmp = parse_expression (awk, awk->token.line); if (tmp == QSE_NULL) @@ -4635,7 +4639,8 @@ static int get_token (qse_awk_t* awk) } else if (c == QSE_T('\n')) { - ADD_TOKEN_CHAR (awk, QSE_T('\n')); + /*ADD_TOKEN_CHAR (awk, QSE_T('\n'));*/ + ADD_TOKEN_STR (awk, QSE_T(""), 4); SET_TOKEN_TYPE (awk, TOKEN_NEWLINE); GET_CHAR (awk); } diff --git a/qse/lib/awk/rio.c b/qse/lib/awk/rio.c index 984e609d..4a5f5910 100644 --- a/qse/lib/awk/rio.c +++ b/qse/lib/awk/rio.c @@ -1,5 +1,5 @@ /* - * $Id: rio.c 207 2009-06-22 13:01:28Z hyunghwan.chung $ + * $Id: rio.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -634,7 +634,7 @@ int qse_awk_rtx_flushio ( if (ok) return 0; /* there is no corresponding rio for name */ - qse_awk_rtx_seterrnum (run, QSE_AWK_EIONONE); + qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF); return -1; } @@ -844,7 +844,7 @@ int qse_awk_rtx_closio_read ( } /* the name given is not found */ - qse_awk_rtx_seterrnum (run, QSE_AWK_EIONONE); + qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF); return -1; } @@ -903,7 +903,7 @@ int qse_awk_rtx_closio_write ( p = p->next; } - qse_awk_rtx_seterrnum (run, QSE_AWK_EIONONE); + qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF); return -1; } @@ -945,7 +945,7 @@ int qse_awk_rtx_closeio (qse_awk_rtx_t* run, const qse_char_t* name) p = p->next; } - qse_awk_rtx_seterrnum (run, QSE_AWK_EIONONE); + qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF); return -1; } diff --git a/qse/lib/awk/run.c b/qse/lib/awk/run.c index d8cdef9c..2c0b761f 100644 --- a/qse/lib/awk/run.c +++ b/qse/lib/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c 210 2009-06-24 08:29:33Z hyunghwan.chung $ + * $Id: run.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -2934,6 +2934,9 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde) return -1; } + /* unlike printf, flushio() is not needed here as print + * inserts that triggers auto-flush */ + if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out); /*skip_write:*/ @@ -3069,10 +3072,13 @@ static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde) } qse_awk_rtx_refdownval (run, v); - if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out); /*skip_write:*/ - return qse_awk_rtx_flushio (run, nde->out_type, dst); + n = qse_awk_rtx_flushio (run, nde->out_type, dst); + + if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out); + + return n; } static int output_formatted ( @@ -4045,7 +4051,7 @@ static int __cmp_int_str ( qse_awk_rtx_valtostr_out_t out; int n; - if (rtx->awk->option & QSE_AWK_NCMPONSTR) + if (rtx->awk->option & QSE_AWK_NCMPONSTR || right->nstr > 0) { qse_long_t ll; qse_real_t rr; @@ -4131,7 +4137,7 @@ static int __cmp_real_str ( qse_awk_rtx_valtostr_out_t out; int n; - if (rtx->awk->option & QSE_AWK_NCMPONSTR) + if (rtx->awk->option & QSE_AWK_NCMPONSTR || right->nstr > 0) { const qse_char_t* end; qse_real_t rr; diff --git a/qse/regress/awk/asm.d1 b/qse/regress/awk/asm.d1 deleted file mode 100644 index d1f4e3ab..00000000 --- a/qse/regress/awk/asm.d1 +++ /dev/null @@ -1,14 +0,0 @@ - ld zero # initialize sum to zero - st sum -loop get # read a number - jz done # no more input if number is zero - add sum # add in accumulated sum - st sum # store new value back in sum - j loop # go back and read another number - -done ld sum # print sum - put - halt - -zero const 0 -sum const diff --git a/qse/regress/awk/asm.d2 b/qse/regress/awk/asm.dat similarity index 100% rename from qse/regress/awk/asm.d2 rename to qse/regress/awk/asm.dat diff --git a/qse/cmd/awk/asm.s b/qse/regress/awk/asm.s similarity index 100% rename from qse/cmd/awk/asm.s rename to qse/regress/awk/asm.s diff --git a/qse/cmd/awk/cou-001.awk b/qse/regress/awk/cou-001.awk similarity index 100% rename from qse/cmd/awk/cou-001.awk rename to qse/regress/awk/cou-001.awk diff --git a/qse/cmd/awk/cou-002.awk b/qse/regress/awk/cou-002.awk similarity index 85% rename from qse/cmd/awk/cou-002.awk rename to qse/regress/awk/cou-002.awk index dbe8c549..84a8ae72 100644 --- a/qse/cmd/awk/cou-002.awk +++ b/qse/regress/awk/cou-002.awk @@ -1,6 +1,6 @@ BEGIN { FS = "\t"; - printf ("%10s %6s %5s %s\n\n", + printf ("%10s %6s %5s %s\n\n", "COUNTRY", "AREA", "POP", "CONTINENT"); } diff --git a/qse/cmd/awk/cou-003.awk b/qse/regress/awk/cou-003.awk similarity index 100% rename from qse/cmd/awk/cou-003.awk rename to qse/regress/awk/cou-003.awk diff --git a/qse/cmd/awk/cou-004.awk b/qse/regress/awk/cou-004.awk similarity index 100% rename from qse/cmd/awk/cou-004.awk rename to qse/regress/awk/cou-004.awk diff --git a/qse/cmd/awk/cou-005.awk b/qse/regress/awk/cou-005.awk similarity index 100% rename from qse/cmd/awk/cou-005.awk rename to qse/regress/awk/cou-005.awk diff --git a/qse/cmd/awk/cou-006.awk b/qse/regress/awk/cou-006.awk similarity index 100% rename from qse/cmd/awk/cou-006.awk rename to qse/regress/awk/cou-006.awk diff --git a/qse/cmd/awk/cou-007.awk b/qse/regress/awk/cou-007.awk similarity index 100% rename from qse/cmd/awk/cou-007.awk rename to qse/regress/awk/cou-007.awk diff --git a/qse/cmd/awk/cou-008.awk b/qse/regress/awk/cou-008.awk similarity index 100% rename from qse/cmd/awk/cou-008.awk rename to qse/regress/awk/cou-008.awk diff --git a/qse/cmd/awk/cou-009.awk b/qse/regress/awk/cou-009.awk similarity index 100% rename from qse/cmd/awk/cou-009.awk rename to qse/regress/awk/cou-009.awk diff --git a/qse/cmd/awk/cou-010.awk b/qse/regress/awk/cou-010.awk similarity index 100% rename from qse/cmd/awk/cou-010.awk rename to qse/regress/awk/cou-010.awk diff --git a/qse/cmd/awk/cou-011.awk b/qse/regress/awk/cou-011.awk similarity index 100% rename from qse/cmd/awk/cou-011.awk rename to qse/regress/awk/cou-011.awk diff --git a/qse/cmd/awk/cou-012.awk b/qse/regress/awk/cou-012.awk similarity index 100% rename from qse/cmd/awk/cou-012.awk rename to qse/regress/awk/cou-012.awk diff --git a/qse/cmd/awk/cou-013.awk b/qse/regress/awk/cou-013.awk similarity index 100% rename from qse/cmd/awk/cou-013.awk rename to qse/regress/awk/cou-013.awk diff --git a/qse/cmd/awk/cou-014.awk b/qse/regress/awk/cou-014.awk similarity index 100% rename from qse/cmd/awk/cou-014.awk rename to qse/regress/awk/cou-014.awk diff --git a/qse/cmd/awk/cou-015.awk b/qse/regress/awk/cou-015.awk similarity index 100% rename from qse/cmd/awk/cou-015.awk rename to qse/regress/awk/cou-015.awk diff --git a/qse/cmd/awk/cou-016.awk b/qse/regress/awk/cou-016.awk similarity index 100% rename from qse/cmd/awk/cou-016.awk rename to qse/regress/awk/cou-016.awk diff --git a/qse/cmd/awk/cou-017.awk b/qse/regress/awk/cou-017.awk similarity index 100% rename from qse/cmd/awk/cou-017.awk rename to qse/regress/awk/cou-017.awk diff --git a/qse/cmd/awk/cou-018.awk b/qse/regress/awk/cou-018.awk similarity index 100% rename from qse/cmd/awk/cou-018.awk rename to qse/regress/awk/cou-018.awk diff --git a/qse/cmd/awk/cou-019.awk b/qse/regress/awk/cou-019.awk similarity index 100% rename from qse/cmd/awk/cou-019.awk rename to qse/regress/awk/cou-019.awk diff --git a/qse/cmd/awk/cou-020.awk b/qse/regress/awk/cou-020.awk similarity index 100% rename from qse/cmd/awk/cou-020.awk rename to qse/regress/awk/cou-020.awk diff --git a/qse/cmd/awk/cou-021.awk b/qse/regress/awk/cou-021.awk similarity index 100% rename from qse/cmd/awk/cou-021.awk rename to qse/regress/awk/cou-021.awk diff --git a/qse/cmd/awk/cou-022.awk b/qse/regress/awk/cou-022.awk similarity index 100% rename from qse/cmd/awk/cou-022.awk rename to qse/regress/awk/cou-022.awk diff --git a/qse/cmd/awk/cou-023.awk b/qse/regress/awk/cou-023.awk similarity index 100% rename from qse/cmd/awk/cou-023.awk rename to qse/regress/awk/cou-023.awk diff --git a/qse/cmd/awk/cou-024.awk b/qse/regress/awk/cou-024.awk similarity index 100% rename from qse/cmd/awk/cou-024.awk rename to qse/regress/awk/cou-024.awk diff --git a/qse/cmd/awk/cou-025.awk b/qse/regress/awk/cou-025.awk similarity index 100% rename from qse/cmd/awk/cou-025.awk rename to qse/regress/awk/cou-025.awk diff --git a/qse/cmd/awk/cou-026.awk b/qse/regress/awk/cou-026.awk similarity index 100% rename from qse/cmd/awk/cou-026.awk rename to qse/regress/awk/cou-026.awk diff --git a/qse/cmd/awk/cou-027.awk b/qse/regress/awk/cou-027.awk similarity index 100% rename from qse/cmd/awk/cou-027.awk rename to qse/regress/awk/cou-027.awk diff --git a/qse/cmd/awk/cou-en.data b/qse/regress/awk/cou.dat similarity index 100% rename from qse/cmd/awk/cou-en.data rename to qse/regress/awk/cou.dat diff --git a/qse/regress/awk/emp.d b/qse/regress/awk/emp.d deleted file mode 100644 index 029863ff..00000000 --- a/qse/regress/awk/emp.d +++ /dev/null @@ -1,6 +0,0 @@ -Beth 4.00 0 -Dan 3.74 0 -Kathy 4.00 10 -Mark 5.00 20 -Mary 5.50 22 -Susie 4.25 18 diff --git a/qse/cmd/awk/emp-en.data b/qse/regress/awk/emp.dat similarity index 100% rename from qse/cmd/awk/emp-en.data rename to qse/regress/awk/emp.dat diff --git a/qse/regress/awk/indent.awk b/qse/regress/awk/indent.awk new file mode 100644 index 00000000..85c22823 --- /dev/null +++ b/qse/regress/awk/indent.awk @@ -0,0 +1,56 @@ +#.H1 indent.awk +#.H2 Synopsis +#.P gawk -f indent.awk file.sh +#.H2 Download +#.P Download from LAWKER +#.h2 Description +#.P +# This is part of Phil's AWK tutorial at +#http://www.bolthole.com/AWK.html. +# This program adjusts the indentation level based on which keywords are +# found in each line it encounters. +#.h2 Code +#.H3 doindent +#.PRE +function doindent(){ + tmpindent=indent; + if(indent<0){ + print "ERROR; indent level == " indent + } + while(tmpindent >0){ + printf(" "); + tmpindent-=1; + } +} +#./PRE +#.H3 Out-denting +#.PRE +$1 == "done" { indent -=1; } +$1 == "fi" { indent -=1; } +$0 ~ /^}$/ { if(indent!=0) indent-=1; } +#./PRE +#.H3 Worker +#.P +# This is the 'default' action, that actually prints a line out. +# This gets called AS WELL AS any other matching clause, in the +# order they appear in this program. +# An "if" match is run AFTER we run this clause. +# A "done" match is run BEFORE we run this clause. +#.PRE + { + doindent(); + print $0; + } +#./PRE +#.H3 In-denting +#.PRE +$0 ~ /if.*;[ ]*then/ { indent+=1; } +$0 ~ /for.*;[ ]*do/ { indent+=1; } +$0 ~ /while.*;[ ]*do/ { indent+=1; } + +$1 == "then" { indent+=1; } +$1 == "do" { indent+=1; } +$0 ~ /^{$/ { indent+=1; } +#./PRE +#.H2 Author +#.P Philip Brown phil@bolthole.com diff --git a/qse/regress/awk/quicksort.d b/qse/regress/awk/quicksort.dat similarity index 100% rename from qse/regress/awk/quicksort.d rename to qse/regress/awk/quicksort.dat diff --git a/qse/regress/awk/quicksort2.d b/qse/regress/awk/quicksort2.dat similarity index 100% rename from qse/regress/awk/quicksort2.d rename to qse/regress/awk/quicksort2.dat diff --git a/qse/regress/awk/regress.sh b/qse/regress/awk/regress.sh index 9864bcc1..2f9e3c2b 100755 --- a/qse/regress/awk/regress.sh +++ b/qse/regress/awk/regress.sh @@ -22,45 +22,76 @@ print_usage() # MAIN # ################### -QSEAWK="../../cmd/awk/qseawk" -PROGS=" - emp-001.awk/emp.d// - emp-002.awk/emp.d// - emp-003.awk/emp.d// - emp-004.awk/emp.d// - emp-005.awk/emp.d// - emp-006.awk/emp.d// - emp-007.awk/emp.d// - emp-008.awk/emp.d// - emp-009.awk/emp.d// - emp-010.awk/emp.d// - emp-011.awk/emp.d// - emp-012.awk/emp.d// - emp-013.awk/emp.d// - emp-014.awk/emp.d// - emp-015.awk/emp.d// - emp-016.awk/emp.d// - emp-017.awk/emp.d// - emp-018.awk/emp.d// - emp-019.awk/emp.d// - emp-020.awk/emp.d// - emp-021.awk/emp.d// - emp-022.awk/emp.d// - emp-023.awk/emp.d// - emp-024.awk/emp.d// - emp-025.awk/emp.d// - emp-026.awk/emp.d// - emp-027.awk/emp.d// +QSEAWK=${QSEAWK:=../../cmd/awk/qseawk} - quicksort.awk/quicksort.d// - quicksort2.awk/quicksort2.d// - asm.awk/asm.d1/asm.d2/ - stripcomment.awk/stripcomment.d// +PROGS=" + cou-001.awk/cou.dat// + cou-002.awk/cou.dat// + cou-003.awk/cou.dat// + cou-004.awk/cou.dat// + cou-005.awk/cou.dat// + cou-006.awk/cou.dat// + cou-007.awk/cou.dat// + cou-008.awk/cou.dat// + cou-009.awk/cou.dat// + cou-010.awk/cou.dat// + cou-011.awk/cou.dat// + cou-012.awk/cou.dat// + cou-013.awk/cou.dat// + cou-014.awk/cou.dat// + cou-015.awk/cou.dat// + cou-016.awk/cou.dat// + cou-017.awk/cou.dat// + cou-018.awk/cou.dat// + cou-019.awk/cou.dat// + cou-020.awk/cou.dat// + cou-021.awk/cou.dat// + cou-022.awk/cou.dat// + cou-023.awk/cou.dat// + cou-024.awk/cou.dat// + cou-025.awk/cou.dat// + cou-026.awk/cou.dat// + cou-027.awk/cou.dat// + + emp-001.awk/emp.dat// + emp-002.awk/emp.dat// + emp-003.awk/emp.dat// + emp-004.awk/emp.dat// + emp-005.awk/emp.dat// + emp-006.awk/emp.dat// + emp-007.awk/emp.dat// + emp-008.awk/emp.dat// + emp-009.awk/emp.dat// + emp-010.awk/emp.dat// + emp-011.awk/emp.dat// + emp-012.awk/emp.dat// + emp-013.awk/emp.dat// + emp-014.awk/emp.dat// + emp-015.awk/emp.dat// + emp-016.awk/emp.dat// + emp-017.awk/emp.dat// + emp-018.awk/emp.dat// + emp-019.awk/emp.dat// + emp-020.awk/emp.dat// + emp-021.awk/emp.dat// + emp-022.awk/emp.dat// + emp-023.awk/emp.dat// + emp-024.awk/emp.dat// + emp-025.awk/emp.dat// + emp-026.awk/emp.dat// + emp-027.awk/emp.dat// + + quicksort.awk/quicksort.dat// + quicksort2.awk/quicksort2.dat// + asm.awk/asm.s/asm.dat/ + stripcomment.awk/stripcomment.dat// wordfreq.awk/wordfreq.awk// hanoi.awk// + indent.awk/regress.sh/ " -[ -x "${QSEAWK}" ] || { +[ -x "${QSEAWK}" ] || +{ echo "ERROR: ${QSEAWK} not found" exit 1; } @@ -72,7 +103,7 @@ do redinfile="`echo ${prog} | cut -d/ -f3`" awkopts="`echo ${prog} | cut -d/ -f4`" - if [ -n "${redinfile}" ] + if [ -n "${redinfile}" ] then echo_so "${QSEAWK} ${awkopts} -f ${script} ${datafile} < ${redinfile}" ${QSEAWK} ${awkopts} -f ${script} ${datafile} < ${redinfile} diff --git a/qse/regress/awk/stripcomment.d b/qse/regress/awk/stripcomment.dat similarity index 100% rename from qse/regress/awk/stripcomment.d rename to qse/regress/awk/stripcomment.dat diff --git a/qse/regress/awk/wordfreq.awk b/qse/regress/awk/wordfreq.awk index 4e922ab3..ce38bfcb 100644 --- a/qse/regress/awk/wordfreq.awk +++ b/qse/regress/awk/wordfreq.awk @@ -16,5 +16,3 @@ END { for (word in freq) print word, freq[word]; } - -