1 # $NetBSD: checktab.awk,v 1.6 2013/09/20 19:06:54 christos Exp $
3 # Check tz tables for consistency.
5 # Contributed by Paul Eggert.
10 if (!iso_table
) iso_table =
"iso3166.tab"
11 if (!zone_table
) zone_table =
"zone.tab"
12 if (!want_warnings
) want_warnings =
-1
14 # A special (and we hope temporary) case.
15 tztab
["America/Montreal"] =
1
17 while (getline <iso_table
) {
19 if ($
0 ~
/^
#/) continue
21 printf "%s:%d: wrong number of columns\n", \
22 iso_table
, iso_NR
>>"/dev/stderr"
27 if (cc !~
/^
[A
-Z
][A
-Z
]$
/) {
28 printf "%s:%d: invalid country code `%s'\n", \
29 iso_table
, iso_NR
, cc
>>"/dev/stderr"
39 printf "%s:%d: country code `%s' is %s\n", \
40 iso_table
, iso_NR
, cc
, s \
46 printf "%s:%d: `%s' and `%s' have the sname name\n", \
47 iso_table
, iso_NR
, name2cc
[name
], cc \
56 zone_table =
"zone.tab"
59 while (getline <zone_table
) {
61 if ($
0 ~
/^
#/) continue
62 if (NF != 3 && NF != 4) {
63 printf "%s:%d: wrong number of columns\n", \
64 zone_table
, zone_NR
>>"/dev/stderr"
72 printf "%s:%d: country code `%s' is out of order\n", \
73 zone_table
, zone_NR
, cc
>>"/dev/stderr"
80 tz2comments
[cctz
] = comments
85 printf "%s:%d: %s: unknown country code\n", \
86 zone_table
, zone_NR
, cc
>>"/dev/stderr"
89 if (coordinates !~
/^
[-+][0-9][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9]$
/ \
90 && 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]$
/) {
91 printf "%s:%d: %s: invalid coordinates\n", \
92 zone_table
, zone_NR
, coordinates
>>"/dev/stderr"
97 for (cctz in cctztab
) {
98 cc =
substr (cctz
, 1, 2)
100 if (cc_used
[cc
] ==
1) {
101 if (tz2comments
[cctz
]) {
102 printf "%s:%d: unnecessary comment `%s'\n", \
103 zone_table
, tz2NR
[tz
], \
109 if (!tz2comments
[cctz
]) {
110 printf "%s:%d: missing comment\n", \
111 zone_table
, tz2NR
[tz
] >>"/dev/stderr"
122 if ($
1 ==
"Zone") tz = $
2
124 # Ignore Link commands if source and destination basenames
125 # are identical, e.g. Europe/Istanbul versus Asia/Istanbul.
128 while ((i =
index(src
, "/"))) src =
substr(src
, i
+1)
129 while ((i =
index(dst
, "/"))) dst =
substr(dst
, i
+1)
130 if (src
!= dst
) tz = $
3
132 if (tz
&& tz ~
/\
//) {
134 printf "%s: no data for `%s'\n", zone_table
, tz \
145 printf "%s:%d: no Zone table for `%s'\n", \
146 zone_table
, tz2NR
[tz
], tz
>>"/dev/stderr"
151 if (0 < want_warnings
) {
152 for (cc in cc2name
) {
154 printf "%s:%d: warning: " \
155 "no Zone entries for %s (%s)\n", \
156 iso_table
, cc2NR
[cc
], cc
, cc2name
[cc
]