From 8d10337bf0d61049ee0f3b0a7f4d87153b18db96 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 4 May 2013 19:30:37 +0000 Subject: (svn r25218) -Fix: the baseset description translation script did not work with any awk other than gawk --- media/baseset/translations.awk | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'media') diff --git a/media/baseset/translations.awk b/media/baseset/translations.awk index 3269d40b7..f15cb43ff 100644 --- a/media/baseset/translations.awk +++ b/media/baseset/translations.awk @@ -18,6 +18,26 @@ # . = # +# Simple insertion sort since not all AWKs have a sort implementation +function isort(A) { + n = 0 + for (val in A) { + n++; + } + + for (i = 2; i <= n; i++) { + j = i; + hold = A[j] + while (A[j - 1] > hold) { + j--; + A[j + 1] = A[j] + } + A[j] = hold + } + + return n +} + /^!!/ { ini_key = $2; str_id = $3; @@ -28,16 +48,17 @@ lang = $2; } else if (match($0, "^" str_id " *:") > 0) { sub("^[^:]*:", "", $0) + i++; if (lang == "en_GB") { - texts[""] = ini_key " = "$0; + texts[i] = ini_key " = "$0; } else { - texts[lang] = ini_key "." lang " = "$0; + texts[i] = ini_key "." lang " = "$0; } } } close(file); - count = asort(texts); + count = isort(texts); for (i = 1; i <= count; i++) { print texts[i] } -- cgit v1.2.3-70-g09d2