Module Name:    src
Committed By:   rillig
Date:           Sat Aug 19 11:53:10 UTC 2023

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: varmod-gmtime.mk

Log Message:
make: clean up comments regarding gmtime/strftime

These two functions are not supposed to be used together, thus it is not
a bug if combining them produces unexpected results.


To generate a diff of this commit:
cvs rdiff -u -r1.1062 -r1.1063 src/usr.bin/make/var.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-gmtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1062 src/usr.bin/make/var.c:1.1063
--- src/usr.bin/make/var.c:1.1062	Sat Aug 19 11:13:35 2023
+++ src/usr.bin/make/var.c	Sat Aug 19 11:53:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1062 2023/08/19 11:13:35 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1063 2023/08/19 11:53:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1062 2023/08/19 11:13:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1063 2023/08/19 11:53:10 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1887,11 +1887,7 @@ FormatTime(const char *fmt, time_t t, bo
 	if (*fmt == '\0')
 		fmt = "%c";
 	if (gmt) {
-		/*
-		 * Work around a buggy 'strftime' implementation on at least
-		 * NetBSD 10 and Linux/glibc-2.31, on which the value of '%s'
-		 * depends on the timezone from TZ; see varmod-gmtime.mk.
-		 */
+		/* strftime only works with localtime, not with gmtime. */
 		const char *prev_tz_env = getenv("TZ");
 		char *prev_tz = prev_tz_env != NULL
 		    ? bmake_strdup(prev_tz_env) : NULL;

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.18 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.18	Sat Aug 19 11:13:36 2023
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Sat Aug 19 11:53:10 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.18 2023/08/19 11:13:36 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.19 2023/08/19 11:53:10 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -147,53 +147,7 @@
 
 
 # Before var.c 1.1062 from 2023-08-19, ':gmtime' but not ':localtime' reported
-# wrong values for '%s', depending on the operating system and the timezone,
-# as demonstrated by the following test program:
-#
-#	for mod in gmtime localtime; do
-#		for tz in UTC Europe/Berlin America/Los_Angeles; do
-#			TZ=$tz ./make -r -f /dev/null -v "\${%F %T %z %s $mod $tz:L:$mod}"
-#		done
-#	done
-#
-# Cygwin:
-# 2023-08-19 07:34:06 +0000 1692430446 gmtime UTC
-# 2023-08-19 07:34:06 +0000 1692430446 gmtime Europe/Berlin
-# 2023-08-19 07:34:06 +0000 1692430446 gmtime America/Los_Angeles
-# 2023-08-19 07:34:06 +0000 1692430446 localtime UTC
-# 2023-08-19 09:34:07 +0200 1692430447 localtime Europe/Berlin
-# 2023-08-19 00:34:07 -0700 1692430447 localtime America/Los_Angeles
-#
-# Looks good:
-#	* ':gmtime' consistently reports timezone offset '+0000'.
-#	* '%s' is independent of the timezone.
-#
-# NetBSD 10.99:
-# 2023-08-19 07:34:37 +0000 1692430477 gmtime UTC
-# 2023-08-19 07:34:37 +0100 1692426877 gmtime Europe/Berlin
-# 2023-08-19 07:34:37 -0800 1692459277 gmtime America/Los_Angeles
-# 2023-08-19 07:34:37 +0000 1692430477 localtime UTC
-# 2023-08-19 09:34:37 +0200 1692430477 localtime Europe/Berlin
-# 2023-08-19 00:34:37 -0700 1692430477 localtime America/Los_Angeles
-#
-# Looks bad:
-#	* ':gmtime' reports different timezone offsets.
-#	* ':gmtime' reports different seconds since the Epoch.
-#	* ':gmtime' reports the timezone offset '+0100' for Europe/Berlin,
-#	  even though at 2023-08-19, DST with offset '+0200' was in place.
-#
-# Debian:
-# 2023-08-19 07:29:10 +0000 1692430150 gmtime UTC
-# 2023-08-19 07:29:10 +0000 1692426550 gmtime Europe/Berlin
-# 2023-08-19 07:29:10 +0000 1692458950 gmtime America/Los_Angeles
-# 2023-08-19 07:29:10 +0000 1692430150 localtime UTC
-# 2023-08-19 09:29:10 +0200 1692430150 localtime Europe/Berlin
-# 2023-08-19 00:29:10 -0700 1692430150 localtime America/Los_Angeles
-#
-# Looks mixed:
-#	* ':gmtime' reports the correct timezone offset '+0000'.
-#	* ':gmtime' reports different seconds since the Epoch, and the '%s'
-#	  value cannot be derived from the '%F %T %z' values.
+# wrong values for '%s', depending on the operating system and the timezone.
 export TZ=UTC
 .for t in ${%s:L:gmtime} ${%s:L:localtime}
 TIMESTAMPS+= $t

Reply via email to