[PROPOSED] Check that ziguard substitutions revert
Add a check that substitutions to vanguard or rearguard form can be reverted. This supports possible future uses when continental files are in vanguard form and you want rearguard (or vice versa). * Makefile (check): Depend on ... (check_ziguard): ... this new target. * ziguard.awk: Fix some in_comment typos, as these column numbers do not depend on whether we’re in a comment. Use sub(X,Y) instead of $I = Y to preserve whitespace. Fix Japan and Morocco substitutions so that they are reversible. --- Makefile | 9 ++++++++- ziguard.awk | 58 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index e3e5c0dd..52d7fdbe 100644 --- a/Makefile +++ b/Makefile @@ -754,7 +754,7 @@ tzselect: tzselect.ksh version check: check_character_set check_white_space check_links \ check_name_lengths check_slashed_abbrs check_sorted \ - check_tables check_web check_zishrink check_tzs + check_tables check_web check_ziguard check_zishrink check_tzs check_character_set: $(ENCHILADA) test ! '$(UTF8_LOCALE)' || \ @@ -839,6 +839,13 @@ check_theory.html check_tz-art.html check_tz-how-to.html check_tz-link.html: test ! -s $@.out || { cat $@.out; exit 1; } mv $@.out $@ +check_ziguard: rearguard.zi vanguard.zi ziguard.awk + $(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \ + diff -u rearguard.zi - + $(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \ + diff -u vanguard.zi - + touch $@ + # Check that zishrink.awk does not alter the data, and that ziguard.awk # preserves main-format data. check_zishrink: check_zishrink_posix check_zishrink_right diff --git a/ziguard.awk b/ziguard.awk index 171b952d..c39e0d65 100644 --- a/ziguard.awk +++ b/ziguard.awk @@ -134,8 +134,7 @@ DATAFORM != "main" { || in_comment + 3 == NF)))) if (Rule_Namibia || Zone_using_Namibia_rule) { if ((Rule_Namibia \ - ? ($(in_comment + 9) ~ /^-/ \ - || ($(in_comment + 9) == 0 && $(in_comment + 10) == "CAT")) \ + ? ($9 ~ /^-/ || ($9 == 0 && $10 == "CAT")) \ : $(in_comment + 1) == "2:00" && $(in_comment + 2) == "Namibia") \ == (DATAFORM != "rearguard")) { uncomment = in_comment @@ -219,43 +218,66 @@ DATAFORM != "main" { stdoff_column = 2 * /^Zone/ + 1 stdoff_column_val = $stdoff_column if (stdoff_column_val == stdoff_subst[0]) { - $stdoff_column = stdoff_subst[1] + sub(stdoff_subst[0], stdoff_subst[1]) if (until_subst[0] && $NF == until_subst[0]) { - $NF = until_subst[1] + sub(until_subst[0], until_subst[1]) } } else if (stdoff_column_val != stdoff_subst[1]) { stdoff_subst[0] = 0 } } - if (DATAFORM == "rearguard") { - - # In rearguard form, change the Japan rule line with "Sat>=8 25:00" - # to "Sun>=9 1:00", to cater to zic before 2007 and to older Java. - if (/^Rule/ && $2 == "Japan") { + # In rearguard form, change the Japan rule line with "Sat>=8 25:00" + # to "Sun>=9 1:00", to cater to zic before 2007 and to older Java. + if (/^Rule/ && $2 == "Japan") { + if (DATAFORM == "rearguard") { if ($7 == "Sat>=8" && $8 == "25:00") { sub(/Sat>=8/, "Sun>=9") sub(/25:00/, " 1:00") } + } else { + if ($7 == "Sun>=9" && $8 == "1:00") { + sub(/Sun>=9/, "Sat>=8") + sub(/ 1:00/, "25:00") + } } + } - # In rearguard form, change the Morocco lines with negative SAVE values - # to use positive SAVE values. - if ($2 == "Morocco") { - if (/^Rule/) { - if ($4 == 2018 && $6 == "Oct") { + # In rearguard form, change the Morocco lines with negative SAVE values + # to use positive SAVE values. + if ($2 == "Morocco") { + if (/^Rule/) { + if ($4 ~ /^201[78]$/ && $6 == "Oct") { + if (DATAFORM == "rearguard") { sub(/\t2018\t/, "\t2017\t") + } else { + sub(/\t2017\t/, "\t2018\t") } - if (2019 <= $3) { - if ($9 == "0") { + } + + if (2019 <= $3) { + if ($8 == "2:00") { + if (DATAFORM == "rearguard") { sub(/\t0\t/, "\t1:00\t") } else { + sub(/\t1:00\t/, "\t0\t") + } + } else { + if (DATAFORM == "rearguard") { sub(/\t-1:00\t/, "\t0\t") + } else { + sub(/\t0\t/, "\t-1:00\t") } } } - if ($1 == "1:00" && $3 == "+01/+00") { - sub(/1:00\tMorocco\t\+01\/\+00$/, "0:00\tMorocco\t+00/+01") + } + if ($1 ~ /^[+0-9-]/ && NF == 3) { + if (DATAFORM == "rearguard") { + sub(/1:00\tMorocco/, "0:00\tMorocco") + sub(/\t\+01\/\+00$/, "\t+00/+01") + } else { + sub(/0:00\tMorocco/, "1:00\tMorocco") + sub(/\t\+00\/+01$/, "\t+01/+00") } } } -- 2.34.1
participants (1)
-
Paul Eggert