xref: /freebsd/contrib/tzdata/checknow.awk (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1# Check zonenow.tab for consistency with primary data.
2
3# Contributed by Paul Eggert.  This file is in the public domain.
4
5function record_zone(zone, data) {
6  if (zone) {
7    zone_data[zone] = data
8    zones[data] = zones[data] " " zone
9  }
10}
11
12BEGIN {
13  while (getline <zdump_table) {
14    if ($0 ~ /^TZ/) {
15      record_zone(zone, data)
16      zone = $0
17      sub(/.*\.dir\//, "", zone)
18      sub(/\/\//, "/", zone)
19      sub(/"/, "", zone)
20      data = ""
21    } else if ($0 ~ /./)
22      data = data $0 "\n"
23  }
24  record_zone(zone, data)
25  FS = "\t"
26}
27
28/^[^#]/ {
29  zone = $3
30  data = zone_data[zone]
31  if (!data) {
32    printf "%s: no data\n", zone
33    status = 1
34  } else {
35    zone2 = zonenow[data]
36    if (zone2) {
37      printf "zones %s and %s identical from now on\n", zone, zone2
38      status = 1
39    } else
40      zonenow[data] = zone
41  }
42}
43
44END {
45 for (zone in zone_data) {
46    data = zone_data[zone]
47    if (!zonenow[data]) {
48      printf "checknow.tab should have one of:%s\n", zones[data]
49      zonenow[data] = zone # This suppresses duplicate diagnostics.
50      status = 1
51    }
52 }
53 exit status
54}
55