Home | History | Annotate | Line # | Download | only in dist
      1      1.1       apb # Check links in tz tables.
      2      1.1       apb 
      3  1.1.1.2  christos # Contributed by Paul Eggert.  This file is in the public domain.
      4      1.1       apb 
      5  1.1.1.2  christos BEGIN {
      6  1.1.1.2  christos     # Special marker indicating that the name is defined as a Zone.
      7  1.1.1.2  christos     # It is a newline so that it cannot match a valid name.
      8  1.1.1.2  christos     # It is not null so that its slot does not appear unset.
      9  1.1.1.2  christos     Zone = "\n"
     10  1.1.1.2  christos }
     11      1.1       apb 
     12  1.1.1.3       kre /^Z/ {
     13  1.1.1.2  christos     if (defined[$2]) {
     14  1.1.1.2  christos 	if (defined[$2] == Zone) {
     15  1.1.1.2  christos 	    printf "%s: Zone has duplicate definition\n", $2
     16  1.1.1.2  christos 	} else {
     17  1.1.1.2  christos 	    printf "%s: Link with same name as Zone\n", $2
     18  1.1.1.2  christos 	}
     19  1.1.1.2  christos 	status = 1
     20  1.1.1.2  christos     }
     21  1.1.1.2  christos     defined[$2] = Zone
     22  1.1.1.2  christos }
     23      1.1       apb 
     24  1.1.1.3       kre /^L/ {
     25  1.1.1.2  christos     if (defined[$3]) {
     26  1.1.1.2  christos 	if (defined[$3] == Zone) {
     27  1.1.1.2  christos 	    printf "%s: Link with same name as Zone\n", $3
     28  1.1.1.2  christos 	} else if (defined[$3] == $2) {
     29  1.1.1.2  christos 	    printf "%s: Link has duplicate definition\n", $3
     30  1.1.1.2  christos 	} else {
     31  1.1.1.2  christos 	    printf "%s: Link to both %s and %s\n", $3, defined[$3], $2
     32  1.1.1.2  christos 	}
     33  1.1.1.2  christos 	status = 1
     34  1.1.1.2  christos     }
     35  1.1.1.4       kre     if (backcheck && FILENAME != backcheck && $3 != "GMT") {
     36  1.1.1.4       kre       printf "%s: Link should be in '%s'\n", $3, backcheck
     37  1.1.1.4       kre       status = 1
     38  1.1.1.4       kre     }
     39  1.1.1.4       kre     if ($4 == "#=") {
     40  1.1.1.4       kre       shortcut[$5] = $3
     41  1.1.1.4       kre     }
     42  1.1.1.2  christos     used[$2] = 1
     43  1.1.1.2  christos     defined[$3] = $2
     44  1.1.1.2  christos }
     45  1.1.1.2  christos 
     46  1.1.1.2  christos END {
     47      1.1       apb     for (tz in used) {
     48  1.1.1.2  christos 	if (defined[tz] != Zone) {
     49  1.1.1.4       kre 	  if (!defined[tz]) {
     50  1.1.1.4       kre 	    printf "%s: Link to nowhere\n", tz
     51      1.1       apb 	    status = 1
     52  1.1.1.4       kre 	  } else if (DATAFORM != "vanguard") {
     53  1.1.1.4       kre 	    printf "%s: Link to link\n", tz
     54  1.1.1.4       kre 	    status = 1
     55  1.1.1.4       kre 	  }
     56      1.1       apb 	}
     57      1.1       apb     }
     58  1.1.1.4       kre     for (tz in shortcut) {
     59  1.1.1.4       kre       if (defined[shortcut[tz]] != defined[tz]) {
     60  1.1.1.4       kre 	target = (!defined[tz] ? "absence" \
     61  1.1.1.4       kre 		  : defined[tz] == "\n" ? "zone" \
     62  1.1.1.4       kre 		  : defined[tz])
     63  1.1.1.4       kre 	printf "%s: target %s disagrees with %s's target %s\n", \
     64  1.1.1.4       kre 	  tz, target, shortcut[tz], defined[shortcut[tz]]
     65  1.1.1.4       kre 	status = 1
     66  1.1.1.4       kre       }
     67  1.1.1.4       kre     }
     68      1.1       apb 
     69      1.1       apb     exit status
     70      1.1       apb }
     71