Skip to content

Commit

Permalink
Check for links to links.
Browse files Browse the repository at this point in the history
This problem has come up before, and it's time to add a check to
catch this common error.
* Makefile (AWK_SCRIPTS): Add checklinks.awk.
(check, .PHONY): Add check_links.
(check_links): New rule.
* checklinks.awk: New file.
  • Loading branch information
eggert committed Nov 17, 2014
1 parent da5a365 commit 2dc5286
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Makefile
Expand Up @@ -359,7 +359,7 @@ TABDATA= iso3166.tab leapseconds $(ZONETABLES)
LEAP_DEPS= leapseconds.awk leap-seconds.list
DATA= $(YDATA) $(NDATA) backzone $(TABDATA) \
leap-seconds.list yearistype.sh
AWK_SCRIPTS= checktab.awk leapseconds.awk
AWK_SCRIPTS= checklinks.awk checktab.awk leapseconds.awk
MISC= $(AWK_SCRIPTS) zoneinfo2tdf.pl
ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC)
Expand Down Expand Up @@ -468,7 +468,7 @@ tzselect: tzselect.ksh
<$? >$@
chmod +x $@
check: check_character_set check_white_space check_sorted \
check: check_character_set check_white_space check_links check_sorted \
check_tables check_web
check_character_set: $(ENCHILADA)
Expand Down Expand Up @@ -500,6 +500,9 @@ check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
LC_ALL=C sort -cu
check_links: checklinks.awk $(TDATA)
$(AWK) -f checklinks.awk $(TDATA)
check_tables: checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
for tab in $(ZONETABLES); do \
$(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
Expand Down Expand Up @@ -662,7 +665,8 @@ zic.o: private.h tzfile.h version.h
.KEEP_STATE:

.PHONY: ALL INSTALL all
.PHONY: check check_character_set check_public check_sorted check_tables
.PHONY: check check_character_set check_links
.PHONY: check_public check_sorted check_tables
.PHONY: check_time_t_alternatives check_web check_white_space clean clean_misc
.PHONY: install maintainer-clean names posix_packrat posix_only posix_right
.PHONY: public right_only right_posix signatures tarballs typecheck
Expand Down
19 changes: 19 additions & 0 deletions checklinks.awk
@@ -0,0 +1,19 @@
# Check links in tz tables.

# Contributed by Paul Eggert.

/^Link/ { used[$2] = 1 }
/^Zone/ { defined[$2] = 1 }

END {
status = 0

for (tz in used) {
if (!defined[tz]) {
printf "%s: Link to non-zone\n", tz
status = 1
}
}

exit status
}

0 comments on commit 2dc5286

Please sign in to comment.