Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Fix major bug in make(1) ... due to shadowing o...
details: https://anonhg.NetBSD.org/src/rev/b1e87cecf1f1
branches: trunk
changeset: 521245:b1e87cecf1f1
user: reinoud <reinoud%NetBSD.org@localhost>
date: Sun Jan 27 01:50:54 2002 +0000
description:
Fix major bug in make(1) ... due to shadowing of the dotLast path used for
the .DOTLAST primitive by a boolean variable with the same name, this whole
mechanism was broken ... it doesn't save much stat calls but it was wrong.
Thanks to Jason Thorpe for the other shadow-variable fixing patches he
made.
diffstat:
usr.bin/make/Makefile | 3 ++-
usr.bin/make/compat.c | 16 ++++++++--------
usr.bin/make/dir.c | 23 +++++++++++------------
usr.bin/make/main.c | 16 ++++++++--------
usr.bin/make/make.c | 7 +++----
usr.bin/make/parse.c | 19 ++++++++-----------
usr.bin/make/suff.c | 7 +++----
usr.bin/make/targ.c | 12 ++++++------
usr.bin/make/trace.c | 12 ++++++------
usr.bin/make/util.c | 8 ++++----
usr.bin/make/var.c | 14 +++++++-------
11 files changed, 66 insertions(+), 71 deletions(-)
diffs (truncated from 521 to 300 lines):
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/Makefile
--- a/usr.bin/make/Makefile Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/Makefile Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.25 2001/10/31 03:59:42 tv Exp $
+# $NetBSD: Makefile,v 1.26 2002/01/27 01:50:54 reinoud Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
CPPFLAGS+= -I${.CURDIR}
@@ -11,6 +11,7 @@
lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \
lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
.PATH: ${.CURDIR}/lst.lib
+WARNS=2
WFORMAT= 1
.if make(install)
SUBDIR= PSD.doc
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/compat.c Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.36 2001/10/16 18:50:12 sjg Exp $ */
+/* $NetBSD: compat.c,v 1.37 2002/01/27 01:50:54 reinoud Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: compat.c,v 1.36 2001/10/16 18:50:12 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.37 2002/01/27 01:50:54 reinoud Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.36 2001/10/16 18:50:12 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.37 2002/01/27 01:50:54 reinoud Exp $");
#endif
#endif /* not lint */
#endif
@@ -162,7 +162,7 @@
int reason; /* Reason for child's death */
int status; /* Description of child's death */
int cpid; /* Child actually found */
- ReturnStatus stat; /* Status of fork */
+ ReturnStatus retstat; /* Status of fork */
LstNode cmdNode; /* Node where current command is located */
char **av; /* Argument vector for thing to exec */
int argc; /* Number of arguments in av or 0 if not
@@ -304,13 +304,13 @@
*/
while (1) {
- while ((stat = wait(&reason)) != cpid) {
- if (stat == -1 && errno != EINTR) {
+ while ((retstat = wait(&reason)) != cpid) {
+ if (retstat == -1 && errno != EINTR) {
break;
}
}
- if (stat > -1) {
+ if (retstat > -1) {
if (WIFSTOPPED(reason)) {
status = WSTOPSIG(reason); /* stopped */
} else if (WIFEXITED(reason)) {
@@ -345,7 +345,7 @@
}
break;
} else {
- Fatal ("error in wait: %d: %s", stat, strerror(errno));
+ Fatal ("error in wait: %d: %s", retstat, strerror(errno));
/*NOTREACHED*/
}
}
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/dir.c Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.30 2002/01/26 22:36:41 christos Exp $ */
+/* $NetBSD: dir.c,v 1.31 2002/01/27 01:50:54 reinoud Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: dir.c,v 1.30 2002/01/26 22:36:41 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.31 2002/01/27 01:50:54 reinoud Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.30 2002/01/26 22:36:41 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.31 2002/01/27 01:50:54 reinoud Exp $");
#endif
#endif /* not lint */
#endif
@@ -940,7 +940,7 @@
register char *file; /* the current filename to check */
register Path *p; /* current path member */
register char *cp; /* index of first slash, if any */
- Boolean lastDot = FALSE; /* true we should search dot last */
+ Boolean hasLastDot = FALSE; /* true we should search dot last */
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
Hash_Entry *entry; /* Entry for mtimes table */
@@ -972,10 +972,9 @@
if ((ln = Lst_First (path)) != NILLNODE) {
p = (Path *) Lst_Datum (ln);
- if (p == dotLast)
- lastDot = TRUE;
- if (DEBUG(DIR)) {
- printf("[dot last]...");
+ if (p == dotLast) {
+ hasLastDot = TRUE;
+ if (DEBUG(DIR)) printf("[dot last]...");
}
}
@@ -986,7 +985,7 @@
* (fish.c) and what pmake finds (./fish.c).
* Unless we found the magic DOTLAST path...
*/
- if (!lastDot && name[0] != '/')
+ if (!hasLastDot && name[0] != '/')
if ((file = DirFindDot(hasSlash, name, cp)) != NULL)
return file;
@@ -1012,7 +1011,7 @@
}
Lst_Close (path);
- if (lastDot && name[0] != '/')
+ if (hasLastDot && name[0] != '/')
if ((file = DirFindDot(hasSlash, name, cp)) != NULL)
return file;
@@ -1043,7 +1042,7 @@
printf("failed. Trying subdirectories...");
}
- if (!lastDot && cur && (file = DirLookupSubdir(cur, name)) != NULL)
+ if (!hasLastDot && cur && (file = DirLookupSubdir(cur, name)) != NULL)
return file;
(void) Lst_Open (path);
@@ -1060,7 +1059,7 @@
}
Lst_Close (path);
- if (lastDot && cur && (file = DirLookupSubdir(cur, name)) != NULL)
+ if (hasLastDot && cur && (file = DirLookupSubdir(cur, name)) != NULL)
return file;
if (DEBUG(DIR)) {
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/main.c
--- a/usr.bin/make/main.c Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/main.c Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.81 2001/12/11 20:50:58 tv Exp $ */
+/* $NetBSD: main.c,v 1.82 2002/01/27 01:50:54 reinoud Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,7 +39,7 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.81 2001/12/11 20:50:58 tv Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.82 2002/01/27 01:50:54 reinoud Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -51,7 +51,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.81 2001/12/11 20:50:58 tv Exp $");
+__RCSID("$NetBSD: main.c,v 1.82 2002/01/27 01:50:54 reinoud Exp $");
#endif
#endif /* not lint */
#endif
@@ -835,7 +835,7 @@
* <directory>:<directory>:<directory>...
*/
if (Var_Exists("VPATH", VAR_CMD)) {
- char *vpath, *path, *cp, savec;
+ char *vpath, savec;
/*
* GCC stores string constants in read-only memory, but
* Var_Subst will want to write this thing, so store it
@@ -1046,7 +1046,7 @@
int copy;
{
static char *make[4];
- static char *curdir = NULL;
+ static char *cur_dir = NULL;
char *cp, **mp;
int is_cmd, next_cmd;
int i;
@@ -1068,7 +1068,7 @@
} else
++make[0];
make[2] = NULL;
- curdir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
+ cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
}
if (ac == 0 || av == NULL)
return NULL; /* initialization only */
@@ -1135,9 +1135,9 @@
if (strcmp(cp, *mp) == 0) {
#ifdef check_cwd_debug
fprintf(stderr, " %s == '%s', chdir(%s)\n",
- cp, *mp, curdir);
+ cp, *mp, cur_dir);
#endif
- return curdir;
+ return cur_dir;
}
}
}
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/make.c
--- a/usr.bin/make/make.c Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/make.c Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $ */
+/* $NetBSD: make.c,v 1.40 2002/01/27 01:50:55 reinoud Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.40 2002/01/27 01:50:55 reinoud Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $");
+__RCSID("$NetBSD: make.c,v 1.40 2002/01/27 01:50:55 reinoud Exp $");
#endif
#endif /* not lint */
#endif
@@ -650,7 +650,6 @@
* of this node.
*/
if (Lst_Open (cgn->iParents) == SUCCESS) {
- char *p1;
char *cpref = Var_Value(PREFIX, cgn, &p1);
while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) {
diff -r 9e4680943dde -r b1e87cecf1f1 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Jan 27 01:47:59 2002 +0000
+++ b/usr.bin/make/parse.c Sun Jan 27 01:50:54 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.77 2002/01/26 20:42:14 christos Exp $ */
+/* $NetBSD: parse.c,v 1.78 2002/01/27 01:50:55 reinoud Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: parse.c,v 1.77 2002/01/26 20:42:14 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.78 2002/01/27 01:50:55 reinoud Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.77 2002/01/26 20:42:14 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.78 2002/01/27 01:50:55 reinoud Exp $");
#endif
#endif /* not lint */
#endif
@@ -1255,7 +1255,6 @@
* If it was .OBJDIR, the source is a new definition for .OBJDIR,
* and will cause make to do a new chdir to that path.
*/
- char savec;
while (*cp && !isspace ((unsigned char)*cp)) {
cp++;
}
@@ -1317,8 +1316,6 @@
}
Home |
Main Index |
Thread Index |
Old Index