X-Git-Url: http://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/95d8e7745d9b00097d50d9903d62c48268324e7a..da99716d86d4870be554d8412b41a751583da661:/scripts/gen-tree.awk diff --git a/scripts/gen-tree.awk b/scripts/gen-tree.awk index 55a7d5c..413f156 100755 --- a/scripts/gen-tree.awk +++ b/scripts/gen-tree.awk @@ -250,25 +250,28 @@ function format_items(s, i) # placing them into dst[0] ... dst[n]. # # Returns the number of elements. -function bucketsort(dst, src, buckets, max, count, i, t) +function bucketsort(dst, src, max, count, i, t) { + # Note: ULTRIX 4.5 nawk does not support local array parameters + split("", bucketsort_buckets); + for (t in src) { i = length(src[t]) if (i > max) { max = i } - buckets[i]++ + bucketsort_buckets[i]++ } for (i = max; i > 0; i--) { - if (i in buckets) { - t = buckets[i] - buckets[i] = count + if (i in bucketsort_buckets) { + t = bucketsort_buckets[i] + bucketsort_buckets[i] = count count += t } } for (t in src) { i = length(t = src[t]) - dst[buckets[i]++] = t + dst[bucketsort_buckets[i]++] = t } return count