1308265Sgjb# Check links in tz tables.
2308265Sgjb
3308265Sgjb# Contributed by Paul Eggert.  This file is in the public domain.
4308265Sgjb
5308265SgjbBEGIN {
6308265Sgjb    # Special marker indicating that the name is defined as a Zone.
7308265Sgjb    # It is a newline so that it cannot match a valid name.
8308265Sgjb    # It is not null so that its slot does not appear unset.
9308265Sgjb    Zone = "\n"
10308265Sgjb}
11308265Sgjb
12325160Sphilip/^Z/ {
13308265Sgjb    if (defined[$2]) {
14308265Sgjb	if (defined[$2] == Zone) {
15308265Sgjb	    printf "%s: Zone has duplicate definition\n", $2
16308265Sgjb	} else {
17308265Sgjb	    printf "%s: Link with same name as Zone\n", $2
18308265Sgjb	}
19308265Sgjb	status = 1
20308265Sgjb    }
21308265Sgjb    defined[$2] = Zone
22308265Sgjb}
23308265Sgjb
24325160Sphilip/^L/ {
25308265Sgjb    if (defined[$3]) {
26308265Sgjb	if (defined[$3] == Zone) {
27308265Sgjb	    printf "%s: Link with same name as Zone\n", $3
28308265Sgjb	} else if (defined[$3] == $2) {
29308265Sgjb	    printf "%s: Link has duplicate definition\n", $3
30308265Sgjb	} else {
31308265Sgjb	    printf "%s: Link to both %s and %s\n", $3, defined[$3], $2
32308265Sgjb	}
33308265Sgjb	status = 1
34308265Sgjb    }
35308265Sgjb    used[$2] = 1
36308265Sgjb    defined[$3] = $2
37308265Sgjb}
38308265Sgjb
39308265SgjbEND {
40308265Sgjb    for (tz in used) {
41308265Sgjb	if (defined[tz] != Zone) {
42308265Sgjb	    printf "%s: Link to non-zone\n", tz
43308265Sgjb	    status = 1
44308265Sgjb	}
45308265Sgjb    }
46308265Sgjb
47308265Sgjb    exit status
48308265Sgjb}
49