From c9634e908df2787d439325fefa78ea8109e0e3a7 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Fri, 26 Jun 2020 13:07:51 +0200 Subject: [PATCH] tmdata: prioritise "UTC" over "GMT" "UTC" is the modern name for what used to be "GMT", but ksh still preferred GMT. On systems configured to use the UTC time zone, this caused a 'printf %T' regression test failure in tests/builtins.sh as the external 'data' utility will prefer UTC these days. src/lib/libast/tm/tmdata.c: - Reorder the name alternatives for UTC/GMT so that UTC is the first preference. src/cmd/ksh93/tests/builtins.sh: - Report expected and actual values on 'printf %T' failure. Related: #6 --- src/cmd/ksh93/tests/builtins.sh | 7 ++++--- src/lib/libast/tm/tmdata.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index 17230d1ad..c1bc4a435 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -310,9 +310,10 @@ then err_exit "printf '%..*s' not working" fi [[ $(printf '%q\n') == '' ]] || err_exit 'printf "%q" with missing arguments' # we won't get hit by the one second boundary twice, right? -[[ $(LC_ALL=C printf '%T\n' now) == "$(LC_ALL=C date)" ]] || -[[ $(LC_ALL=C printf '%T\n' now) == "$(LC_ALL=C date)" ]] || -err_exit 'printf "%T" now' +expect= actual= +{ expect=$(LC_ALL=C date) && actual=$(LC_ALL=C printf '%T\n' now) && [[ $actual == "$expect" ]]; } || +{ expect=$(LC_ALL=C date) && actual=$(LC_ALL=C printf '%T\n' now) && [[ $actual == "$expect" ]]; } || +err_exit 'printf "%T" now' "(expected $(printf %q "$expect"), got $(printf %q "$actual"))" behead() { read line diff --git a/src/lib/libast/tm/tmdata.c b/src/lib/libast/tm/tmdata.c index 4ffd2453d..33e3beca8 100644 --- a/src/lib/libast/tm/tmdata.c +++ b/src/lib/libast/tm/tmdata.c @@ -54,7 +54,7 @@ static char* format[] = "AM", "PM", - "GMT", "UTC", "UCT", "CUT", + "UTC", "UCT", "CUT", "GMT", "DST", "", "", "", @@ -233,10 +233,10 @@ static Tm_leap_t leap[] = static Tm_zone_t zone[] = { - 0, "GMT", 0, ( 0 * 60), 0, /* UTC */ - 0, "UCT", 0, ( 0 * 60), 0, /* UTC */ 0, "UTC", 0, ( 0 * 60), 0, /* UTC */ + 0, "UCT", 0, ( 0 * 60), 0, /* UTC */ 0, "CUT", 0, ( 0 * 60), 0, /* UTC */ + 0, "GMT", 0, ( 0 * 60), 0, /* UTC */ 0, "Z", 0, ( 0 * 60), 0, /* UTC */ "USA", "HST", 0, (10 * 60), 0, /* Hawaii */ 0, "YST", "YDT", ( 9 * 60), TM_DST, /* Yukon */