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

Eike Rathke erack at redhat.com
Fri Apr 28 09:26:41 UTC 2017


 i18npool/source/localedata/data/sort-formats-by-formatindex.awk |   82 ------
 i18npool/source/localedata/data/sort-formats.awk                |  132 ++++++++++
 2 files changed, 132 insertions(+), 82 deletions(-)

New commits:
commit 72947e82fef1800d50e6d317fbfd7be05aaebf6b
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Apr 28 11:23:55 2017 +0200

    Add group option, group by usage attribute
    
    Change-Id: Ib20d6ca4bad6f15999abdd93b74ccb3e82a664d6

diff --git a/i18npool/source/localedata/data/sort-formats.awk b/i18npool/source/localedata/data/sort-formats.awk
index ffd84e4d517e..1ac040ddb75d 100755
--- a/i18npool/source/localedata/data/sort-formats.awk
+++ b/i18npool/source/localedata/data/sort-formats.awk
@@ -7,21 +7,35 @@
 # 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
+# Usage: gawk -f sort-formats-by-formatindex.awk [-v group=1] ll_CC.xml
 #
 # Sort the LC_FORMAT child elements FormatElement and their children by
 # formatindex="..." value for easier comparison between locales.
+# If -v group=1 is given, the output is sorted by usage groups first, then by
+# formatindex. This could be the final sorting to commit.
 # Output goes to stdout.
 
 BEGIN {
     file = ""
+    usage["FIXED_NUMBER"] = 1
+    usage["SCIENTIFIC_NUMBER"] = 2
+    usage["PERCENT_NUMBER"] = 3
+    usage["CURRENCY"] = 4
+    usage["DATE"] = 5
+    usage["TIME"] = 6
+    usage["DATE_TIME"] = 7
+    group = (group ? 1 : 0)     # -v group=... given or not
 }
 
 file != FILENAME {
     file = FILENAME
     informats = 0
+    currusage = 0
     currformat = 0
+    inFormatElement = 0
     delete formats
+    currleader = 0
+    delete leaders
 }
 
 /<LC_FORMAT[ >]/ {
@@ -33,17 +47,28 @@ file != FILENAME {
 
 informats && /<\/LC_FORMAT>/ {
     PROCINFO["sorted_in"] = "@ind_num_asc"
-    for (f in formats)
+    for (u in formats)
     {
-        if (isarray(formats[f]))
+        if (isarray(formats[u]))
         {
-            for (i in formats[f])
-                print formats[f][i]
+            for (f in formats[u])
+            {
+                if (isarray(formats[u][f]))
+                {
+                    for (i in formats[u][f])
+                        print formats[u][f][i]
+                }
+                else
+                {
+                    # Something unhandled, adapt code.
+                    print "XXX formats[u][f] error: " formats[u][f]
+                }
+            }
         }
         else
         {
             # Something unhandled, adapt code.
-            print "XXX error: " formats[f]
+            print "XXX formats[u] error: " formats[u]
         }
     }
     informats = 0
@@ -58,11 +83,26 @@ informats && /<\/LC_FORMAT>/ {
 }
 
 /<FormatElement / {
-    split( $0, a, /formatindex="/)
+    if (group)
+    {
+        split( $0, a, / usage="/)
+        split( a[2], b, /"/)
+        currusage = usage[b[1]]
+    }
+    else
+    {
+        currusage = 0
+    }
+    split( $0, a, / formatindex="/)
     split( a[2], b, /"/)
     currformat = b[1]
     child = 0   # 1-based
-    formats[currformat][++child] = $0
+    for (l in leaders)
+        formats[currusage][currformat][++child] = leaders[l]
+    delete leaders
+    currleader = 0
+    formats[currusage][currformat][++child] = $0
+    inFormatElement = 1
     next
 }
 
@@ -71,9 +111,19 @@ informats && /<\/LC_FORMAT>/ {
     next
 }
 
+# Prefix a leading comment (or even an element) to the next FormatElement.
+!inFormatElement {
+    leaders[++currleader] = $0
+    next
+}
+
 # Associate any element or comment with the current FormatElement.
 {
-    formats[currformat][++child] = $0
+    formats[currusage][currformat][++child] = $0
+}
+
+/<\/FormatElement>/ {
+    inFormatElement = 0
 }
 
 END {
commit 952faab8ab597e86636324bdb9e8e3090bf025cc
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Apr 28 11:22:58 2017 +0200

    Rename to sort-formats.awk that better fits plans
    
    Change-Id: I4d4092375a040793f8aa408802978c420f33a4f3

diff --git a/i18npool/source/localedata/data/sort-formats-by-formatindex.awk b/i18npool/source/localedata/data/sort-formats.awk
similarity index 100%
rename from i18npool/source/localedata/data/sort-formats-by-formatindex.awk
rename to i18npool/source/localedata/data/sort-formats.awk


More information about the Libreoffice-commits mailing list