1 # $NetBSD: checktab.awk,v 1.4 2009/12/31 22:49:16 mlelstv Exp $
3 # Check tz tables for consistency.
7 # Contributed by Paul Eggert.
12 if (!iso_table
) iso_table =
"iso3166.tab"
13 if (!zone_table
) zone_table =
"zone.tab"
14 if (!want_warnings
) want_warnings =
-1
16 while (getline <iso_table
) {
18 if ($
0 ~
/^
#/) continue
20 printf "%s:%d: wrong number of columns\n", \
21 iso_table
, iso_NR
>>"/dev/stderr"
26 if (cc !~
/^
[A
-Z
][A
-Z
]$
/) {
27 printf "%s:%d: invalid country code `%s'\n", \
28 iso_table
, iso_NR
, cc
>>"/dev/stderr"
38 printf "%s:%d: country code `%s' is %s\n", \
39 iso_table
, iso_NR
, cc
, s \
45 printf "%s:%d: `%s' and `%s' have the sname name\n", \
46 iso_table
, iso_NR
, name2cc
[name
], cc \
55 zone_table =
"zone.tab"
58 while (getline <zone_table
) {
60 if ($
0 ~
/^
#/) continue
61 if (NF != 3 && NF != 4) {
62 printf "%s:%d: wrong number of columns\n", \
63 zone_table
, zone_NR
>>"/dev/stderr"
71 printf "%s:%d: country code `%s' is out of order\n", \
72 zone_table
, zone_NR
, cc
>>"/dev/stderr"
77 printf "%s:%d: %s: duplicate TZ column\n", \
78 zone_table
, zone_NR
, tz
>>"/dev/stderr"
82 tz2comments
[tz
] = comments
87 printf "%s:%d: %s: unknown country code\n", \
88 zone_table
, zone_NR
, cc
>>"/dev/stderr"
91 if (coordinates !~
/^
[-+][0-9][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9]$
/ \
92 && 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]$
/) {
93 printf "%s:%d: %s: invalid coordinates\n", \
94 zone_table
, zone_NR
, coordinates
>>"/dev/stderr"
100 if (cc_used
[tz2cc
[tz
]] ==
1) {
101 if (tz2comments
[tz
]) {
102 printf "%s:%d: unnecessary comment `%s'\n", \
103 zone_table
, tz2NR
[tz
], tz2comments
[tz
] \
108 if (!tz2comments
[tz
]) {
109 printf "%s:%d: missing comment\n", \
110 zone_table
, tz2NR
[tz
] >>"/dev/stderr"
121 if ($
1 ==
"Zone") tz = $
2
123 # Ignore Link commands if source and destination basenames
124 # are identical, e.g. Europe/Istanbul versus Asia/Istanbul.
127 while ((i =
index(src
, "/"))) src =
substr(src
, i
+1)
128 while ((i =
index(dst
, "/"))) dst =
substr(dst
, i
+1)
129 if (src
!= dst
) tz = $
3
131 if (tz
&& tz ~
/\
//) {
133 printf "%s: no data for `%s'\n", zone_table
, tz \
144 printf "%s:%d: no Zone table for `%s'\n", \
145 zone_table
, tz2NR
[tz
], tz
>>"/dev/stderr"
150 if (0 < want_warnings
) {
151 for (cc in cc2name
) {
153 printf "%s:%d: warning: " \
154 "no Zone entries for %s (%s)\n", \
155 iso_table
, cc2NR
[cc
], cc
, cc2name
[cc
]