2 # -*- Mode: awk; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # Usage: gawk -f sort-formats-by-formatindex.awk [-v group=1] ll_CC.xml
12 # Sort the LC_FORMAT child elements FormatElement and their children by
13 # formatindex="..." value for easier comparison between locales.
14 # If -v group=1 is given, the output is sorted by usage groups first, then by
15 # formatindex. This could be the final sorting to commit.
16 # Output goes to stdout.
20 usage
["FIXED_NUMBER"] =
1
21 usage
["SCIENTIFIC_NUMBER"] =
2
22 usage
["PERCENT_NUMBER"] =
3
26 usage
["DATE_TIME"] =
7
27 group =
(group ?
1 : 0) # -v group=... given or not
48 informats
&& /<\
/LC_FORMAT
>/ {
49 PROCINFO
["sorted_in"] =
"@ind_num_asc"
52 if (isarray
(formats
[u
]))
56 if (isarray
(formats
[u
][f
]))
58 for (i in formats
[u
][f
])
59 print formats
[u
][f
][i
]
63 # Something unhandled, adapt code.
64 print "XXX formats[u][f] error: " formats
[u
][f
]
70 # Something unhandled, adapt code.
71 print "XXX formats[u] error: " formats
[u
]
88 split( $
0, a
, / usage=
"/)
90 currusage = usage
[b
[1]]
96 split( $
0, a
, / formatindex=
"/)
101 formats
[currusage
][currformat
][++child
] = leaders
[l
]
104 formats
[currusage
][currformat
][++child
] = $
0
109 /<DateAcceptancePattern
[ >]/ {
114 # Prefix a leading comment (or even an element) to the next FormatElement.
116 leaders
[++currleader
] = $
0
120 # Associate any element or comment with the current FormatElement.
122 formats
[currusage
][currformat
][++child
] = $
0
125 /<\
/FormatElement
>/ {
132 # vim:set shiftwidth=4 softtabstop=4 expandtab: