# Convert tzdata source into vanguard or rearguard form.
# Contributed by Paul Eggert. This file is in the public domain.
# This is not a general-purpose converter; it is designed for current tzdata.
#
# When converting to vanguard form, the output can use negative SAVE
# values.
#
# When converting to rearguard form, the output uses only nonnegative
# SAVE values. The idea is for the output data to simulate the behavior
# of the input data as best it can within the constraints of the
# rearguard format.
BEGIN {

}
# If a Link line is followed by a Zone line for the same data, comment
# out the Link line. This can happen if backzone overrides a Link
# with a Zone.
/^Link/ {
linkline[$3] = NR
}
/^Zone/ {
sub(/^Link/, "#Link", line[linkline[$2]])
}
{ line[NR] = $0 }
END {
for (i = 1; i <= NR; i++)
print line[i]
}