]> git.draconx.ca Git - dxcommon.git/blobdiff - scripts/gen-strtab.awk
Avoid local array parameters in awk scripts.
[dxcommon.git] / scripts / gen-strtab.awk
index c5b02c6d3840fef82f2bbaa7a9353312b986c95c..6ec06be8b526c469c2f094babf6fb0bee2867b3c 100755 (executable)
@@ -246,25 +246,28 @@ function real_length(s, t)
 # 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