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

This makes the test depsrc-optional independent from the current time
zone.
This commit is contained in:
rillig 2020-12-18 14:46:44 +00:00
parent 6e3f82b272
commit d80c99b6f3
3 changed files with 13 additions and 14 deletions

View File

@ -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",

View File

@ -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;
}

View File

@ -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