Przeglądaj źródła

'make check_links' now checks duplicate links etc.

* checklinks.awk: Check for duplicate links and zones.
Prompted by a problem report from Daniel Schultze in:
http://mm.icann.org/pipermail/tz/2015-September/022650.html
Paul Eggert 10 lat temu
rodzic
commit
1e1bbcd3ef
1 zmienionych plików z 34 dodań i 5 usunięć
  1. 34 5
      checklinks.awk

+ 34 - 5
checklinks.awk

@@ -2,14 +2,43 @@
 
 # Contributed by Paul Eggert.
 
-/^Link/ { used[$2] = 1 }
-/^Zone/ { defined[$2] = 1 }
+BEGIN {
+    # Special marker indicating that the name is defined as a Zone.
+    # It is a newline so that it cannot match a valid name.
+    # It is not null so that its slot does not appear unset.
+    Zone = "\n"
+}
 
-END {
-    status = 0
+/^Zone/ {
+    if (defined[$2]) {
+	if (defined[$2] == Zone) {
+	    printf "%s: Zone has duplicate definition\n", $2
+	} else {
+	    printf "%s: Link with same name as Zone\n", $2
+	}
+	status = 1
+    }
+    defined[$2] = Zone
+}
 
+/^Link/ {
+    if (defined[$3]) {
+	if (defined[$3] == Zone) {
+	    printf "%s: Link with same name as Zone\n", $3
+	} else if (defined[$3] == $2) {
+	    printf "%s: Link has duplicate definition\n", $3
+	} else {
+	    printf "%s: Link to both %s and %s\n", $3, defined[$3], $2
+	}
+	status = 1
+    }
+    used[$2] = 1
+    defined[$3] = $2
+}
+
+END {
     for (tz in used) {
-	if (!defined[tz]) {
+	if (defined[tz] != Zone) {
 	    printf "%s: Link to non-zone\n", tz
 	    status = 1
 	}