1 # Check tz tables for consistency.
3 # Contributed by Paul Eggert.
8 if (!iso_table
) iso_table =
"iso3166.tab"
9 if (!zone_table
) zone_table =
"zone.tab"
10 if (!want_warnings
) want_warnings =
-1
12 # A special (and we hope temporary) case.
13 tztab
["America/Montreal"] =
1
15 while (getline <iso_table
) {
17 if ($
0 ~
/^
#/) continue
19 printf "%s:%d: wrong number of columns\n", \
20 iso_table
, iso_NR
>>"/dev/stderr"
25 if (cc !~
/^
[A
-Z
][A
-Z
]$
/) {
26 printf "%s:%d: invalid country code `%s'\n", \
27 iso_table
, iso_NR
, cc
>>"/dev/stderr"
37 printf "%s:%d: country code `%s' is %s\n", \
38 iso_table
, iso_NR
, cc
, s \
44 printf "%s:%d: `%s' and `%s' have the sname name\n", \
45 iso_table
, iso_NR
, name2cc
[name
], cc \
54 zone_table =
"zone.tab"
57 while (getline <zone_table
) {
59 if ($
0 ~
/^
#/) continue
60 if (NF != 3 && NF != 4) {
61 printf "%s:%d: wrong number of columns\n", \
62 zone_table
, zone_NR
>>"/dev/stderr"
70 printf "%s:%d: country code `%s' is out of order\n", \
71 zone_table
, zone_NR
, cc
>>"/dev/stderr"
78 tz2comments
[cctz
] = comments
83 printf "%s:%d: %s: unknown country code\n", \
84 zone_table
, zone_NR
, cc
>>"/dev/stderr"
87 if (coordinates !~
/^
[-+][0-9][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9]$
/ \
88 && 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]$
/) {
89 printf "%s:%d: %s: invalid coordinates\n", \
90 zone_table
, zone_NR
, coordinates
>>"/dev/stderr"
95 for (cctz in cctztab
) {
96 cc =
substr (cctz
, 1, 2)
98 if (cc_used
[cc
] ==
1) {
99 if (tz2comments
[cctz
]) {
100 printf "%s:%d: unnecessary comment `%s'\n", \
101 zone_table
, tz2NR
[tz
], \
107 if (!tz2comments
[cctz
]) {
108 printf "%s:%d: missing comment\n", \
109 zone_table
, tz2NR
[tz
] >>"/dev/stderr"
125 } else if ($
1 ==
"Link") {
126 # Ignore Link commands if source and destination basenames
127 # are identical, e.g. Europe/Istanbul versus Asia/Istanbul.
130 while ((i =
index(src
, "/"))) src =
substr(src
, i
+1)
131 while ((i =
index(dst
, "/"))) dst =
substr(dst
, i
+1)
132 if (src
!= dst
) tz = $
3
133 } else if ($
1 ==
"Rule") {
138 if (tz
&& tz ~
/\
//) {
140 printf "%s: no data for `%s'\n", zone_table
, tz \
149 for (tz in ruleDefined
) {
151 printf "%s: Rule never used\n", tz
157 printf "%s:%d: no Zone table for `%s'\n", \
158 zone_table
, tz2NR
[tz
], tz
>>"/dev/stderr"
163 if (0 < want_warnings
) {
164 for (cc in cc2name
) {
166 printf "%s:%d: warning: " \
167 "no Zone entries for %s (%s)\n", \
168 iso_table
, cc2NR
[cc
], cc
, cc2name
[cc
]