From f856979d85ace61bfeb2d31146485ec668202ad8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Jul 2018 09:07:29 +0300 Subject: Fix coredump from IGNORECASE array sorting. --- test/arraysort2.awk | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/arraysort2.awk (limited to 'test/arraysort2.awk') 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]) +} -- cgit v1.2.3