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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# Check tz tables for consistency.
# Contributed by Paul Eggert.
BEGIN {
FS = "\t"
if (!iso_table) iso_table = "iso3166.tab"
if (!zone_table) zone_table = "zone.tab"
if (!want_warnings) want_warnings = -1
while (getline <iso_table) {
iso_NR++
if ($0 ~ /^#/) continue
if (NF != 2) {
printf "%s:%d: wrong number of columns\n", \
iso_table, iso_NR >>"/dev/stderr"
status = 1
}
cc = $1
name = $2
if (cc !~ /^[A-Z][A-Z]$/) {
printf "%s:%d: invalid country code `%s'\n", \
iso_table, iso_NR, cc >>"/dev/stderr"
status = 1
}
if (cc <= cc0) {
if (cc == cc0) {
s = "duplicate";
} else {
s = "out of order";
}
printf "%s:%d: country code `%s' is %s\n", \
iso_table, iso_NR, cc, s \
>>"/dev/stderr"
status = 1
}
cc0 = cc
if (name2cc[name]) {
printf "%s:%d: `%s' and `%s' have the sname name\n", \
iso_table, iso_NR, name2cc[name], cc \
>>"/dev/stderr"
status = 1
}
name2cc[name] = cc
cc2name[cc] = name
cc2NR[cc] = iso_NR
}
zone_table = "zone.tab"
cc0 = ""
while (getline <zone_table) {
zone_NR++
if ($0 ~ /^#/) continue
if (NF != 3 && NF != 4) {
printf "%s:%d: wrong number of columns\n", \
zone_table, zone_NR >>"/dev/stderr"
status = 1
}
cc = $1
coordinates = $2
tz = $3
comments = $4
if (cc < cc0) {
printf "%s:%d: country code `%s' is out of order\n", \
zone_table, zone_NR, cc >>"/dev/stderr"
status = 1
}
cc0 = cc
if (tz2cc[tz]) {
printf "%s:%d: %s: duplicate TZ column\n", \
zone_table, zone_NR, tz >>"/dev/stderr"
status = 1
}
tz2cc[tz] = cc
tz2comments[tz] = comments
tz2NR[tz] = zone_NR
if (cc2name[cc]) {
cc_used[cc]++
} else {
printf "%s:%d: %s: unknown country code\n", \
zone_table, zone_NR, cc >>"/dev/stderr"
status = 1
}
if (coordinates !~ /^[-+][0-9][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9]$/ \
&& coordinates !~ /^[-+][0-9][0-9][0-5][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9][0-5][0-9]$/) {
printf "%s:%d: %s: invalid coordinates\n", \
zone_table, zone_NR, coordinates >>"/dev/stderr"
status = 1
}
}
for (tz in tz2cc) {
if (cc_used[tz2cc[tz]] == 1) {
if (tz2comments[tz]) {
printf "%s:%d: unnecessary comment `%s'\n", \
zone_table, tz2NR[tz], tz2comments[tz] \
>>"/dev/stderr"
status = 1
}
} else {
if (!tz2comments[tz]) {
printf "%s:%d: missing comment\n", \
zone_table, tz2NR[tz] >>"/dev/stderr"
status = 1
}
}
}
FS = " "
}
{
tz = ""
if ($1 == "Zone") tz = $2
if ($1 == "Link") {
# Ignore Link commands if source and destination basenames
# are identical, e.g. Europe/Istanbul versus Asia/Istanbul.
src = $2
dst = $3
while ((i = index(src, "/"))) src = substr(src, i+1)
while ((i = index(dst, "/"))) dst = substr(dst, i+1)
if (src != dst) tz = $3
}
if (tz && tz ~ /\//) {
if (!tz2cc[tz]) {
printf "%s: no data for `%s'\n", zone_table, tz \
>>"/dev/stderr"
status = 1
}
zoneSeen[tz] = 1
}
}
END {
for (tz in tz2cc) {
if (!zoneSeen[tz]) {
printf "%s:%d: no Zone table for `%s'\n", \
zone_table, tz2NR[tz], tz >>"/dev/stderr"
status = 1
}
}
if (0 < want_warnings) {
for (cc in cc2name) {
if (!cc_used[cc]) {
printf "%s:%d: warning: " \
"no Zone entries for %s (%s)\n", \
iso_table, cc2NR[cc], cc, cc2name[cc]
}
}
}
exit status
}
|