summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-04-27 23:33:06 +0200
committerEike Rathke <erack@redhat.com>2017-04-27 23:36:29 +0200
commitfcd0ee644de8e96a350e5d37030875df651dfdc9 (patch)
tree55e28c4b117d044ecebe828774f7c66e0bad09bc /i18npool
parent4b605466a2304efd2b247595fe74ddf7c6d5a77d (diff)
Sort FormatElement and their children by formatindex value
Change-Id: Ifa5b4a74de864b2eea982a166f90095344f812ea
Diffstat (limited to 'i18npool')
-rwxr-xr-xi18npool/source/localedata/data/sort-formats-by-formatindex.awk82
1 files changed, 82 insertions, 0 deletions
diff --git a/i18npool/source/localedata/data/sort-formats-by-formatindex.awk b/i18npool/source/localedata/data/sort-formats-by-formatindex.awk
new file mode 100755
index 000000000000..ffd84e4d517e
--- /dev/null
+++ b/i18npool/source/localedata/data/sort-formats-by-formatindex.awk
@@ -0,0 +1,82 @@
+#!/usr/bin/gawk -f
+# -*- Mode: awk; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Usage: gawk -f sort-formats-by-formatindex.awk ll_CC.xml
+#
+# Sort the LC_FORMAT child elements FormatElement and their children by
+# formatindex="..." value for easier comparison between locales.
+# Output goes to stdout.
+
+BEGIN {
+ file = ""
+}
+
+file != FILENAME {
+ file = FILENAME
+ informats = 0
+ currformat = 0
+ delete formats
+}
+
+/<LC_FORMAT[ >]/ {
+ if (!/\/>/)
+ informats = 1
+ print
+ next
+}
+
+informats && /<\/LC_FORMAT>/ {
+ PROCINFO["sorted_in"] = "@ind_num_asc"
+ for (f in formats)
+ {
+ if (isarray(formats[f]))
+ {
+ for (i in formats[f])
+ print formats[f][i]
+ }
+ else
+ {
+ # Something unhandled, adapt code.
+ print "XXX error: " formats[f]
+ }
+ }
+ informats = 0
+}
+
+{
+ if (!informats)
+ {
+ print
+ next
+ }
+}
+
+/<FormatElement / {
+ split( $0, a, /formatindex="/)
+ split( a[2], b, /"/)
+ currformat = b[1]
+ child = 0 # 1-based
+ formats[currformat][++child] = $0
+ next
+}
+
+/<DateAcceptancePattern[ >]/ {
+ print
+ next
+}
+
+# Associate any element or comment with the current FormatElement.
+{
+ formats[currformat][++child] = $0
+}
+
+END {
+}
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: