Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): use symbolic time for 0 in Make_Recheck



details:   https://anonhg.NetBSD.org/src/rev/7b959e0544a2
branches:  trunk
changeset: 947573:7b959e0544a2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 18 14:46:44 2020 +0000

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

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

diffstat:

 usr.bin/make/make.c                         |   7 ++++---
 usr.bin/make/targ.c                         |  12 +++++-------
 usr.bin/make/unit-tests/depsrc-optional.exp |   8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diffs (88 lines):

diff -r 9eb2585cfea2 -r 7b959e0544a2 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Fri Dec 18 14:36:46 2020 +0000
+++ b/usr.bin/make/make.c       Fri Dec 18 14:46:44 2020 +0000
@@ -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 @@
        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",
diff -r 9eb2585cfea2 -r 7b959e0544a2 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Fri Dec 18 14:36:46 2020 +0000
+++ b/usr.bin/make/targ.c       Fri Dec 18 14:46:44 2020 +0000
@@ -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 @@
 
 /*
  * 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;
 }
diff -r 9eb2585cfea2 -r 7b959e0544a2 usr.bin/make/unit-tests/depsrc-optional.exp
--- a/usr.bin/make/unit-tests/depsrc-optional.exp       Fri Dec 18 14:36:46 2020 +0000
+++ b/usr.bin/make/unit-tests/depsrc-optional.exp       Fri Dec 18 14:46:44 2020 +0000
@@ -8,13 +8,13 @@
 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



Home | Main Index | Thread Index | Old Index