Module Name:    src
Committed By:   rillig
Date:           Fri Dec 18 14:46:44 UTC 2020

Modified Files:
        src/usr.bin/make: make.c targ.c
        src/usr.bin/make/unit-tests: depsrc-optional.exp

Log Message:
make(1): use symbolic time for 0 in Make_Recheck

This makes the test depsrc-optional independent from the current time
zone.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/make.c
cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/targ.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-optional.exp

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/make.c
diff -u src/usr.bin/make/make.c:1.229 src/usr.bin/make/make.c:1.230
--- src/usr.bin/make/make.c:1.229	Tue Dec 15 20:17:08 2020
+++ src/usr.bin/make/make.c	Fri Dec 18 14:46:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.229 2020/12/15 20:17:08 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.230 2020/12/18 14:46:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -102,7 +102,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.229 2020/12/15 20:17:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.230 2020/12/18 14:46:44 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -539,7 +539,8 @@ Make_Recheck(GNode *gn)
 	if (!GNode_ShouldExecute(gn) || (gn->type & OP_SAVE_CMDS) ||
 	    (mtime == 0 && !(gn->type & OP_WAIT))) {
 		DEBUG2(MAKE, " recheck(%s): update time from %s to now\n",
-		    gn->name, Targ_FmtTime(gn->mtime));
+		    gn->name,
+		    gn->mtime == 0 ? "nonexistent" : Targ_FmtTime(gn->mtime));
 		gn->mtime = now;
 	} else {
 		DEBUG2(MAKE, " recheck(%s): current update time: %s\n",

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.157 src/usr.bin/make/targ.c:1.158
--- src/usr.bin/make/targ.c:1.157	Fri Dec 18 14:36:46 2020
+++ src/usr.bin/make/targ.c	Fri Dec 18 14:46:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.157 2020/12/18 14:36:46 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.158 2020/12/18 14:46:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.157 2020/12/18 14:36:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.158 2020/12/18 14:46:44 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -401,17 +401,15 @@ Targ_PrintCmds(GNode *gn)
 
 /*
  * Format a modification time in some reasonable way and return it.
- * The time is placed in a static area, so it is overwritten with each call.
+ * The formatted time is placed in a static area, so it is overwritten
+ * with each call.
  */
 const char *
 Targ_FmtTime(time_t tm)
 {
-	struct tm *parts;
 	static char buf[128];
 
-	/* TODO: Add special case for 0, which often means ENOENT, to make it
-	 * independent from time zones. */
-	parts = localtime(&tm);
+	struct tm *parts = localtime(&tm);
 	(void)strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
 	return buf;
 }

Index: src/usr.bin/make/unit-tests/depsrc-optional.exp
diff -u src/usr.bin/make/unit-tests/depsrc-optional.exp:1.5 src/usr.bin/make/unit-tests/depsrc-optional.exp:1.6
--- src/usr.bin/make/unit-tests/depsrc-optional.exp:1.5	Sun Nov  8 11:05:58 2020
+++ src/usr.bin/make/unit-tests/depsrc-optional.exp	Fri Dec 18 14:46:44 2020
@@ -8,13 +8,13 @@ Make_ExpandUse: examine optional-cohort
 Examining optional...non-existent...up-to-date.
 Examining optional-cohort...non-existent...:: operator and no sources...out-of-date.
 : A leaf node using '::' is considered out-of-date.
- recheck(optional-cohort): update time from  0:00:00 Jan 01, 1970 to now
+ recheck(optional-cohort): update time from nonexistent to now
 Examining important...non-existent...modified before source "optional-cohort"...out-of-date.
 : important is made.
- recheck(important): update time from  0:00:00 Jan 01, 1970 to now
+ recheck(important): update time from nonexistent to now
 Examining all...non-existent...modified before source "important"...out-of-date.
 : all is made.
- recheck(all): update time from  0:00:00 Jan 01, 1970 to now
+ recheck(all): update time from nonexistent to now
 Examining .END...non-existent...non-existent and no sources...out-of-date.
- recheck(.END): update time from  0:00:00 Jan 01, 1970 to now
+ recheck(.END): update time from nonexistent to now
 exit status 0

Reply via email to