diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-24 21:07:22 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-24 21:07:22 +0300 |
commit | 37cd3566b9b74c43d5f11f1cba8dec147a25e474 (patch) | |
tree | 86bc4f722b6fd17c5dcf183f1a82ca20e2786454 /extension/rwarray.awk | |
parent | 115d332143b1a9d23bbf57088a577e778dcf31f8 (diff) | |
download | egawk-37cd3566b9b74c43d5f11f1cba8dec147a25e474.tar.gz egawk-37cd3566b9b74c43d5f11f1cba8dec147a25e474.tar.bz2 egawk-37cd3566b9b74c43d5f11f1cba8dec147a25e474.zip |
Get rwarray extension working with new API.
Diffstat (limited to 'extension/rwarray.awk')
-rw-r--r-- | extension/rwarray.awk | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/extension/rwarray.awk b/extension/rwarray.awk index 1057b396..b34a42a7 100644 --- a/extension/rwarray.awk +++ b/extension/rwarray.awk @@ -1,19 +1,24 @@ -BEGIN { - extension("./rwarray.so","dlload") +@load "rwarray" +BEGIN { while ((getline word < "/usr/share/dict/words") > 0) dict[word] = word word - for (i in dict) - printf("dict[%s] = %s\n", i, dict[i]) > "orig.out" + n = asorti(dict, dictindices) + for (i = 1; i <= n; i++) + printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "orig.out" close("orig.out"); - writea("orig.bin", dict) + ret = writea("orig.bin", dict) + printf "writea() returned %d, expecting 1\n", ret - reada("orig.bin", dict) + + ret = reada("orig.bin", dict) + printf "reada() returned %d, expecting 1\n", ret - for (i in dict) - printf("dict[%s] = %s\n", i, dict[i]) > "new.out" + n = asorti(dict, dictindices) + for (i = 1; i <= n; i++) + printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "new.out" close("new.out"); ret = system("cmp orig.out new.out") @@ -23,6 +28,6 @@ BEGIN { else print "old and new are not equal - BAD" - if (ret == 0 && !("keepit" in ENVIRON)) - system("rm orig.bin orig.out new.out") + if (ret == 0 && !("KEEPIT" in ENVIRON)) + system("rm -f orig.bin orig.out new.out") } |