aboutsummaryrefslogtreecommitdiffstats
path: root/test/arraysort2.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-07-31 09:07:29 +0300
committerArnold D. Robbins <arnold@skeeve.com>2018-07-31 09:07:29 +0300
commitf856979d85ace61bfeb2d31146485ec668202ad8 (patch)
tree754f2101557d620a56b66e23209909f790b0cb09 /test/arraysort2.awk
parent4703b75c618070d88f9e2eff084ca8119980bd9c (diff)
downloadegawk-f856979d85ace61bfeb2d31146485ec668202ad8.tar.gz
egawk-f856979d85ace61bfeb2d31146485ec668202ad8.tar.bz2
egawk-f856979d85ace61bfeb2d31146485ec668202ad8.zip
Fix coredump from IGNORECASE array sorting.
Diffstat (limited to 'test/arraysort2.awk')
-rw-r--r--test/arraysort2.awk34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/arraysort2.awk b/test/arraysort2.awk
new file mode 100644
index 00000000..e52d2a7c
--- /dev/null
+++ b/test/arraysort2.awk
@@ -0,0 +1,34 @@
+# This should no longer core dump ... 7/31/2018
+function init(b, a, i)
+{
+ a[1] = "aardvark"
+ a[2] = "animal"
+ a[3] = "zebra"
+ a[4] = "zoo"
+ a[5] = "Iguana"
+ a[6] = "Alligator"
+ a[7] =a[8] = "people"
+ for (i in a)
+ b[IGNORECASE][i] = a[i]
+}
+
+BEGIN {
+
+ for (IGNORECASE = 0; IGNORECASE < 2; IGNORECASE++) {
+ init(b)
+
+ n = asort(b[IGNORECASE])
+
+ for (i = 1; i <= n; i++)
+ printf("b[%d][%d] = \"%s\"\n", IGNORECASE, i, b[IGi])
+
+ print "===="
+ }
+
+ IGNORECASE = 1
+ init(b)
+ b[2][1] = ""
+ n = asort(b[1], b[2])
+ for (i = 1; i <= n; i++)
+ printf("b[2][%d] = \"%s\"\n", i, b[2][i])
+}