[Libreoffice-commits] core.git: i18npool/source

Eike Rathke erack at redhat.com
Thu Apr 27 21:37:18 UTC 2017


 i18npool/source/localedata/data/sort-formats-by-formatindex.awk |   82 ++++++++++
 1 file changed, 82 insertions(+)

New commits:
commit fcd0ee644de8e96a350e5d37030875df651dfdc9
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Apr 27 23:33:06 2017 +0200

    Sort FormatElement and their children by formatindex value
    
    Change-Id: Ifa5b4a74de864b2eea982a166f90095344f812ea

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:


More information about the Libreoffice-commits mailing list