* tzselect.ksh (check_POSIX_TZ_STRING): New var. Use it to work around a bug in mawk 1.3.4 2023-0730 <https://github.com/ThomasDickey/original-mawk/issues/72> as it uses /XXX+/ rather than /X{3,}/ in awk patterns. --- NEWS | 3 +++ tzselect.ksh | 35 +++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index bad81aa2..a0d87bf6 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,9 @@ Unreleased, experimental changes tzselect no longer mishandles ISO 6709 coordinates when using an awk that does not support newlines in -v option-arguments. + tzselect no longer mishandles TZ strings when using mawk 1.4.3, + which mishandles regular expressions of the form /X{2,}/. + zic no longer mishandles data for Palestine after the year 2075. Previously, it incorrectly omitted post-2075 transitions that are predicted for just before and just after Ramadan. (Thanks to Ken diff --git a/tzselect.ksh b/tzselect.ksh index 1bef35ec..ffcec71b 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -425,6 +425,24 @@ while case $continent in TZ) # Ask the user for a POSIX TZ string. Check that it conforms. + check_POSIX_TZ_string='BEGIN { + tz = substr(ARGV[1], 2) + ARGV[1] = "" + tzname = ("(<[[:alnum:]+-][[:alnum:]+-][[:alnum:]+-]+>" \ + "|[[:alpha:]][[:alpha:]][[:alpha:]]+)") + time = ("(2[0-4]|[0-1]?[0-9])" \ + "(:[0-5][0-9](:[0-5][0-9])?)?") + offset = "[-+]?" time + mdate = "M([1-9]|1[0-2])\\.[1-5]\\.[0-6]" + jdate = ("((J[1-9]|[0-9]|J?[1-9][0-9]" \ + "|J?[1-2][0-9][0-9])|J?3[0-5][0-9]|J?36[0-5])") + datetime = ",(" mdate "|" jdate ")(/" time ")?" + tzpattern = ("^(:.*|" tzname offset "(" tzname \ + "(" offset ")?(" datetime datetime ")?)?)$") + if (tz ~ tzpattern) exit 1 + exit 0 + }' + while echo >&2 'Please enter the desired value' \ 'of the TZ environment variable.' @@ -433,22 +451,7 @@ while echo >&2 'ahead (east) of Greenwich,' \ 'with no daylight saving time.' read tz - $AWK 'BEGIN { - tz = substr(ARGV[1], 2) - ARGV[1] = "" - tzname = "(<[[:alnum:]+-]{3,}>|[[:alpha:]]{3,})" - time = "(2[0-4]|[0-1]?[0-9])" \ - "(:[0-5][0-9](:[0-5][0-9])?)?" - offset = "[-+]?" time - mdate = "M([1-9]|1[0-2])\\.[1-5]\\.[0-6]" - jdate = "((J[1-9]|[0-9]|J?[1-9][0-9]" \ - "|J?[1-2][0-9][0-9])|J?3[0-5][0-9]|J?36[0-5])" - datetime = ",(" mdate "|" jdate ")(/" time ")?" - tzpattern = "^(:.*|" tzname offset "(" tzname \ - "(" offset ")?(" datetime datetime ")?)?)$" - if (tz ~ tzpattern) exit 1 - exit 0 - }' ="$tz" + $AWK "$check_POSIX_TZ_string" ="$tz" do say >&2 "'$tz' is not a conforming POSIX timezone string." done -- 2.40.1