summaryrefslogtreecommitdiff
path: root/i18npool/source/localedata/data/list-dateacceptancepattern.awk
blob: b1ad115e52ca9d75a576d9f17fe667bb004c6759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/gawk -f
# -*- Mode: awk; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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 list-dateacceptancepattern.awk *.xml [--html]
# Outputs two lists of locales, one with DateAcceptancePattern elements
# defined, and one where none are defined.
# If --html is given as the last parameter, format output suitable for
# inclusion in HTML.

BEGIN {
    html = 0
    if (ARGV[ARGC-1] == "--html") {
        html = 1
        --ARGC
    }
    file = ""
    nopatterns = 0
    if (html)
        print "<p>"
    else
        print ""
    print "Locales with explicit DateAcceptancePattern elements:"
    if (html)
        print "<ul>"
}


file != FILENAME {
    if (file)
        endFile()
    file = FILENAME
    patterns = 0
    noFormatCode = 1
}

/<DateAcceptancePattern>/ {
    split( $0, a, /<|>/ )
    pattern[patterns++] = a[3]
}

# No FormatCode element means inherited LC_FORMAT ref=...
# hence pattern inherited as well.
/<FormatCode>/ {
    noFormatCode = 0
}


END {
    if (file)
        endFile()
    if (html)
    {
        print "</ul>"
        print "\n<p>"
    }
    else
        print "\n"
    print "Locales without explicit DateAcceptancePattern elements:"
    if (html)
        print "<br>"
    print "(one implicit full date pattern is always generated)"
    if (html)
        print "<p>"
    if (html)
    {
        for (i=0; i<nopatterns; ++i)
        {
            print NoPatternList[i] "&nbsp;&nbsp;&nbsp; "
        }
    }
    else
    {
        for (i=0; i<nopatterns; ++i)
        {
            print NoPatternList[i]
        }
    }
}


function endFile() {
    if (patterns)
    {
        if (html)
        {
            print "  <li> " getLocale( file) ":"
            print "  <ul>"
            for ( i=0; i<patterns; ++i )
            {
                print "    <li> " pattern[i]
            }
            print "  </ul>"
        }
        else
        {
            print getLocale( file) ":"
            for ( i=0; i<patterns; ++i )
            {
                print "    " pattern[i]
            }
        }
    }
    else if (!noFormatCode)
        NoPatternList[nopatterns++] = getLocale( file)
}


function getLocale( file, tmp ) {
    tmp = file
    gsub( /.*\//, "", tmp )
    gsub( /\.xml/, "", tmp )
    return tmp
}

# vim:set shiftwidth=4 softtabstop=4 expandtab: