checklinks.awk revision 309583
1309583Sglebius# Check links in tz tables. 2309583Sglebius 3309583Sglebius# Contributed by Paul Eggert. This file is in the public domain. 4309583Sglebius 5309583SglebiusBEGIN { 6309583Sglebius # Special marker indicating that the name is defined as a Zone. 7309583Sglebius # It is a newline so that it cannot match a valid name. 8309583Sglebius # It is not null so that its slot does not appear unset. 9309583Sglebius Zone = "\n" 10309583Sglebius} 11309583Sglebius 12309583Sglebius/^Zone/ { 13309583Sglebius if (defined[$2]) { 14309583Sglebius if (defined[$2] == Zone) { 15309583Sglebius printf "%s: Zone has duplicate definition\n", $2 16309583Sglebius } else { 17309583Sglebius printf "%s: Link with same name as Zone\n", $2 18309583Sglebius } 19309583Sglebius status = 1 20309583Sglebius } 21309583Sglebius defined[$2] = Zone 22309583Sglebius} 23309583Sglebius 24309583Sglebius/^Link/ { 25309583Sglebius if (defined[$3]) { 26309583Sglebius if (defined[$3] == Zone) { 27309583Sglebius printf "%s: Link with same name as Zone\n", $3 28309583Sglebius } else if (defined[$3] == $2) { 29309583Sglebius printf "%s: Link has duplicate definition\n", $3 30309583Sglebius } else { 31309583Sglebius printf "%s: Link to both %s and %s\n", $3, defined[$3], $2 32309583Sglebius } 33309583Sglebius status = 1 34309583Sglebius } 35309583Sglebius used[$2] = 1 36309583Sglebius defined[$3] = $2 37309583Sglebius} 38309583Sglebius 39309583SglebiusEND { 40309583Sglebius for (tz in used) { 41309583Sglebius if (defined[tz] != Zone) { 42309583Sglebius printf "%s: Link to non-zone\n", tz 43309583Sglebius status = 1 44309583Sglebius } 45309583Sglebius } 46309583Sglebius 47309583Sglebius exit status 48309583Sglebius} 49