summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-02-02 13:47:49 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-02-02 13:47:49 +0000
commit89cfbc73b83ac826bd95ad3336d0d9d7cee0d517 (patch)
tree52a45f86e9a29a5c10005b18695f535cde12dcf7 /usr.bin
parent6ead3373fdd3f136aefedec5ee2e05f125596a5a (diff)
Bug-fix: make should behave sensibly when presented with negative times...
- let *_MTime return booleans, as that's what they're used for, the time_t is set as a side effect. - use OUT_OF_DATE for a date starting point, set it at the origin of time.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/arch.c49
-rw-r--r--usr.bin/make/compat.c6
-rw-r--r--usr.bin/make/dir.c22
-rw-r--r--usr.bin/make/dir.h4
-rw-r--r--usr.bin/make/extern.h6
-rw-r--r--usr.bin/make/main.c6
-rw-r--r--usr.bin/make/make.c22
-rw-r--r--usr.bin/make/make.h4
-rw-r--r--usr.bin/make/targ.c8
9 files changed, 68 insertions, 59 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index e5239a48719..81127ebc320 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arch.c,v 1.24 2000/01/08 09:45:15 espie Exp $ */
+/* $OpenBSD: arch.c,v 1.25 2000/02/02 13:47:46 espie Exp $ */
/* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: arch.c,v 1.24 2000/01/08 09:45:15 espie Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.25 2000/02/02 13:47:46 espie Exp $";
#endif
#endif /* not lint */
@@ -73,9 +73,9 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.24 2000/01/08 09:45:15 espie Exp $";
* of the library's table of contents.
*
* Arch_MTime Find the modification time of a member of
- * an archive *in the archive*. The time is also
- * placed in the member's GNode. Returns the
- * modification time.
+ * an archive *in the archive*, return TRUE if
+ * exists. The time is placed in the member's
+ * GNode. Returns the modification time.
*
* Arch_MemTime Find the modification time of a member of
* an archive. Called when the member doesn't
@@ -995,7 +995,7 @@ Arch_TouchLib (gn)
* Return the modification time of a member of an archive.
*
* Results:
- * The modification time (seconds).
+ * TRUE if found.
*
* Side Effects:
* The mtime field of the given node is filled in with the value
@@ -1003,7 +1003,7 @@ Arch_TouchLib (gn)
*
*-----------------------------------------------------------------------
*/
-time_t
+Boolean
Arch_MTime (gn)
GNode *gn; /* Node describing archive member */
{
@@ -1014,13 +1014,12 @@ Arch_MTime (gn)
Var_Value(MEMBER, gn),
TRUE);
if (arhPtr != NULL) {
- modTime = (time_t) strtol(arhPtr->ar_date, NULL, 10);
+ gn->mtime = (time_t) strtol(arhPtr->ar_date, NULL, 10);
+ return TRUE;
} else {
- modTime = 0;
+ gn->mtime = OUT_OF_DATE;
+ return FALSE;
}
-
- gn->mtime = modTime;
- return (modTime);
}
/*-
@@ -1030,14 +1029,14 @@ Arch_MTime (gn)
* time from its archived form, if it exists.
*
* Results:
- * The modification time.
+ * TRUE if found.
*
* Side Effects:
* The mtime field is filled in.
*
*-----------------------------------------------------------------------
*/
-time_t
+Boolean
Arch_MemMTime (gn)
GNode *gn;
{
@@ -1047,8 +1046,8 @@ Arch_MemMTime (gn)
*nameEnd;
if (Lst_Open (gn->parents) != SUCCESS) {
- gn->mtime = 0;
- return (0);
+ gn->mtime = OUT_OF_DATE;
+ return FALSE;
}
while ((ln = Lst_Next (gn->parents)) != NULL) {
pgn = (GNode *) Lst_Datum (ln);
@@ -1070,21 +1069,24 @@ Arch_MemMTime (gn)
if (pgn->make && nameEnd != NULL &&
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) {
- gn->mtime = Arch_MTime(pgn);
+ if (Arch_MTime(pgn))
+ gn->mtime = pgn->mtime;
+ else
+ gn->mtime = OUT_OF_DATE;
}
} else if (pgn->make) {
/*
* Something which isn't a library depends on the existence of
* this target, so it needs to exist.
*/
- gn->mtime = 0;
+ gn->mtime = OUT_OF_DATE;
break;
}
}
Lst_Close (gn->parents);
- return (gn->mtime);
+ return gn->mtime == OUT_OF_DATE;
}
/*-
@@ -1172,17 +1174,18 @@ Arch_LibOODate (gn)
if (OP_NOP(gn->type) && Lst_IsEmpty(gn->children)) {
oodate = FALSE;
- } else if ((gn->mtime > now) || (gn->mtime < gn->cmtime) || !gn->mtime) {
- oodate = TRUE;
+ } else if (gn->mtime > now || gn->mtime < gn->cmtime ||
+ gn->mtime == OUT_OF_DATE) {
+ oodate = TRUE;
} else {
#ifdef RANLIBMAG
struct ar_hdr *arhPtr; /* Header for __.SYMDEF */
- int modTimeTOC; /* The table-of-contents's mod time */
+ time_t modTimeTOC; /* The table-of-contents's mod time */
arhPtr = ArchStatMember (gn->path, RANLIBMAG, FALSE);
if (arhPtr != NULL) {
- modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
+ modTimeTOC = (time_t) strtol(arhPtr->ar_date, NULL, 10);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index f23713bc9a8..a0d74215a1c 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compat.c,v 1.21 2000/02/01 03:23:32 deraadt Exp $ */
+/* $OpenBSD: compat.c,v 1.22 2000/02/02 13:47:47 espie Exp $ */
/* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: compat.c,v 1.21 2000/02/01 03:23:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: compat.c,v 1.22 2000/02/02 13:47:47 espie Exp $";
#endif
#endif /* not lint */
@@ -588,7 +588,7 @@ CompatMake (gnp, pgnp)
* ok.
* -- ardeb 1/12/88
*/
- if (noExecute || Dir_MTime(gn) == 0) {
+ if (noExecute || Dir_MTime(gn) == FALSE) {
gn->mtime = now;
}
if (gn->cmtime > gn->mtime)
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 79da0bf429a..7744735a18f 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.15 2000/01/25 20:52:15 espie Exp $ */
+/* $OpenBSD: dir.c,v 1.16 2000/02/02 13:47:47 espie Exp $ */
/* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: dir.c,v 1.15 2000/01/25 20:52:15 espie Exp $";
+static char rcsid[] = "$OpenBSD: dir.c,v 1.16 2000/02/02 13:47:47 espie Exp $";
#endif
#endif /* not lint */
@@ -68,7 +68,7 @@ static char rcsid[] = "$OpenBSD: dir.c,v 1.15 2000/01/25 20:52:15 espie Exp $";
* If it exists, the entire path is returned.
* Otherwise NULL is returned.
*
- * Dir_MTime Return the modification time of a node. The file
+ * Dir_MTime Return TRUE if node exists. The file
* is searched for along the default search path.
* The path and mtime fields of the node are filled
* in.
@@ -977,7 +977,7 @@ Dir_FindFile (name, path)
* search path dirSearchPath.
*
* Results:
- * The modification time or 0 if it doesn't exist
+ * TRUE if file exists.
*
* Side Effects:
* The modification time is placed in the node's mtime slot.
@@ -985,7 +985,7 @@ Dir_FindFile (name, path)
* found one for it, the full name is placed in the path slot.
*-----------------------------------------------------------------------
*/
-int
+Boolean
Dir_MTime (gn)
GNode *gn; /* the file whose modification time is
* desired */
@@ -993,6 +993,7 @@ Dir_MTime (gn)
char *fullName; /* the full pathname of name */
struct stat stb; /* buffer for finding the mod time */
Hash_Entry *entry;
+ Boolean exists;
if (gn->type & OP_ARCHV) {
return Arch_MTime (gn);
@@ -1019,18 +1020,21 @@ Dir_MTime (gn)
}
stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
Hash_DeleteEntry(&mtimes, entry);
+ exists = TRUE;
} else if (stat (fullName, &stb) == 0) {
/* XXX forces make to differentiate between the epoch and
* non-existent files by kludging the timestamp slightly. */
- if (stb.st_mtime == 0)
- stb.st_mtime = 1;
+ if (stb.st_mtime == OUT_OF_DATE)
+ stb.st_mtime++;
+ exists = TRUE;
} else {
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);
return Arch_MemMTime (gn);
} else {
- stb.st_mtime = 0;
+ stb.st_mtime = OUT_OF_DATE;
+ exists = FALSE;
}
}
if (fullName && gn->path == (char *)NULL) {
@@ -1038,7 +1042,7 @@ Dir_MTime (gn)
}
gn->mtime = stb.st_mtime;
- return (gn->mtime);
+ return exists;
}
/*-
diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h
index f1351500112..077530d4d63 100644
--- a/usr.bin/make/dir.h
+++ b/usr.bin/make/dir.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.h,v 1.4 1998/12/05 00:06:27 espie Exp $ */
+/* $OpenBSD: dir.h,v 1.5 2000/02/02 13:47:47 espie Exp $ */
/* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
@@ -60,7 +60,7 @@ void Dir_End __P((void));
Boolean Dir_HasWildcards __P((char *));
void Dir_Expand __P((char *, Lst, Lst));
char *Dir_FindFile __P((char *, Lst));
-int Dir_MTime __P((GNode *));
+Boolean Dir_MTime __P((GNode *));
void Dir_AddDir __P((Lst, char *));
char *Dir_MakeFlags __P((char *, Lst));
void Dir_ClearPath __P((Lst));
diff --git a/usr.bin/make/extern.h b/usr.bin/make/extern.h
index a647b22c90f..c0f3ecee080 100644
--- a/usr.bin/make/extern.h
+++ b/usr.bin/make/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.18 2000/01/08 09:45:15 espie Exp $ */
+/* $OpenBSD: extern.h,v 1.19 2000/02/02 13:47:47 espie Exp $ */
/* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */
/*-
@@ -45,8 +45,8 @@
ReturnStatus Arch_ParseArchive __P((char **, Lst, GNode *));
void Arch_Touch __P((GNode *));
void Arch_TouchLib __P((GNode *));
-time_t Arch_MTime __P((GNode *));
-time_t Arch_MemMTime __P((GNode *));
+Boolean Arch_MTime __P((GNode *));
+Boolean Arch_MemMTime __P((GNode *));
void Arch_FindLib __P((GNode *, Lst));
Boolean Arch_LibOODate __P((GNode *));
void Arch_Init __P((void));
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index f602dac7b5f..a3a32825442 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.27 1999/12/19 00:04:25 espie Exp $ */
+/* $OpenBSD: main.c,v 1.28 2000/02/02 13:47:47 espie Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
@@ -49,7 +49,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.27 1999/12/19 00:04:25 espie Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.28 2000/02/02 13:47:47 espie Exp $";
#endif
#endif /* not lint */
@@ -113,7 +113,7 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.27 1999/12/19 00:04:25 espie Exp $";
#define MAKEFLAGS ".MAKEFLAGS"
Lst create; /* Targets to be made */
-time_t now; /* Time at start of make */
+time_t now = OUT_OF_DATE;/* Time at start of make */
GNode *DEFAULT; /* .DEFAULT node */
Boolean allPrecious; /* .PRECIOUS given on line by itself */
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index a539d643a28..59b29bf3126 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: make.c,v 1.12 1999/12/18 21:58:07 espie Exp $ */
+/* $OpenBSD: make.c,v 1.13 2000/02/02 13:47:48 espie Exp $ */
/* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: make.c,v 1.12 1999/12/18 21:58:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: make.c,v 1.13 2000/02/02 13:47:48 espie Exp $";
#endif
#endif /* not lint */
@@ -163,7 +163,7 @@ Make_OODate (gn)
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
(void) Dir_MTime (gn);
if (DEBUG(MAKE)) {
- if (gn->mtime != 0) {
+ if (gn->mtime != OUT_OF_DATE) {
printf ("modified %s...", Targ_FmtTime(gn->mtime));
} else {
printf ("non-existent...");
@@ -204,7 +204,7 @@ Make_OODate (gn)
*/
oodate = Arch_LibOODate (gn) ||
- ((gn->cmtime == 0) && (gn->type & OP_DOUBLEDEP));
+ (gn->cmtime == OUT_OF_DATE && (gn->type & OP_DOUBLEDEP));
} else if (gn->type & OP_JOIN) {
/*
* A target with the .JOIN attribute is only considered
@@ -229,21 +229,21 @@ Make_OODate (gn)
}
}
oodate = TRUE;
- } else if ((gn->mtime < gn->cmtime) ||
- ((gn->cmtime == 0) &&
- ((gn->mtime==0) || (gn->type & OP_DOUBLEDEP))))
+ } else if (gn->mtime < gn->cmtime ||
+ (gn->cmtime == OUT_OF_DATE &&
+ (gn->mtime == OUT_OF_DATE || (gn->type & OP_DOUBLEDEP))))
{
/*
* A node whose modification time is less than that of its
- * youngest child or that has no children (cmtime == 0) and
- * either doesn't exist (mtime == 0) or was the object of a
+ * youngest child or that has no children (cmtime == OUT_OF_DATE) and
+ * either doesn't exist (mtime == OUT_OF_DATE) or was the object of a
* :: operator is out-of-date. Why? Because that's the way Make does
* it.
*/
if (DEBUG(MAKE)) {
if (gn->mtime < gn->cmtime) {
printf("modified before source...");
- } else if (gn->mtime == 0) {
+ } else if (gn->mtime == OUT_OF_DATE) {
printf("non-existent and no sources...");
} else {
printf(":: operator and no sources...");
@@ -472,7 +472,7 @@ Make_Update (cgn)
* the target is made now. Otherwise archives with ... rules
* don't work!
*/
- if (noExecute || (cgn->type & OP_SAVE_CMDS) || Dir_MTime(cgn) == 0) {
+ if (noExecute || (cgn->type & OP_SAVE_CMDS) || Dir_MTime(cgn) == FALSE) {
cgn->mtime = now;
}
if (DEBUG(MAKE)) {
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 46904d70b87..14c76caebf0 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: make.h,v 1.16 1999/12/18 21:53:32 espie Exp $ */
+/* $OpenBSD: make.h,v 1.17 2000/02/02 13:47:48 espie Exp $ */
/* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */
/*
@@ -84,6 +84,8 @@
#include "config.h"
#include "buf.h"
+#define OUT_OF_DATE INT_MIN
+
/*-
* The structure for an individual graph node. Each node has several
* pieces of data associated with it.
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index f181f8af2d9..4206684fdb6 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: targ.c,v 1.13 1999/12/18 21:58:08 espie Exp $ */
+/* $OpenBSD: targ.c,v 1.14 2000/02/02 13:47:48 espie Exp $ */
/* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-static char *rcsid = "$OpenBSD: targ.c,v 1.13 1999/12/18 21:58:08 espie Exp $";
+static char *rcsid = "$OpenBSD: targ.c,v 1.14 2000/02/02 13:47:48 espie Exp $";
#endif
#endif /* not lint */
@@ -183,7 +183,7 @@ Targ_NewGN (name)
gn->made = UNMADE;
gn->childMade = FALSE;
gn->order = 0;
- gn->mtime = gn->cmtime = 0;
+ gn->mtime = gn->cmtime = OUT_OF_DATE;
gn->iParents = Lst_Init();
gn->cohorts = Lst_Init();
gn->parents = Lst_Init();
@@ -560,7 +560,7 @@ TargPrintNode (gnp, passp)
printf("# No unmade children\n");
}
if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
- if (gn->mtime != 0) {
+ if (gn->mtime != OUT_OF_DATE) {
printf("# last modified %s: %s\n",
Targ_FmtTime(gn->mtime),
(gn->made == UNMADE ? "unmade" :