summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1997-07-06 06:54:14 +0000
committerBruce Evans <bde@FreeBSD.org>1997-07-06 06:54:14 +0000
commit3e4da6f5b3dfa3b4ff9caabcbc673d721a1a9bf0 (patch)
tree3675d30d996f539ee0f33692a10a82dbc864eb89
parentea09f5e44d046037109ca9ba434e0135c27b392c (diff)
downloadsrc-test2-3e4da6f5b3dfa3b4ff9caabcbc673d721a1a9bf0.tar.gz
src-test2-3e4da6f5b3dfa3b4ff9caabcbc673d721a1a9bf0.zip
Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should already have been imported.
Notes
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=27241
-rw-r--r--usr.bin/make/Makefile8
-rw-r--r--usr.bin/make/PSD.doc/Makefile1
-rw-r--r--usr.bin/make/PSD.doc/tutorial.ms22
-rw-r--r--usr.bin/make/arch.c255
-rw-r--r--usr.bin/make/buf.c47
-rw-r--r--usr.bin/make/buf.h9
-rw-r--r--usr.bin/make/compat.c62
-rw-r--r--usr.bin/make/cond.c58
-rw-r--r--usr.bin/make/config.h46
-rw-r--r--usr.bin/make/dir.c112
-rw-r--r--usr.bin/make/dir.h8
-rw-r--r--usr.bin/make/for.c33
-rw-r--r--usr.bin/make/hash.c34
-rw-r--r--usr.bin/make/hash.h28
-rw-r--r--usr.bin/make/job.c1661
-rw-r--r--usr.bin/make/job.h20
-rw-r--r--usr.bin/make/list.h40
-rw-r--r--usr.bin/make/lst.h13
-rw-r--r--usr.bin/make/lst.lib/lstAppend.c22
-rw-r--r--usr.bin/make/lst.lib/lstAtEnd.c12
-rw-r--r--usr.bin/make/lst.lib/lstAtFront.c10
-rw-r--r--usr.bin/make/lst.lib/lstClose.c10
-rw-r--r--usr.bin/make/lst.lib/lstConcat.c12
-rw-r--r--usr.bin/make/lst.lib/lstDatum.c8
-rw-r--r--usr.bin/make/lst.lib/lstDeQueue.c12
-rw-r--r--usr.bin/make/lst.lib/lstDestroy.c12
-rw-r--r--usr.bin/make/lst.lib/lstDupl.c12
-rw-r--r--usr.bin/make/lst.lib/lstEnQueue.c10
-rw-r--r--usr.bin/make/lst.lib/lstFind.c8
-rw-r--r--usr.bin/make/lst.lib/lstFindFrom.c16
-rw-r--r--usr.bin/make/lst.lib/lstFirst.c8
-rw-r--r--usr.bin/make/lst.lib/lstForEach.c8
-rw-r--r--usr.bin/make/lst.lib/lstForEachFrom.c25
-rw-r--r--usr.bin/make/lst.lib/lstInit.c14
-rw-r--r--usr.bin/make/lst.lib/lstInsert.c24
-rw-r--r--usr.bin/make/lst.lib/lstInt.h7
-rw-r--r--usr.bin/make/lst.lib/lstIsAtEnd.c8
-rw-r--r--usr.bin/make/lst.lib/lstIsEmpty.c8
-rw-r--r--usr.bin/make/lst.lib/lstLast.c8
-rw-r--r--usr.bin/make/lst.lib/lstMember.c10
-rw-r--r--usr.bin/make/lst.lib/lstNext.c16
-rw-r--r--usr.bin/make/lst.lib/lstOpen.c8
-rw-r--r--usr.bin/make/lst.lib/lstRemove.c16
-rw-r--r--usr.bin/make/lst.lib/lstReplace.c8
-rw-r--r--usr.bin/make/lst.lib/lstSucc.c8
-rw-r--r--usr.bin/make/main.c477
-rw-r--r--usr.bin/make/make.1127
-rw-r--r--usr.bin/make/make.c70
-rw-r--r--usr.bin/make/make.h27
-rw-r--r--usr.bin/make/nonints.h10
-rw-r--r--usr.bin/make/parse.c651
-rw-r--r--usr.bin/make/pathnames.h5
-rw-r--r--usr.bin/make/sprite.h8
-rw-r--r--usr.bin/make/str.c43
-rw-r--r--usr.bin/make/suff.c126
-rw-r--r--usr.bin/make/targ.c27
-rw-r--r--usr.bin/make/var.c147
57 files changed, 1629 insertions, 2866 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index eb1f43f9d5f4..b6ae9fc12691 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.11 1996/05/28 23:34:35 christos Exp $
-# @(#)Makefile 5.2 (Berkeley) 12/28/90
+# from: @(#)Makefile 5.2 (Berkeley) 12/28/90
+# $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $
PROG= make
-CFLAGS+= -I${.CURDIR} -Wall -Wno-unused #-Wmissing-prototypes -Wstrict-prototypes
+CFLAGS+= -I${.CURDIR} -DPOSIX
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
- make.c parse.c str.c suff.c targ.c var.c util.c
+ make.c parse.c str.c suff.c targ.c var.c
SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \
lstFind.c lstFindFrom.c lstFirst.c lstForEach.c lstForEachFrom.c \
diff --git a/usr.bin/make/PSD.doc/Makefile b/usr.bin/make/PSD.doc/Makefile
index 8e1f1fa0705b..acac84f3edc6 100644
--- a/usr.bin/make/PSD.doc/Makefile
+++ b/usr.bin/make/PSD.doc/Makefile
@@ -1,4 +1,3 @@
-# $NetBSD: Makefile,v 1.2 1995/06/14 15:20:23 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 8/14/93
DIR= psd/12.make
diff --git a/usr.bin/make/PSD.doc/tutorial.ms b/usr.bin/make/PSD.doc/tutorial.ms
index f66fd909be7b..3cd869d05289 100644
--- a/usr.bin/make/PSD.doc/tutorial.ms
+++ b/usr.bin/make/PSD.doc/tutorial.ms
@@ -1,4 +1,3 @@
-.\" $NetBSD: tutorial.ms,v 1.3 1996/03/06 00:15:31 christos Exp $
.\" Copyright (c) 1988, 1989 by Adam de Boor
.\" Copyright (c) 1989 by Berkeley Softworks
.\" Copyright (c) 1988, 1989, 1993
@@ -35,7 +34,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tutorial.ms 8.1 (Berkeley) 8/18/93
+.\" @(#)tutorial.ms 8.4 (Berkeley) 4/28/95
.\"
.EH 'PSD:12-%''PMake \*- A Tutorial'
.OH 'PMake \*- A Tutorial''PSD:12-%'
@@ -44,6 +43,8 @@
.\" is numeric, it is taken as the depth for numbering (as for .NH), else
.\" the default (1) is assumed.
.\"
+.\" $Id: tutorial.ms,v 1.4 89/01/08 20:20:22 adam Exp Locker: adam $
+.\"
.\" @P The initial paragraph distance.
.\" @Q The piece of section number to increment (or 0 if none given)
.\" @R Section header.
@@ -1271,15 +1272,6 @@ administrator. If locking is on,
will turn it off, and vice versa. Note that this locking will not
prevent \fIyou\fP from invoking PMake twice in the same place \*- if
you own the lock file, PMake will warn you about it but continue to execute.
-.IP "\fB\-m\fP \fIdirectory\fP"
-.Ix 0 def flags -m
-Tells PMake another place to search for included makefiles via the <...>
-style. Several
-.B \-m
-options can be given to form a search path. If this construct is used the
-default system makefile search path is completely overridden.
-To be explained in chapter 3, section 3.2.
-.Rm 2 3.2
.IP \fB\-n\fP
.Ix 0 def flags -n
This flag tells PMake not to execute the commands needed to update the
@@ -1920,15 +1912,11 @@ or this
.DE
The difference between the two is where PMake searches for the file:
the first way, PMake will look for
-the file only in the system makefile directory (or directories)
-(to find out what that directory is, give PMake the
+the file only in the system makefile directory (to find out what that
+directory is, give PMake the
.B \-h
flag).
.Ix 0 ref flags -h
-The system makefile directory search path can be overridden via the
-.B \-m
-option.
-.Ix 0 ref flags -m
For files in double-quotes, the search is more complex:
.RS
.IP 1)
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 410580013e01..64071dc6c535 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -1,5 +1,3 @@
-/* $NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
-#else
-static char rcsid[] = "$NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $";
-#endif
+static char sccsid[] = "@(#)arch.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -100,7 +94,7 @@ static char rcsid[] = "$NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $
#include <sys/param.h>
#include <ctype.h>
#include <ar.h>
-#include <utime.h>
+#include <ranlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "make.h"
@@ -114,18 +108,12 @@ typedef struct Arch {
char *name; /* Name of archive */
Hash_Table members; /* All the members of the archive described
* by <name, struct ar_hdr *> key/value pairs */
- char *fnametab; /* Extended name table strings */
- size_t fnamesize; /* Size of the string table */
} Arch;
static int ArchFindArchive __P((ClientData, ClientData));
static void ArchFree __P((ClientData));
static struct ar_hdr *ArchStatMember __P((char *, char *, Boolean));
static FILE *ArchFindMember __P((char *, char *, struct ar_hdr *, char *));
-#if defined(__svr4__) || defined(__SVR4)
-#define SVR4ARCHIVES
-static int ArchSVR4Entry __P((Arch *, char *, size_t, FILE *));
-#endif
/*-
*-----------------------------------------------------------------------
@@ -147,20 +135,18 @@ ArchFree(ap)
Arch *a = (Arch *) ap;
Hash_Search search;
Hash_Entry *entry;
-
- /* Free memory from hash entries */
+
+ /* Free memory from hash entries */
for (entry = Hash_EnumFirst(&a->members, &search);
entry != (Hash_Entry *)NULL;
entry = Hash_EnumNext(&search))
free((Address) Hash_GetValue (entry));
free(a->name);
- if (a->fnametab)
- free(a->fnametab);
Hash_DeleteTable(&a->members);
free((Address) a);
}
-
+
/*-
@@ -196,7 +182,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
* variable substitution performed on it */
libName = *linePtr;
-
+
subLibName = FALSE;
for (cp = libName; *cp != '(' && *cp != '\0'; cp++) {
@@ -208,14 +194,14 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
int length;
Boolean freeIt;
char *result;
-
+
result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
if (result == var_Error) {
return(FAILURE);
} else {
subLibName = TRUE;
}
-
+
if (freeIt) {
free(result);
}
@@ -227,7 +213,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
if (subLibName) {
libName = Var_Subst(NULL, libName, ctxt, TRUE);
}
-
+
for (;;) {
/*
@@ -303,7 +289,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
char *buf;
char *sacrifice;
char *oldMemName = memName;
-
+
memName = Var_Subst(NULL, memName, ctxt, TRUE);
/*
@@ -349,7 +335,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
Dir_Expand(memName, dirSearchPath, members);
while (!Lst_IsEmpty(members)) {
member = (char *)Lst_DeQueue(members);
-
+
sprintf(nameBuf, "%s(%s)", libName, member);
free(member);
gn = Targ_FindNode (nameBuf, TARG_CREATE);
@@ -388,7 +374,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt)
if (doSubst) {
free(memName);
}
-
+
*cp = saveChar;
}
@@ -500,7 +486,7 @@ ArchStatMember (archive, member, hash)
strncpy(copy, member, AR_MAX_NAME_LEN);
copy[AR_MAX_NAME_LEN] = '\0';
}
- if ((he = Hash_FindEntry (&ar->members, copy)) != NULL)
+ if (he = Hash_FindEntry (&ar->members, copy))
return ((struct ar_hdr *) Hash_GetValue (he));
return ((struct ar_hdr *) NULL);
}
@@ -534,7 +520,7 @@ ArchStatMember (archive, member, hash)
if (arch == (FILE *) NULL) {
return ((struct ar_hdr *) NULL);
}
-
+
/*
* We use the ARMAG string to make sure this is an archive we
* can handle...
@@ -546,58 +532,27 @@ ArchStatMember (archive, member, hash)
}
ar = (Arch *)emalloc (sizeof (Arch));
- ar->name = estrdup (archive);
- ar->fnametab = NULL;
- ar->fnamesize = 0;
+ ar->name = strdup (archive);
Hash_InitTable (&ar->members, -1);
memName[AR_MAX_NAME_LEN] = '\0';
-
+
while (fread ((char *)&arh, sizeof (struct ar_hdr), 1, arch) == 1) {
if (strncmp ( arh.ar_fmag, ARFMAG, sizeof (arh.ar_fmag)) != 0) {
- /*
- * The header is bogus, so the archive is bad
- * and there's no way we can recover...
- */
- goto badarch;
+ /*
+ * The header is bogus, so the archive is bad
+ * and there's no way we can recover...
+ */
+ fclose (arch);
+ Hash_DeleteTable (&ar->members);
+ free ((Address)ar);
+ return ((struct ar_hdr *) NULL);
} else {
- /*
- * We need to advance the stream's pointer to the start of the
- * next header. Files are padded with newlines to an even-byte
- * boundary, so we need to extract the size of the file from the
- * 'size' field of the header and round it up during the seek.
- */
- arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
- size = (int) strtol(arh.ar_size, NULL, 10);
-
(void) strncpy (memName, arh.ar_name, sizeof(arh.ar_name));
for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
continue;
}
cp[1] = '\0';
-#ifdef SVR4ARCHIVES
- /*
- * svr4 names are slash terminated. Also svr4 extended AR format.
- */
- if (memName[0] == '/') {
- /*
- * svr4 magic mode; handle it
- */
- switch (ArchSVR4Entry(ar, memName, size, arch)) {
- case -1: /* Invalid data */
- goto badarch;
- case 0: /* List of files entry */
- continue;
- default: /* Got the entry */
- break;
- }
- }
- else {
- if (cp[0] == '/')
- cp[0] = '\0';
- }
-#endif
-
#ifdef AR_EFMT1
/*
* BSD 4.4 extended AR format: #1/<namelen>, with name as the
@@ -608,10 +563,18 @@ ArchStatMember (archive, member, hash)
unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
- if (elen > MAXPATHLEN)
- goto badarch;
- if (fread (memName, elen, 1, arch) != 1)
- goto badarch;
+ if (elen > MAXPATHLEN) {
+ fclose (arch);
+ Hash_DeleteTable (&ar->members);
+ free ((Address)ar);
+ return ((struct ar_hdr *) NULL);
+ }
+ if (fread (memName, elen, 1, arch) != 1) {
+ fclose (arch);
+ Hash_DeleteTable (&ar->members);
+ free ((Address)ar);
+ return ((struct ar_hdr *) NULL);
+ }
memName[elen] = '\0';
fseek (arch, -elen, 1);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
@@ -625,6 +588,14 @@ ArchStatMember (archive, member, hash)
memcpy ((Address)Hash_GetValue (he), (Address)&arh,
sizeof (struct ar_hdr));
}
+ /*
+ * We need to advance the stream's pointer to the start of the
+ * next header. Files are padded with newlines to an even-byte
+ * boundary, so we need to extract the size of the file from the
+ * 'size' field of the header and round it up during the seek.
+ */
+ arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
+ size = (int) strtol(arh.ar_size, NULL, 10);
fseek (arch, (size + 1) & ~1, 1);
}
@@ -643,120 +614,7 @@ ArchStatMember (archive, member, hash)
} else {
return ((struct ar_hdr *) NULL);
}
-
-badarch:
- fclose (arch);
- Hash_DeleteTable (&ar->members);
- if (ar->fnametab)
- free(ar->fnametab);
- free ((Address)ar);
- return ((struct ar_hdr *) NULL);
-}
-
-#ifdef SVR4ARCHIVES
-/*-
- *-----------------------------------------------------------------------
- * ArchSVR4Entry --
- * Parse an SVR4 style entry that begins with a slash.
- * If it is "//", then load the table of filenames
- * If it is "/<offset>", then try to substitute the long file name
- * from offset of a table previously read.
- *
- * Results:
- * -1: Bad data in archive
- * 0: A table was loaded from the file
- * 1: Name was successfully substituted from table
- * 2: Name was not successfully substituted from table
- *
- * Side Effects:
- * If a table is read, the file pointer is moved to the next archive
- * member
- *
- *-----------------------------------------------------------------------
- */
-static int
-ArchSVR4Entry(ar, name, size, arch)
- Arch *ar;
- char *name;
- size_t size;
- FILE *arch;
-{
-#define ARLONGNAMES1 "//"
-#define ARLONGNAMES2 "/ARFILENAMES"
- size_t entry;
- char *ptr, *eptr;
-
- if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 ||
- strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
-
- if (ar->fnametab != NULL) {
- if (DEBUG(ARCH)) {
- printf("Attempted to redefine an SVR4 name table\n");
- }
- return -1;
- }
-
- /*
- * This is a table of archive names, so we build one for
- * ourselves
- */
- ar->fnametab = emalloc(size);
- ar->fnamesize = size;
-
- if (fread(ar->fnametab, size, 1, arch) != 1) {
- if (DEBUG(ARCH)) {
- printf("Reading an SVR4 name table failed\n");
- }
- return -1;
- }
- eptr = ar->fnametab + size;
- for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
- switch (*ptr) {
- case '/':
- entry++;
- *ptr = '\0';
- break;
-
- case '\n':
- break;
-
- default:
- break;
- }
- if (DEBUG(ARCH)) {
- printf("Found svr4 archive name table with %d entries\n", entry);
- }
- return 0;
- }
-
- if (name[1] == ' ' || name[1] == '\0')
- return 2;
-
- entry = (size_t) strtol(&name[1], &eptr, 0);
- if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
- if (DEBUG(ARCH)) {
- printf("Could not parse SVR4 name %s\n", name);
- }
- return 2;
- }
- if (entry >= ar->fnamesize) {
- if (DEBUG(ARCH)) {
- printf("SVR4 entry offset %s is greater than %d\n",
- name, ar->fnamesize);
- }
- return 2;
- }
-
- if (DEBUG(ARCH)) {
- printf("Replaced %s with %s\n", name, &ar->fnametab[entry]);
- }
-
- (void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
- name[MAXPATHLEN] = '\0';
- return 1;
}
-#endif
-
/*-
*-----------------------------------------------------------------------
@@ -793,7 +651,7 @@ ArchFindMember (archive, member, arhPtr, mode)
if (arch == (FILE *) NULL) {
return ((FILE *) NULL);
}
-
+
/*
* We use the ARMAG string to make sure this is an archive we
* can handle...
@@ -818,7 +676,7 @@ ArchFindMember (archive, member, arhPtr, mode)
if (len > sizeof (arhPtr->ar_name)) {
tlen = sizeof (arhPtr->ar_name);
}
-
+
while (fread ((char *)arhPtr, sizeof (struct ar_hdr), 1, arch) == 1) {
if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof (arhPtr->ar_fmag) ) != 0) {
/*
@@ -962,10 +820,9 @@ void
Arch_TouchLib (gn)
GNode *gn; /* The node of the library to touch */
{
-#ifdef RANLIBMAG
FILE * arch; /* Stream open to archive */
struct ar_hdr arh; /* Header describing table of contents */
- struct utimbuf times; /* Times for utime() call */
+ struct timeval times[2]; /* Times for utimes() call */
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+");
sprintf(arh.ar_date, "%-12ld", (long) now);
@@ -974,10 +831,10 @@ Arch_TouchLib (gn)
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
fclose (arch);
- times.actime = times.modtime = now;
- utime(gn->path, &times);
+ times[0].tv_sec = times[1].tv_sec = now;
+ times[0].tv_usec = times[1].tv_usec = 0;
+ utimes(gn->path, times);
}
-#endif
}
/*-
@@ -1083,7 +940,7 @@ Arch_MemMTime (gn)
/*-
*-----------------------------------------------------------------------
* Arch_FindLib --
- * Search for a library along the given search path.
+ * Search for a library along the given search path.
*
* Results:
* None.
@@ -1118,7 +975,7 @@ Arch_FindLib (gn, path)
Var_Set (TARGET, gn->name, gn);
#else
Var_Set (TARGET, gn->path == (char *) NULL ? gn->name : gn->path, gn);
-#endif /* LIBRARIES */
+#endif LIBRARIES
}
/*-
@@ -1147,7 +1004,7 @@ Arch_FindLib (gn, path)
* opinion we should not bother with the TOC at all since
* this is used by 'ar' rules that affect the data contents
* of the archive, not by ranlib rules, which affect the
- * TOC.
+ * TOC.
*
* Results:
* TRUE if the library is out-of-date. FALSE otherwise.
@@ -1162,13 +1019,12 @@ Arch_LibOODate (gn)
GNode *gn; /* The library's graph node */
{
Boolean oodate;
-
+
if (OP_NOP(gn->type) && Lst_IsEmpty(gn->children)) {
oodate = FALSE;
} else if ((gn->mtime > now) || (gn->mtime < gn->cmtime)) {
oodate = TRUE;
} else {
-#ifdef RANLIBMAG
struct ar_hdr *arhPtr; /* Header for __.SYMDEF */
int modTimeTOC; /* The table-of-contents's mod time */
@@ -1190,9 +1046,6 @@ Arch_LibOODate (gn)
}
oodate = TRUE;
}
-#else
- oodate = FALSE;
-#endif
}
return (oodate);
}
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index e3b6afe176fe..68a534db14bc 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -1,8 +1,6 @@
-/* $NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $";
-#endif
+static char sccsid[] = "@(#)buf.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -69,7 +63,7 @@ static char rcsid[] = "$NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $";
#define BufExpand(bp,nb) \
if (bp->left < (nb)+1) {\
int newSize = (bp)->size + max((nb)+1,BUF_ADD_INC); \
- Byte *newBuf = (Byte *) erealloc((bp)->buffer, newSize); \
+ Byte *newBuf = (Byte *) realloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
(bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\
@@ -292,7 +286,7 @@ Buf_GetBytes (bp, numBytes, bytesPtr)
int numBytes;
Byte *bytesPtr;
{
-
+
if (bp->inPtr - bp->outPtr < numBytes) {
numBytes = bp->inPtr - bp->outPtr;
}
@@ -329,7 +323,7 @@ Buf_GetAll (bp, numBytesPtr)
if (numBytesPtr != (int *)NULL) {
*numBytesPtr = bp->inPtr - bp->outPtr;
}
-
+
return (bp->outPtr);
}
@@ -342,7 +336,7 @@ Buf_GetAll (bp, numBytesPtr)
* None.
*
* Side Effects:
- * The bytes are discarded.
+ * The bytes are discarded.
*
*-----------------------------------------------------------------------
*/
@@ -434,34 +428,9 @@ Buf_Destroy (buf, freeData)
Buffer buf; /* Buffer to destroy */
Boolean freeData; /* TRUE if the data should be destroyed as well */
{
-
+
if (freeData) {
free ((char *)buf->buffer);
}
free ((char *)buf);
}
-
-/*-
- *-----------------------------------------------------------------------
- * Buf_ReplaceLastByte --
- * Replace the last byte in a buffer.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * If the buffer was empty intially, then a new byte will be added.
- * Otherwise, the last byte is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-void
-Buf_ReplaceLastByte (buf, byte)
- Buffer buf; /* buffer to augment */
- Byte byte; /* byte to be written */
-{
- if (buf->inPtr == buf->outPtr)
- Buf_AddByte(buf, byte);
- else
- *(buf->inPtr - 1) = byte;
-}
diff --git a/usr.bin/make/buf.h b/usr.bin/make/buf.h
index 1295ff63dfd7..33313b8ff0ea 100644
--- a/usr.bin/make/buf.h
+++ b/usr.bin/make/buf.h
@@ -1,8 +1,6 @@
-/* $NetBSD: buf.h,v 1.5 1995/06/14 15:18:53 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)buf.h 8.1 (Berkeley) 6/6/93
+ * @(#)buf.h 8.2 (Berkeley) 4/28/95
*/
/*-
@@ -78,6 +76,5 @@ void Buf_Discard __P((Buffer, int));
int Buf_Size __P((Buffer));
Buffer Buf_Init __P((int));
void Buf_Destroy __P((Buffer, Boolean));
-void Buf_ReplaceLastByte __P((Buffer, Byte));
#endif /* _BUF_H */
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index 0ebdcc089a01..9cab63c07345 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -1,8 +1,6 @@
-/* $NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
-#else
-static char rcsid[] = "$NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $";
-#endif
+static char sccsid[] = "@(#)compat.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -61,11 +55,11 @@ static char rcsid[] = "$NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp
#include <stdio.h>
#include <sys/types.h>
-#include <sys/stat.h>
+#include <sys/signal.h>
#include <sys/wait.h>
+#include <sys/errno.h>
+#include <sys/stat.h>
#include <ctype.h>
-#include <errno.h>
-#include <signal.h>
#include "make.h"
#include "hash.h"
#include "dir.h"
@@ -107,12 +101,14 @@ CompatInterrupt (signo)
int signo;
{
GNode *gn;
-
+
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
char *p1;
char *file = Var_Value (TARGET, curTarg, &p1);
+ struct stat st;
- if (!noExecute && eunlink(file) != -1) {
+ if (!noExecute && lstat(file, &st) != -1 && !S_ISDIR(st.st_mode) &&
+ unlink(file) != -1) {
printf ("*** %s removed\n", file);
}
if (p1)
@@ -155,7 +151,7 @@ CompatRunCommand (cmdp, gnp)
register char *cp;
Boolean silent, /* Don't print command */
errCheck; /* Check errors */
- int reason; /* Reason for child's death */
+ union wait reason; /* Reason for child's death */
int status; /* Description of child's death */
int cpid; /* Child actually found */
ReturnStatus stat; /* Status of fork */
@@ -168,7 +164,7 @@ CompatRunCommand (cmdp, gnp)
char *cmd = (char *) cmdp;
GNode *gn = (GNode *) gnp;
- /*
+ /*
* Avoid clobbered variable warnings by forcing the compiler
* to ``unregister'' variables
*/
@@ -188,7 +184,7 @@ CompatRunCommand (cmdp, gnp)
* command? In any case, we warn the user that the command expanded to
* nothing (is this the right thing to do?).
*/
-
+
if (*cmdStart == '\0') {
free(cmdStart);
Error("%s expands to empty string", cmd);
@@ -217,7 +213,7 @@ CompatRunCommand (cmdp, gnp)
while (isspace((unsigned char)*cmd))
cmd++;
-
+
/*
* Search for meta characters in the command. If there are no meta
* characters, there's no need to execute a shell to execute the
@@ -243,7 +239,7 @@ CompatRunCommand (cmdp, gnp)
if (noExecute) {
return (0);
}
-
+
if (*cp != '\0') {
/*
* If *cp isn't the null character, we hit a "meta" character and
@@ -268,7 +264,7 @@ CompatRunCommand (cmdp, gnp)
av = brk_string(cmd, &argc, TRUE);
av += 1;
}
-
+
local = TRUE;
/*
@@ -290,32 +286,32 @@ CompatRunCommand (cmdp, gnp)
}
free(cmdStart);
Lst_Replace (cmdNode, (ClientData) NULL);
-
+
/*
* The child is off and running. Now all we can do is wait...
*/
while (1) {
- while ((stat = wait(&reason)) != cpid) {
+ while ((stat = wait((int *)&reason)) != cpid) {
if (stat == -1 && errno != EINTR) {
break;
}
}
-
+
if (stat > -1) {
if (WIFSTOPPED(reason)) {
- status = WSTOPSIG(reason); /* stopped */
+ status = reason.w_stopval; /* stopped */
} else if (WIFEXITED(reason)) {
- status = WEXITSTATUS(reason); /* exited */
+ status = reason.w_retcode; /* exited */
if (status != 0) {
printf ("*** Error code %d", status);
}
} else {
- status = WTERMSIG(reason); /* signaled */
+ status = reason.w_termsig; /* signaled */
printf ("*** Signal %d", status);
- }
-
+ }
+
if (!WIFEXITED(reason) || (status != 0)) {
if (errCheck) {
gn->made = ERROR;
@@ -392,7 +388,7 @@ CompatMake (gnp, pgnp)
if (p1)
free(p1);
}
-
+
/*
* All the children were made ok. Now cmtime contains the modification
* time of the newest child, we need to find out if we exist and when
@@ -426,7 +422,7 @@ CompatMake (gnp, pgnp)
* Make_DoAllVar().
*/
Make_DoAllVar(gn);
-
+
/*
* Alter our type to tell if errors should be ignored or things
* should not be printed so CompatRunCommand knows what to do.
@@ -567,7 +563,7 @@ CompatMake (gnp, pgnp)
return (0);
}
-
+
/*-
*-----------------------------------------------------------------------
* Compat_Run --
@@ -619,10 +615,6 @@ Compat_Run(targs)
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (gn != NILGNODE) {
Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
- if (gn->made == ERROR) {
- printf("\n\nStop.\n");
- exit(1);
- }
}
}
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index 6515ec006789..6ea0d6a3d476 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -1,8 +1,6 @@
-/* $NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
-#else
-static char rcsid[] = "$NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $";
-#endif
+static char sccsid[] = "@(#)cond.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -100,7 +94,6 @@ typedef enum {
* Structures to handle elegantly the different forms of #if's. The
* last two fields are stored in condInvert and condDefProc, respectively.
*/
-static void CondPushBack __P((Token));
static int CondGetArg __P((char **, char **, char *, Boolean));
static Boolean CondDoDefined __P((int, char *));
static int CondStrMatch __P((ClientData, ClientData));
@@ -117,19 +110,18 @@ static struct If {
char *form; /* Form of if */
int formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
- Boolean (*defProc) __P((int, char *)); /* Default function to apply */
+ Boolean (*defProc)(); /* Default function to apply */
} ifs[] = {
{ "ifdef", 5, FALSE, CondDoDefined },
{ "ifndef", 6, TRUE, CondDoDefined },
{ "ifmake", 6, FALSE, CondDoMake },
{ "ifnmake", 7, TRUE, CondDoMake },
{ "if", 2, FALSE, CondDoDefined },
- { NULL, 0, FALSE, NULL }
+ { (char *)0, 0, FALSE, (Boolean (*)())0 }
};
static Boolean condInvert; /* Invert the default function */
-static Boolean (*condDefProc) /* Default function to apply */
- __P((int, char *));
+static Boolean (*condDefProc)(); /* Default function to apply */
static char *condExpr; /* The expression to parse */
static Token condPushBack=None; /* Single push-back token used in
* parsing */
@@ -218,7 +210,7 @@ CondGetArg (linePtr, argPtr, func, parens)
* long. Why 16? Why not?
*/
buf = Buf_Init(16);
-
+
while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) {
if (*cp == '$') {
/*
@@ -261,7 +253,7 @@ CondGetArg (linePtr, argPtr, func, parens)
*/
cp++;
}
-
+
*linePtr = cp;
return (argLen);
}
@@ -435,7 +427,7 @@ CondDoTarget (argLen, arg)
*
* Side Effects:
* Can change 'value' even if string is not a valid number.
- *
+ *
*
*-----------------------------------------------------------------------
*/
@@ -625,10 +617,10 @@ do_string_compare:
buf = Buf_Init(0);
qt = *rhs == '"' ? 1 : 0;
-
- for (cp = &rhs[qt];
- ((qt && (*cp != '"')) ||
- (!qt && strchr(" \t)", *cp) == NULL)) &&
+
+ for (cp = &rhs[qt];
+ ((qt && (*cp != '"')) ||
+ (!qt && strchr(" \t)", *cp) == NULL)) &&
(*cp != '\0'); cp++) {
if ((*cp == '\\') && (cp[1] != '\0')) {
/*
@@ -640,7 +632,7 @@ do_string_compare:
} else if (*cp == '$') {
int len;
Boolean freeIt;
-
+
cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt);
if (cp2 != var_Error) {
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
@@ -694,7 +686,7 @@ do_string_compare:
if (*rhs == '$') {
int len;
Boolean freeIt;
-
+
string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt);
if (string == var_Error) {
right = 0.0;
@@ -722,7 +714,7 @@ do_string_compare:
}
}
}
-
+
if (DEBUG(COND)) {
printf("left = %f, right = %f, op = %.2s\n", left,
right, op);
@@ -766,11 +758,11 @@ error:
break;
}
default: {
- Boolean (*evalProc) __P((int, char *));
+ Boolean (*evalProc)();
Boolean invert = FALSE;
char *arg;
int arglen;
-
+
if (strncmp (condExpr, "defined", 7) == 0) {
/*
* Use CondDoDefined to evaluate the argument and
@@ -832,8 +824,8 @@ error:
if (val == var_Error) {
t = Err;
} else {
- /*
- * A variable is empty when it just contains
+ /*
+ * A variable is empty when it just contains
* spaces... 4/15/92, christos
*/
char *p;
@@ -1115,7 +1107,7 @@ Cond_Eval (line)
} else {
isElse = FALSE;
}
-
+
/*
* Figure out what sort of conditional it is -- what its default
* function is, etc. -- by looking in the table of valid "ifs"
@@ -1175,16 +1167,16 @@ Cond_Eval (line)
*/
condDefProc = ifp->defProc;
condInvert = ifp->doNot;
-
+
line += ifp->formlen;
-
+
while (*line == ' ' || *line == '\t') {
line++;
}
-
+
condExpr = line;
condPushBack = None;
-
+
switch (CondE(TRUE)) {
case True:
if (CondToken(TRUE) == EndOfFile) {
diff --git a/usr.bin/make/config.h b/usr.bin/make/config.h
index eaf960c85653..1f70f3768aa3 100644
--- a/usr.bin/make/config.h
+++ b/usr.bin/make/config.h
@@ -1,8 +1,6 @@
-/* $NetBSD: config.h,v 1.6 1996/05/28 23:34:39 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)config.h 8.1 (Berkeley) 6/6/93
+ * @(#)config.h 8.2 (Berkeley) 4/28/95
*/
#define DEFSHELL 1 /* Bourne shell */
@@ -80,39 +78,15 @@
* re-made, causing later targets to appear up-to-date. On systems
* that don't have this problem, you should defined this. Under
* NFS you probably should not, unless you aren't exporting jobs.
+ *
+ * POSIX
+ * If the POSIX standard for Make is to be followed. There are
+ * several areas that I dislike, hence this constant.
*/
#define LIBSUFF ".a"
#define RECHECK
-/*
- * POSIX
- * Adhere to the POSIX 1003.2 draft for the make(1) program.
- * - Use MAKEFLAGS instead of MAKE to pick arguments from the
- * environment.
- * - Allow empty command lines if starting with tab.
- */
-#define POSIX
-
-/*
- * SYSVINCLUDE
- * Recognize system V like include directives [include "filename"]
- * SYSVVARSUB
- * Recognize system V like ${VAR:x=y} variable substitutions
- */
-#define SYSVINCLUDE
-#define SYSVVARSUB
-
-/*
- * SUNSHCMD
- * Recognize SunOS and Solaris:
- * VAR :sh= CMD # Assign VAR to the command substitution of CMD
- * ${VAR:sh} # Return the command substitution of the value
- * # of ${VAR}
- */
-#define SUNSHCMD
-
-#if !defined(__svr4__) && !defined(__SVR4)
-# ifndef RANLIBMAG
-# define RANLIBMAG "__.SYMDEF"
-# endif
+#ifndef RANLIBMAG
+#define RANLIBMAG "__.SYMDEF"
#endif
+/*#define POSIX*/
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 56d78afbbe90..e515fbb731e1 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,8 +1,6 @@
-/* $NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
-#else
-static char rcsid[] = "$NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $";
-#endif
+static char sccsid[] = "@(#)dir.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -217,7 +211,7 @@ Dir_Init ()
dirSearchPath = Lst_Init (FALSE);
openDirectories = Lst_Init (FALSE);
Hash_InitTable(&mtimes, 0);
-
+
/*
* Since the Path structure is placed on both openDirectories and
* the path we give Dir_AddDir (which in this case is openDirectories),
@@ -297,7 +291,7 @@ Dir_HasWildcards (name)
char *name; /* name to check */
{
register char *cp;
-
+
for (cp = name; *cp; cp++) {
switch(*cp) {
case '{':
@@ -333,12 +327,12 @@ DirMatchFiles (pattern, p, expansions)
Path *p; /* Directory to search */
Lst expansions; /* Place to store the results */
{
- Hash_Search search; /* Index into the directory's table */
+ Hash_Search search; /* Index into the directory's table */
Hash_Entry *entry; /* Current entry in the table */
Boolean isDot; /* TRUE if the directory being searched is . */
-
+
isDot = (*p->name == '.' && p->name[1] == '\0');
-
+
for (entry = Hash_EnumFirst(&p->files, &search);
entry != (Hash_Entry *)NULL;
entry = Hash_EnumNext(&search))
@@ -354,7 +348,7 @@ DirMatchFiles (pattern, p, expansions)
(pattern[0] == '.')))
{
(void)Lst_AtEnd(expansions,
- (isDot ? estrdup(entry->name) :
+ (isDot ? strdup(entry->name) :
str_concat(p->name, entry->name,
STR_ADDSLASH)));
}
@@ -557,7 +551,7 @@ Dir_Expand (word, path, expansions)
if (DEBUG(DIR)) {
printf("expanding \"%s\"...", word);
}
-
+
cp = strchr(word, '{');
if (cp) {
DirExpandCurly(word, cp, path, expansions);
@@ -631,7 +625,7 @@ Dir_Expand (word, path, expansions)
* First the files in dot
*/
DirMatchFiles(word, dot, expansions);
-
+
/*
* Then the files in every other directory on the path.
*/
@@ -676,7 +670,7 @@ Dir_FindFile (name, path)
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
Hash_Entry *entry; /* Entry for mtimes table */
-
+
/*
* Find the final component of the name and note whether it has a
* slash in it (the name, I mean)
@@ -689,7 +683,7 @@ Dir_FindFile (name, path)
hasSlash = FALSE;
cp = name;
}
-
+
if (DEBUG(DIR)) {
printf("Searching for %s...", name);
}
@@ -706,9 +700,9 @@ Dir_FindFile (name, path)
}
hits += 1;
dot->hits += 1;
- return (estrdup (name));
+ return (strdup (name));
}
-
+
if (Lst_Open (path) == FAILURE) {
if (DEBUG(DIR)) {
printf("couldn't open path, file not found\n");
@@ -716,7 +710,7 @@ Dir_FindFile (name, path)
misses += 1;
return ((char *) NULL);
}
-
+
/*
* We look through all the directories on the path seeking one which
* contains the final component of the given name and whose final
@@ -781,7 +775,7 @@ Dir_FindFile (name, path)
}
}
}
-
+
/*
* We didn't find the file on any existing members of the directory.
* If the name doesn't contain a slash, that means it doesn't exist.
@@ -801,10 +795,10 @@ Dir_FindFile (name, path)
misses += 1;
return ((char *) NULL);
}
-
+
if (*name != '/') {
Boolean checkedDot = FALSE;
-
+
if (DEBUG(DIR)) {
printf("failed. Trying subdirectories...");
}
@@ -817,21 +811,21 @@ Dir_FindFile (name, path)
/*
* Checking in dot -- DON'T put a leading ./ on the thing.
*/
- file = estrdup(name);
+ file = strdup(name);
checkedDot = TRUE;
}
if (DEBUG(DIR)) {
printf("checking %s...", file);
}
-
-
+
+
if (stat (file, &stb) == 0) {
if (DEBUG(DIR)) {
printf("got it.\n");
}
-
+
Lst_Close (path);
-
+
/*
* We've found another directory to search. We know there's
* a slash in 'file' because we put one there. We nuke it after
@@ -846,7 +840,7 @@ Dir_FindFile (name, path)
*cp = '\0';
Dir_AddDir (path, file);
*cp = '/';
-
+
/*
* Save the modification time so if it's needed, we don't have
* to fetch it again.
@@ -864,7 +858,7 @@ Dir_FindFile (name, path)
free (file);
}
}
-
+
if (DEBUG(DIR)) {
printf("failed. ");
}
@@ -881,7 +875,7 @@ Dir_FindFile (name, path)
return(NULL);
}
}
-
+
/*
* Didn't find it that way, either. Sigh. Phase 3. Add its directory
* onto the search path in any case, just in case, then look for the
@@ -903,7 +897,7 @@ Dir_FindFile (name, path)
cp[-1] = '\0';
Dir_AddDir (path, name);
cp[-1] = '/';
-
+
bigmisses += 1;
ln = Lst_Last (path);
if (ln == NILLNODE) {
@@ -911,9 +905,9 @@ Dir_FindFile (name, path)
} else {
p = (Path *) Lst_Datum (ln);
}
-
+
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
- return (estrdup (name));
+ return (strdup (name));
} else {
return ((char *) NULL);
}
@@ -921,14 +915,14 @@ Dir_FindFile (name, path)
if (DEBUG(DIR)) {
printf("Looking for \"%s\"...", name);
}
-
+
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != (Hash_Entry *)NULL) {
if (DEBUG(DIR)) {
printf("got it (in mtime cache)\n");
}
- return(estrdup(name));
+ return(strdup(name));
} else if (stat (name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
if (DEBUG(DIR)) {
@@ -936,7 +930,7 @@ Dir_FindFile (name, path)
name);
}
Hash_SetValue(entry, (long)stb.st_mtime);
- return (estrdup (name));
+ return (strdup (name));
} else {
if (DEBUG(DIR)) {
printf("failed. Returning NULL\n");
@@ -951,7 +945,7 @@ Dir_FindFile (name, path)
* Dir_MTime --
* Find the modification time of the file described by gn along the
* search path dirSearchPath.
- *
+ *
* Results:
* The modification time or 0 if it doesn't exist
*
@@ -969,7 +963,7 @@ Dir_MTime (gn)
char *fullName; /* the full pathname of name */
struct stat stb; /* buffer for finding the mod time */
Hash_Entry *entry;
-
+
if (gn->type & OP_ARCHV) {
return Arch_MTime (gn);
} else if (gn->path == (char *)NULL) {
@@ -977,9 +971,9 @@ Dir_MTime (gn)
} else {
fullName = gn->path;
}
-
+
if (fullName == (char *)NULL) {
- fullName = estrdup(gn->name);
+ fullName = strdup(gn->name);
}
entry = Hash_FindEntry(&mtimes, fullName);
@@ -1007,7 +1001,7 @@ Dir_MTime (gn)
if (fullName && gn->path == (char *)NULL) {
gn->path = fullName;
}
-
+
gn->mtime = stb.st_mtime;
return (gn->mtime);
}
@@ -1023,7 +1017,7 @@ Dir_MTime (gn)
* none
*
* Side Effects:
- * A structure is added to the list and the directory is
+ * A structure is added to the list and the directory is
* read and hashed.
*-----------------------------------------------------------------------
*/
@@ -1037,7 +1031,7 @@ Dir_AddDir (path, name)
register Path *p; /* pointer to new Path structure */
DIR *d; /* for reading directory */
register struct dirent *dp; /* entry in directory */
-
+
ln = Lst_Find (openDirectories, (ClientData)name, DirFindName);
if (ln != NILLNODE) {
p = (Path *)Lst_Datum (ln);
@@ -1050,22 +1044,22 @@ Dir_AddDir (path, name)
printf("Caching %s...", name);
fflush(stdout);
}
-
+
if ((d = opendir (name)) != (DIR *) NULL) {
p = (Path *) emalloc (sizeof (Path));
- p->name = estrdup (name);
+ p->name = strdup (name);
p->hits = 0;
p->refCount = 1;
Hash_InitTable (&p->files, -1);
-
+
/*
* Skip the first two entries -- these will *always* be . and ..
*/
(void)readdir(d);
(void)readdir(d);
-
+
while ((dp = readdir (d)) != (struct dirent *) NULL) {
-#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
+#ifdef sun
/*
* The sun directory library doesn't check for a 0 inode
* (0-inode slots just take up space), so we have to do
@@ -1074,7 +1068,7 @@ Dir_AddDir (path, name)
if (dp->d_fileno == 0) {
continue;
}
-#endif /* sun && d_ino */
+#endif /* sun */
(void)Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
}
(void) closedir (d);
@@ -1136,9 +1130,9 @@ Dir_MakeFlags (flag, path)
char *tstr; /* the current directory preceded by 'flag' */
LstNode ln; /* the node of the current directory */
Path *p; /* the structure describing the current directory */
-
- str = estrdup ("");
-
+
+ str = strdup ("");
+
if (Lst_Open (path) == SUCCESS) {
while ((ln = Lst_Next (path)) != NILLNODE) {
p = (Path *) Lst_Datum (ln);
@@ -1147,7 +1141,7 @@ Dir_MakeFlags (flag, path)
}
Lst_Close (path);
}
-
+
return (str);
}
@@ -1209,7 +1203,7 @@ Dir_ClearPath(path)
Dir_Destroy((ClientData) p);
}
}
-
+
/*-
*-----------------------------------------------------------------------
@@ -1248,7 +1242,7 @@ Dir_PrintDirectories()
{
LstNode ln;
Path *p;
-
+
printf ("#*** Directory Cache:\n");
printf ("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
hits, misses, nearmisses, bigmisses,
@@ -1267,7 +1261,7 @@ Dir_PrintDirectories()
static int DirPrintDir (p, dummy)
ClientData p;
ClientData dummy;
-{
+{
printf ("%s ", ((Path *) p)->name);
return (dummy ? 0 : 0);
}
diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h
index ac43ab0092ac..81d76d11504d 100644
--- a/usr.bin/make/dir.h
+++ b/usr.bin/make/dir.h
@@ -1,8 +1,6 @@
-/* $NetBSD: dir.h,v 1.3 1995/06/14 15:19:11 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)dir.h 8.1 (Berkeley) 6/6/93
+ * @(#)dir.h 8.2 (Berkeley) 4/28/95
*/
/* dir.h --
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
index 47d42af282c0..3ab3cba33dce 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -1,8 +1,9 @@
-/* $NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $ */
-
/*
- * Copyright (c) 1992, The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $";
-#endif
+static char sccsid[] = "@(#)for.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -67,7 +64,7 @@ static char rcsid[] = "$NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $";
* The trick is to look for the matching end inside for for loop
* To do that, we count the current nesting level of the for loops.
* and the .endfor statements, accumulating all the statements between
- * the initial .for loop and the matching .endfor;
+ * the initial .for loop and the matching .endfor;
* then we evaluate the for loop for each variable in the varlist.
*/
@@ -131,18 +128,18 @@ For_Eval (line)
!isspace((unsigned char) ptr[3]))
return FALSE;
ptr += 3;
-
+
/*
* we found a for loop, and now we are going to parse it.
*/
while (*ptr && isspace((unsigned char) *ptr))
ptr++;
-
+
/*
* Grab the variable
*/
buf = Buf_Init(0);
- for (wrd = ptr; *ptr && !isspace((unsigned char) *ptr); ptr++)
+ for (wrd = ptr; *ptr && !isspace((unsigned char) *ptr); ptr++)
continue;
Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd);
@@ -175,12 +172,12 @@ For_Eval (line)
*/
forLst = Lst_Init(FALSE);
buf = Buf_Init(0);
- sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
+ sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \
Buf_AddByte(buf, (Byte) '\0'), \
- Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
+ Lst_AtEnd(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
@@ -196,12 +193,12 @@ For_Eval (line)
}
if (DEBUG(FOR))
(void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub);
- if (ptr - wrd > 0)
+ if (ptr - wrd > 0)
ADDWORD();
else
Buf_Destroy(buf, TRUE);
free((Address) sub);
-
+
forBuf = Buf_Init(0);
forLevel++;
return 1;
@@ -262,7 +259,7 @@ ForExec(namep, argp)
Var_Set(arg->var, name, VAR_GLOBAL);
if (DEBUG(FOR))
(void) fprintf(stderr, "--- %s = %s\n", arg->var, name);
- Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
+ Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
VAR_GLOBAL, FALSE));
Var_Delete(arg->var, VAR_GLOBAL);
diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c
index a4b730964a99..37e839862b56 100644
--- a/usr.bin/make/hash.c
+++ b/usr.bin/make/hash.c
@@ -1,8 +1,6 @@
-/* $NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $";
-#endif
+static char sccsid[] = "@(#)hash.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/* hash.c --
@@ -64,7 +58,7 @@ static char rcsid[] = "$NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $"
static void RebuildTable __P((Hash_Table *));
-/*
+/*
* The following defines the ratio of # entries to # buckets
* at which we rebuild the table to make it larger.
*/
@@ -73,12 +67,12 @@ static void RebuildTable __P((Hash_Table *));
/*
*---------------------------------------------------------
- *
+ *
* Hash_InitTable --
*
* This routine just sets up the hash table.
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
@@ -100,7 +94,7 @@ Hash_InitTable(t, numBuckets)
register struct Hash_Entry **hp;
/*
- * Round up the size to a power of two.
+ * Round up the size to a power of two.
*/
if (numBuckets <= 0)
i = 16;
@@ -125,7 +119,7 @@ Hash_InitTable(t, numBuckets)
* and frees up the memory space it occupied (except for
* the space in the Hash_Table structure).
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
@@ -151,7 +145,7 @@ Hash_DeleteTable(t)
/*
* Set up the hash table to cause memory faults on any future access
- * attempts until re-initialization.
+ * attempts until re-initialization.
*/
t->bucketPtr = NULL;
}
@@ -243,7 +237,7 @@ Hash_CreateEntry(t, key, newPtr)
/*
* The desired entry isn't there. Before allocating a new entry,
* expand the table if necessary (and this changes the resulting
- * bucket chain).
+ * bucket chain).
*/
if (t->numEntries >= rebuildLimit * t->size)
RebuildTable(t);
@@ -307,7 +301,7 @@ Hash_DeleteEntry(t, e)
* This procedure sets things up for a complete search
* of all entries recorded in the hash table.
*
- * Results:
+ * Results:
* The return value is the address of the first entry in
* the hash table, or NULL if the table is empty.
*
@@ -322,7 +316,7 @@ Hash_DeleteEntry(t, e)
Hash_Entry *
Hash_EnumFirst(t, searchPtr)
Hash_Table *t; /* Table to be searched. */
- register Hash_Search *searchPtr;/* Area in which to keep state
+ register Hash_Search *searchPtr;/* Area in which to keep state
* about search.*/
{
searchPtr->tablePtr = t;
@@ -351,7 +345,7 @@ Hash_EnumFirst(t, searchPtr)
Hash_Entry *
Hash_EnumNext(searchPtr)
- register Hash_Search *searchPtr; /* Area used to keep state about
+ register Hash_Search *searchPtr; /* Area used to keep state about
search. */
{
register Hash_Entry *e;
@@ -385,7 +379,7 @@ Hash_EnumNext(searchPtr)
* This local routine makes a new hash table that
* is larger than the old one.
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
diff --git a/usr.bin/make/hash.h b/usr.bin/make/hash.h
index 179b2cded713..63e8783726ce 100644
--- a/usr.bin/make/hash.h
+++ b/usr.bin/make/hash.h
@@ -1,8 +1,6 @@
-/* $NetBSD: hash.h,v 1.4 1995/06/14 15:19:18 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)hash.h 8.1 (Berkeley) 6/6/93
+ * @(#)hash.h 8.2 (Berkeley) 4/28/95
*/
/* hash.h --
@@ -49,7 +47,7 @@
#ifndef _HASH
#define _HASH
-/*
+/*
* The following defines one entry in the hash table.
*/
@@ -71,7 +69,7 @@ typedef struct Hash_Table {
int mask; /* Used to select bits for hashing. */
} Hash_Table;
-/*
+/*
* The following structure is used by the searching routines
* to record where we are in the search.
*/
@@ -87,22 +85,22 @@ typedef struct Hash_Search {
*/
/*
- * ClientData Hash_GetValue(h)
- * Hash_Entry *h;
+ * ClientData Hash_GetValue(h)
+ * Hash_Entry *h;
*/
#define Hash_GetValue(h) ((h)->clientData)
-/*
- * Hash_SetValue(h, val);
- * Hash_Entry *h;
- * char *val;
+/*
+ * Hash_SetValue(h, val);
+ * Hash_Entry *h;
+ * char *val;
*/
#define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val))
-/*
- * Hash_Size(n) returns the number of words in an object of n bytes
+/*
+ * Hash_Size(n) returns the number of words in an object of n bytes
*/
#define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int))
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 89a7e1b8bd65..166fd974797a 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,8 +1,6 @@
-/* $NetBSD: job.c,v 1.15 1996/05/29 15:28:05 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
-#else
-static char rcsid[] = "$NetBSD: job.c,v 1.15 1996/05/29 15:28:05 christos Exp $";
-#endif
+static char sccsid[] = "@(#)job.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -103,13 +97,13 @@ static char rcsid[] = "$NetBSD: job.c,v 1.15 1996/05/29 15:28:05 christos Exp $"
*/
#include <sys/types.h>
+#include <sys/signal.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
-#include <utime.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
@@ -118,17 +112,11 @@ static char rcsid[] = "$NetBSD: job.c,v 1.15 1996/05/29 15:28:05 christos Exp $"
#include "dir.h"
#include "job.h"
#include "pathnames.h"
-#ifdef REMOTE
-#include "rmt.h"
-# define STATIC
-#else
-# define STATIC static
-#endif
extern int errno;
/*
- * error handling variables
+ * error handling variables
*/
static int errors = 0; /* number of errors reported */
static int aborting = 0; /* why is the make aborting? */
@@ -136,11 +124,6 @@ static int aborting = 0; /* why is the make aborting? */
#define ABORT_INTERRUPT 2 /* Because it was interrupted */
#define ABORT_WAIT 3 /* Waiting for jobs to finish */
-/*
- * XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
- * is a char! So when we go above 127 we turn negative!
- */
-#define FILENO(a) ((unsigned) fileno(a))
/*
* post-make command processing. The node postCommands is really just the
@@ -153,6 +136,7 @@ static int numCommands; /* The number of commands actually printed
* for a target. Should this number be
* 0, no shell will be executed. */
+
/*
* Return values from JobStart.
*/
@@ -165,7 +149,7 @@ static int numCommands; /* The number of commands actually printed
* tfile is the name of a file into which all shell commands are put. It is
* used over by removing it before the child shell is executed. The XXXXX in
* the string are replaced by the pid of the make process in a 5-character
- * field with leading zeroes.
+ * field with leading zeroes.
*/
static char tfile[] = TMPPAT;
@@ -192,20 +176,17 @@ static Shell shells[] = {
{
"sh",
TRUE, "set -", "set -v", "set -", 5,
- TRUE, "set -e", "set +e",
-#ifdef OLDBOURNESHELL
FALSE, "echo \"%s\"\n", "sh -c '%s || exit 0'\n",
-#endif
"v", "e",
},
/*
* UNKNOWN.
*/
{
- (char *) 0,
- FALSE, (char *) 0, (char *) 0, (char *) 0, 0,
- FALSE, (char *) 0, (char *) 0,
- (char *) 0, (char *) 0,
+ (char *)0,
+ FALSE, (char *)0, (char *)0, (char *)0, 0,
+ FALSE, (char *)0, (char *)0,
+ (char *)0, (char *)0,
}
};
static Shell *commandShell = &shells[DEFSHELL];/* this is the shell to
@@ -213,17 +194,17 @@ static Shell *commandShell = &shells[DEFSHELL];/* this is the shell to
* commands in the Makefile.
* It is set by the
* Job_ParseShell function */
-static char *shellPath = NULL, /* full pathname of
+static char *shellPath = (char *) NULL, /* full pathname of
* executable image */
*shellName; /* last component of shell */
static int maxJobs; /* The most children we can run at once */
static int maxLocal; /* The most local ones we can have */
-STATIC int nJobs; /* The number of children currently running */
-STATIC int nLocal; /* The number of local children */
-STATIC Lst jobs; /* The structures that describe them */
-STATIC Boolean jobFull; /* Flag to tell when the job table is full. It
+int nJobs; /* The number of children currently running */
+int nLocal; /* The number of local children */
+Lst jobs; /* The structures that describe them */
+Boolean jobFull; /* Flag to tell when the job table is full. It
* is set TRUE when (1) the total number of
* running jobs equals the maximum allowed or
* (2) a job can only be run locally, but
@@ -233,86 +214,47 @@ static fd_set outputs; /* Set of descriptors of pipes connected to
* the output channels of children */
#endif
-STATIC GNode *lastNode; /* The node for which output was most recently
+GNode *lastNode; /* The node for which output was most recently
* produced. */
-STATIC char *targFmt; /* Format string to use to head output from a
+char *targFmt; /* Format string to use to head output from a
* job when it's not the most-recent job heard
* from */
-
-#ifdef REMOTE
-# define TARG_FMT "--- %s at %s ---\n" /* Default format */
-# define MESSAGE(fp, gn) \
- (void) fprintf(fp, targFmt, gn->name, gn->rem.hname);
-#else
-# define TARG_FMT "--- %s ---\n" /* Default format */
-# define MESSAGE(fp, gn) \
- (void) fprintf(fp, targFmt, gn->name);
-#endif
+#define TARG_FMT "--- %s ---\n" /* Default format */
/*
* When JobStart attempts to run a job remotely but can't, and isn't allowed
* to run the job locally, or when Job_CatchChildren detects a job that has
* been migrated home, the job is placed on the stoppedJobs queue to be run
- * when the next job finishes.
+ * when the next job finishes.
*/
-STATIC Lst stoppedJobs; /* Lst of Job structures describing
+Lst stoppedJobs; /* Lst of Job structures describing
* jobs that were stopped due to concurrency
* limits or migration home */
#if defined(USE_PGRP) && defined(SYSV)
-# define KILL(pid, sig) killpg(-(pid), (sig))
+#define KILL(pid,sig) killpg (-(pid),(sig))
#else
# if defined(USE_PGRP)
-# define KILL(pid, sig) killpg((pid), (sig))
+#define KILL(pid,sig) killpg ((pid),(sig))
# else
-# define KILL(pid, sig) kill((pid), (sig))
+#define KILL(pid,sig) kill ((pid),(sig))
# endif
#endif
-/*
- * Grmpf... There is no way to set bits of the wait structure
- * anymore with the stupid W*() macros. I liked the union wait
- * stuff much more. So, we devise our own macros... This is
- * really ugly, use dramamine sparingly. You have been warned.
- */
-#define W_SETMASKED(st, val, fun) \
- { \
- int sh = (int) ~0; \
- int mask = fun(sh); \
- \
- for (sh = 0; ((mask >> sh) & 1) == 0; sh++) \
- continue; \
- *(st) = (*(st) & ~mask) | ((val) << sh); \
- }
-
-#define W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG)
-#define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
-
-
static int JobCondPassSig __P((ClientData, ClientData));
static void JobPassSig __P((int));
static int JobCmpPid __P((ClientData, ClientData));
static int JobPrintCommand __P((ClientData, ClientData));
static int JobSaveCommand __P((ClientData, ClientData));
-static void JobClose __P((Job *));
-#ifdef REMOTE
-static int JobCmpRmtID __P((Job *, int));
-# ifdef RMT_WILL_WATCH
-static void JobLocalInput __P((int, Job *));
-# endif
-#else
-static void JobFinish __P((Job *, int *));
+static void JobFinish __P((Job *, union wait));
static void JobExec __P((Job *, char **));
-#endif
static void JobMakeArgv __P((Job *, char **));
static void JobRestart __P((Job *));
static int JobStart __P((GNode *, int, Job *));
-static char *JobOutput __P((Job *, char *, char *, int));
static void JobDoOutput __P((Job *, Boolean));
static Shell *JobMatchShell __P((char *));
-static void JobInterrupt __P((int, int));
-static void JobRestartJobs __P((void));
+static void JobInterrupt __P((int));
/*-
*-----------------------------------------------------------------------
@@ -337,7 +279,7 @@ JobCondPassSig(jobp, signop)
int signo = *(int *) signop;
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
- (void) Rmt_Signal(job, signo);
+ (void)Rmt_Signal(job, signo);
} else {
KILL(job->pid, signo);
}
@@ -346,15 +288,9 @@ JobCondPassSig(jobp, signop)
* Assume that sending the signal to job->pid will signal any remote
* job as well.
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobCondPassSig passing signal %d to child %d.\n",
- signo, job->pid);
- (void) fflush(stdout);
- }
KILL(job->pid, signo);
#endif
- return 0;
+ return(0);
}
/*-
@@ -368,21 +304,16 @@ JobCondPassSig(jobp, signop)
*
* Side Effects:
* We die by the same signal.
- *
+ *
*-----------------------------------------------------------------------
*/
static void
JobPassSig(signo)
int signo; /* The signal number we've received */
{
- sigset_t nmask, omask;
- struct sigaction act;
-
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "JobPassSig(%d) called.\n", signo);
- (void) fflush(stdout);
- }
- Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo);
+ int mask;
+
+ Lst_ForEach(jobs, JobCondPassSig, (ClientData)(long)signo);
/*
* Deal with proper cleanup based on the signal received. We only run
@@ -390,49 +321,36 @@ JobPassSig(signo)
* three termination signals are more of a "get out *now*" command.
*/
if (signo == SIGINT) {
- JobInterrupt(TRUE, signo);
+ JobInterrupt(TRUE);
} else if ((signo == SIGHUP) || (signo == SIGTERM) || (signo == SIGQUIT)) {
- JobInterrupt(FALSE, signo);
+ JobInterrupt(FALSE);
}
-
+
/*
* Leave gracefully if SIGQUIT, rather than core dumping.
*/
if (signo == SIGQUIT) {
Finish(0);
}
-
+
/*
* Send ourselves the signal now we've given the message to everyone else.
* Note we block everything else possible while we're getting the signal.
* This ensures that all our jobs get continued when we wake up before
* we take any other signal.
*/
- sigemptyset(&nmask);
- sigaddset(&nmask, signo);
- sigprocmask(SIG_SETMASK, &nmask, &omask);
- act.sa_handler = SIG_DFL;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- sigaction(signo, &act, NULL);
-
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobPassSig passing signal to self, mask = %x.\n",
- ~0 & ~(1 << (signo-1)));
- (void) fflush(stdout);
- }
- (void) signal(signo, SIG_DFL);
+ mask = sigblock(0);
+ (void) sigsetmask(~0 & ~(1 << (signo-1)));
+ signal(signo, SIG_DFL);
- (void) KILL(getpid(), signo);
+ kill(getpid(), signo);
signo = SIGCONT;
Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo);
- (void) sigprocmask(SIG_SETMASK, &omask, NULL);
- sigprocmask(SIG_SETMASK, &omask, NULL);
- act.sa_handler = JobPassSig;
- sigaction(signo, &act, NULL);
+ sigsetmask(mask);
+ signal(signo, JobPassSig);
+
}
/*-
@@ -450,36 +368,13 @@ JobPassSig(signo)
*-----------------------------------------------------------------------
*/
static int
-JobCmpPid(job, pid)
+JobCmpPid (job, pid)
ClientData job; /* job to examine */
ClientData pid; /* process id desired */
{
- return *(int *) pid - ((Job *) job)->pid;
+ return ( *(int *) pid - ((Job *) job)->pid);
}
-#ifdef REMOTE
-/*-
- *-----------------------------------------------------------------------
- * JobCmpRmtID --
- * Compare the rmtID of the job with the given rmtID and return 0 if they
- * are equal.
- *
- * Results:
- * 0 if the rmtID's match
- *
- * Side Effects:
- * None.
- *-----------------------------------------------------------------------
- */
-static int
-JobCmpRmtID(job, rmtID)
- ClientData job; /* job to examine */
- ClientData rmtID; /* remote id desired */
-{
- return(*(int *) rmtID - *(int *) job->rmtID);
-}
-#endif
-
/*-
*-----------------------------------------------------------------------
* JobPrintCommand --
@@ -508,7 +403,7 @@ JobCmpRmtID(job, rmtID)
*-----------------------------------------------------------------------
*/
static int
-JobPrintCommand(cmdp, jobp)
+JobPrintCommand (cmdp, jobp)
ClientData cmdp; /* command string to print */
ClientData jobp; /* job for which to print it */
{
@@ -525,26 +420,21 @@ JobPrintCommand(cmdp, jobp)
char *cmdStart; /* Start of expanded command */
LstNode cmdNode; /* Node for replacing the command */
char *cmd = (char *) cmdp;
- Job *job = (Job *) jobp;
+ Job *job = (Job *) jobp;
- noSpecials = (noExecute && !(job->node->type & OP_MAKE));
+ noSpecials = (noExecute && ! (job->node->type & OP_MAKE));
- if (strcmp(cmd, "...") == 0) {
- job->node->type |= OP_SAVE_CMDS;
+ if (strcmp (cmd, "...") == 0) {
+ job->node->type |= OP_SAVE_CMDS;
if ((job->flags & JOB_IGNDOTS) == 0) {
- job->tailCmds = Lst_Succ(Lst_Member(job->node->commands,
- (ClientData)cmd));
- return 1;
+ job->tailCmds = Lst_Succ (Lst_Member (job->node->commands,
+ (ClientData)cmd));
+ return (1);
}
- return 0;
+ return (0);
}
-#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \
- (void) fprintf(stdout, fmt, arg); \
- (void) fflush(stdout); \
- } \
- (void) fprintf(job->cmdFILE, fmt, arg); \
- (void) fflush(job->cmdFILE);
+#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) printf (fmt, arg); fprintf (job->cmdFILE, fmt, arg)
numCommands += 1;
@@ -552,9 +442,9 @@ JobPrintCommand(cmdp, jobp)
* For debugging, we replace each command with the result of expanding
* the variables in the command.
*/
- cmdNode = Lst_Member(job->node->commands, (ClientData)cmd);
- cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
- Lst_Replace(cmdNode, (ClientData)cmdStart);
+ cmdNode = Lst_Member (job->node->commands, (ClientData)cmd);
+ cmdStart = cmd = Var_Subst (NULL, cmd, job->node, FALSE);
+ Lst_Replace (cmdNode, (ClientData)cmdStart);
cmdTemplate = "%s\n";
@@ -574,16 +464,16 @@ JobPrintCommand(cmdp, jobp)
cmd++;
if (shutUp) {
- if (!(job->flags & JOB_SILENT) && !noSpecials &&
+ if (! (job->flags & JOB_SILENT) && !noSpecials &&
commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
+ DBPRINTF ("%s\n", commandShell->echoOff);
} else {
shutUp = FALSE;
}
}
if (errOff) {
- if ( !(job->flags & JOB_IGNERR) && !noSpecials) {
+ if ( ! (job->flags & JOB_IGNERR) && !noSpecials) {
if (commandShell->hasErrCtl) {
/*
* we don't want the error-control commands showing
@@ -593,16 +483,16 @@ JobPrintCommand(cmdp, jobp)
* string too, but why make it any more complex than
* it already is?
*/
- if (!(job->flags & JOB_SILENT) && !shutUp &&
+ if (! (job->flags & JOB_SILENT) && !shutUp &&
commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- DBPRINTF("%s\n", commandShell->ignErr);
- DBPRINTF("%s\n", commandShell->echoOn);
+ DBPRINTF ("%s\n", commandShell->echoOff);
+ DBPRINTF ("%s\n", commandShell->ignErr);
+ DBPRINTF ("%s\n", commandShell->echoOn);
} else {
- DBPRINTF("%s\n", commandShell->ignErr);
+ DBPRINTF ("%s\n", commandShell->ignErr);
}
} else if (commandShell->ignErr &&
- (*commandShell->ignErr != '\0'))
+ (*commandShell->ignErr != '\0'))
{
/*
* The shell has no error control, so we need to be
@@ -613,10 +503,10 @@ JobPrintCommand(cmdp, jobp)
* to ignore errors. Set cmdTemplate to use the weirdness
* instead of the simple "%s\n" template.
*/
- if (!(job->flags & JOB_SILENT) && !shutUp &&
+ if (! (job->flags & JOB_SILENT) && !shutUp &&
commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- DBPRINTF(commandShell->errCheck, cmd);
+ DBPRINTF ("%s\n", commandShell->echoOff);
+ DBPRINTF (commandShell->errCheck, cmd);
shutUp = TRUE;
}
cmdTemplate = commandShell->ignErr;
@@ -633,9 +523,9 @@ JobPrintCommand(cmdp, jobp)
errOff = FALSE;
}
}
-
- DBPRINTF(cmdTemplate, cmd);
-
+
+ DBPRINTF (cmdTemplate, cmd);
+
if (errOff) {
/*
* If echoing is already off, there's no point in issuing the
@@ -643,15 +533,15 @@ JobPrintCommand(cmdp, jobp)
* for the whole command...
*/
if (!shutUp && !(job->flags & JOB_SILENT) && commandShell->hasEchoCtl){
- DBPRINTF("%s\n", commandShell->echoOff);
+ DBPRINTF ("%s\n", commandShell->echoOff);
shutUp = TRUE;
}
- DBPRINTF("%s\n", commandShell->errCheck);
+ DBPRINTF ("%s\n", commandShell->errCheck);
}
if (shutUp) {
- DBPRINTF("%s\n", commandShell->echoOn);
+ DBPRINTF ("%s\n", commandShell->echoOn);
}
- return 0;
+ return (0);
}
/*-
@@ -669,48 +559,13 @@ JobPrintCommand(cmdp, jobp)
*-----------------------------------------------------------------------
*/
static int
-JobSaveCommand(cmd, gn)
+JobSaveCommand (cmd, gn)
ClientData cmd;
ClientData gn;
{
- cmd = (ClientData) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE);
- (void) Lst_AtEnd(postCommands->commands, cmd);
- return(0);
-}
-
-
-/*-
- *-----------------------------------------------------------------------
- * JobClose --
- * Called to close both input and output pipes when a job is finished.
- *
- * Results:
- * Nada
- *
- * Side Effects:
- * The file descriptors associated with the job are closed.
- *
- *-----------------------------------------------------------------------
- */
-static void
-JobClose(job)
- Job *job;
-{
- if (usePipes) {
-#ifdef RMT_WILL_WATCH
- Rmt_Ignore(job->inPipe);
-#else
- FD_CLR(job->inPipe, &outputs);
-#endif
- if (job->outPipe != job->inPipe) {
- (void) close(job->outPipe);
- }
- JobDoOutput(job, TRUE);
- (void) close(job->inPipe);
- } else {
- (void) close(job->outFd);
- JobDoOutput(job, TRUE);
- }
+ cmd = (ClientData) Var_Subst (NULL, (char *) cmd, (GNode *) gn, FALSE);
+ (void)Lst_AtEnd (postCommands->commands, cmd);
+ return (0);
}
/*-
@@ -738,15 +593,15 @@ JobClose(job)
*/
/*ARGSUSED*/
static void
-JobFinish(job, status)
- Job *job; /* job to finish */
- int *status; /* sub-why job went away */
+JobFinish (job, status)
+ Job *job; /* job to finish */
+ union wait status; /* sub-why job went away */
{
- Boolean done;
+ Boolean done;
- if ((WIFEXITED(*status) &&
- (((WEXITSTATUS(*status) != 0) && !(job->flags & JOB_IGNERR)))) ||
- (WIFSIGNALED(*status) && (WTERMSIG(*status) != SIGCONT)))
+ if ((WIFEXITED(status) &&
+ (((status.w_retcode != 0) && !(job->flags & JOB_IGNERR)))) ||
+ (WIFSIGNALED(status) && (status.w_termsig != SIGCONT)))
{
/*
* If it exited non-zero and either we're doing things our
@@ -756,109 +611,93 @@ JobFinish(job, status)
* cases, finish out the job's output before printing the exit
* status...
*/
-#ifdef REMOTE
- KILL(job->pid, SIGCONT);
-#endif
- JobClose(job);
+ if (usePipes) {
+#ifdef RMT_WILL_WATCH
+ Rmt_Ignore(job->inPipe);
+#else
+ FD_CLR(job->inPipe, &outputs);
+#endif /* RMT_WILL_WATCH */
+ if (job->outPipe != job->inPipe) {
+ (void)close (job->outPipe);
+ }
+ JobDoOutput (job, TRUE);
+ (void)close (job->inPipe);
+ } else {
+ (void)close (job->outFd);
+ JobDoOutput (job, TRUE);
+ }
+
if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
- (void) fclose(job->cmdFILE);
+ fclose(job->cmdFILE);
}
done = TRUE;
-#ifdef REMOTE
- if (job->flags & JOB_REMOTE)
- Rmt_Done(job->rmtID, job->node);
-#endif
- } else if (WIFEXITED(*status)) {
+ } else if (WIFEXITED(status) && status.w_retcode != 0) {
/*
* Deal with ignored errors in -B mode. We need to print a message
* telling of the ignored error as well as setting status.w_status
* to 0 so the next command gets run. To do this, we set done to be
- * TRUE if in -B mode and the job exited non-zero.
- */
- done = WEXITSTATUS(*status) != 0;
- /*
- * Old comment said: "Note we don't
+ * TRUE if in -B mode and the job exited non-zero. Note we don't
* want to close down any of the streams until we know we're at the
- * end."
- * But we do. Otherwise when are we going to print the rest of the
- * stuff?
+ * end.
*/
- JobClose(job);
-#ifdef REMOTE
- if (job->flags & JOB_REMOTE)
- Rmt_Done(job->rmtID, job->node);
-#endif /* REMOTE */
+ done = TRUE;
} else {
/*
* No need to close things down or anything.
*/
done = FALSE;
}
-
+
if (done ||
- WIFSTOPPED(*status) ||
- (WIFSIGNALED(*status) && (WTERMSIG(*status) == SIGCONT)) ||
+ WIFSTOPPED(status) ||
+ (WIFSIGNALED(status) && (status.w_termsig == SIGCONT)) ||
DEBUG(JOB))
{
FILE *out;
-
- if (compatMake && !usePipes && (job->flags & JOB_IGNERR)) {
+
+ if (!usePipes && (job->flags & JOB_IGNERR)) {
/*
* If output is going to a file and this job is ignoring
* errors, arrange to have the exit status sent to the
* output file as well.
*/
- out = fdopen(job->outFd, "w");
+ out = fdopen (job->outFd, "w");
} else {
out = stdout;
}
- if (WIFEXITED(*status)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d exited.\n", job->pid);
- (void) fflush(stdout);
- }
- if (WEXITSTATUS(*status) != 0) {
+ if (WIFEXITED(status)) {
+ if (status.w_retcode != 0) {
if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
+ fprintf (out, targFmt, job->node->name);
lastNode = job->node;
}
- (void) fprintf(out, "*** Error code %d%s\n",
- WEXITSTATUS(*status),
- (job->flags & JOB_IGNERR) ? "(ignored)" : "");
+ fprintf (out, "*** Error code %d%s\n", status.w_retcode,
+ (job->flags & JOB_IGNERR) ? " (ignored)" : "");
if (job->flags & JOB_IGNERR) {
- *status = 0;
+ status.w_status = 0;
}
} else if (DEBUG(JOB)) {
if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
+ fprintf (out, targFmt, job->node->name);
lastNode = job->node;
}
- (void) fprintf(out, "*** Completed successfully\n");
- }
- } else if (WIFSTOPPED(*status)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d stopped.\n", job->pid);
- (void) fflush(stdout);
+ fprintf (out, "*** Completed successfully\n");
}
+ } else if (WIFSTOPPED(status)) {
if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
+ fprintf (out, targFmt, job->node->name);
lastNode = job->node;
}
- if (!(job->flags & JOB_REMIGRATE)) {
- (void) fprintf(out, "*** Stopped -- signal %d\n",
- WSTOPSIG(*status));
+ if (! (job->flags & JOB_REMIGRATE)) {
+ fprintf (out, "*** Stopped -- signal %d\n", status.w_stopsig);
}
job->flags |= JOB_RESUME;
(void)Lst_AtEnd(stoppedJobs, (ClientData)job);
-#ifdef REMOTE
- if (job->flags & JOB_REMIGRATE)
- JobRestart(job);
-#endif
- (void) fflush(out);
+ fflush(out);
return;
- } else if (WTERMSIG(*status) == SIGCONT) {
+ } else if (status.w_termsig == SIGCONT) {
/*
* If the beastie has continued, shift the Job from the stopped
* list to the running one (or re-stop it if concurrency is
@@ -866,58 +705,37 @@ JobFinish(job, status)
*/
if (job->flags & (JOB_RESUME|JOB_REMIGRATE|JOB_RESTART)) {
if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
+ fprintf (out, targFmt, job->node->name);
lastNode = job->node;
}
- (void) fprintf(out, "*** Continued\n");
+ fprintf (out, "*** Continued\n");
}
- if (!(job->flags & JOB_CONTINUING)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Warning: process %d was not continuing.\n",
- job->pid);
- (void) fflush(stdout);
- }
-#ifdef notdef
- /*
- * We don't really want to restart a job from scratch just
- * because it continued, especially not without killing the
- * continuing process! That's why this is ifdef'ed out.
- * FD - 9/17/90
- */
+ if (! (job->flags & JOB_CONTINUING)) {
JobRestart(job);
-#endif
- }
- job->flags &= ~JOB_CONTINUING;
- Lst_AtEnd(jobs, (ClientData)job);
- nJobs += 1;
- if (!(job->flags & JOB_REMOTE)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Process %d is continuing locally.\n",
- job->pid);
- (void) fflush(stdout);
- }
- nLocal += 1;
+ } else {
+ Lst_AtEnd(jobs, (ClientData)job);
+ nJobs += 1;
+ if (! (job->flags & JOB_REMOTE)) {
+ nLocal += 1;
+ }
+ if (nJobs == maxJobs) {
+ jobFull = TRUE;
+ if (DEBUG(JOB)) {
+ printf("Job queue is full.\n");
+ }
+ }
}
- if (nJobs == maxJobs) {
- jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
- }
- (void) fflush(out);
- return;
+ fflush(out);
+ return;
} else {
if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
+ fprintf (out, targFmt, job->node->name);
lastNode = job->node;
}
- (void) fprintf(out, "*** Signal %d\n", WTERMSIG(*status));
+ fprintf (out, "*** Signal %d\n", status.w_termsig);
}
- (void) fflush(out);
+ fflush (out);
}
/*
@@ -925,36 +743,40 @@ JobFinish(job, status)
* try and restart the job on the next command. If JobStart says it's
* ok, it's ok. If there's an error, this puppy is done.
*/
- if (compatMake && (WIFEXITED(*status) &&
- !Lst_IsAtEnd(job->node->commands))) {
- switch (JobStart(job->node, job->flags & JOB_IGNDOTS, job)) {
- case JOB_RUNNING:
- done = FALSE;
- break;
- case JOB_ERROR:
- done = TRUE;
- W_SETEXITSTATUS(status, 1);
- break;
- case JOB_FINISHED:
- /*
- * If we got back a JOB_FINISHED code, JobStart has already
- * called Make_Update and freed the job descriptor. We set
- * done to false here to avoid fake cycles and double frees.
- * JobStart needs to do the update so we can proceed up the
- * graph when given the -n flag..
- */
- done = FALSE;
- break;
+ if ((status.w_status == 0) &&
+ !Lst_IsAtEnd (job->node->commands))
+ {
+ switch (JobStart (job->node,
+ job->flags & JOB_IGNDOTS,
+ job))
+ {
+ case JOB_RUNNING:
+ done = FALSE;
+ break;
+ case JOB_ERROR:
+ done = TRUE;
+ status.w_retcode = 1;
+ break;
+ case JOB_FINISHED:
+ /*
+ * If we got back a JOB_FINISHED code, JobStart has already
+ * called Make_Update and freed the job descriptor. We set
+ * done to false here to avoid fake cycles and double frees.
+ * JobStart needs to do the update so we can proceed up the
+ * graph when given the -n flag..
+ */
+ done = FALSE;
+ break;
}
} else {
done = TRUE;
}
-
+
if (done &&
(aborting != ABORT_ERROR) &&
(aborting != ABORT_INTERRUPT) &&
- (*status == 0))
+ (status.w_status == 0))
{
/*
* As long as we aren't aborting and the job didn't return a non-zero
@@ -963,19 +785,21 @@ JobFinish(job, status)
* on the .END target.
*/
if (job->tailCmds != NILLNODE) {
- Lst_ForEachFrom(job->node->commands, job->tailCmds,
+ Lst_ForEachFrom (job->node->commands, job->tailCmds,
JobSaveCommand,
- (ClientData)job->node);
+ (ClientData)job->node);
}
job->node->made = MADE;
- Make_Update(job->node);
+ Make_Update (job->node);
free((Address)job);
- } else if (*status != 0) {
+ } else if (status.w_status) {
errors += 1;
free((Address)job);
}
- JobRestartJobs();
+ while (!errors && !jobFull && !Lst_IsEmpty(stoppedJobs)) {
+ JobRestart((Job *)Lst_DeQueue(stoppedJobs));
+ }
/*
* Set aborting if any error.
@@ -988,13 +812,13 @@ JobFinish(job, status)
*/
aborting = ABORT_ERROR;
}
-
+
if ((aborting == ABORT_ERROR) && Job_Empty()) {
/*
* If we are aborting and the job table is now empty, we finish.
*/
- (void) eunlink(tfile);
- Finish(errors);
+ (void) unlink (tfile);
+ Finish (errors);
}
}
@@ -1013,12 +837,12 @@ JobFinish(job, status)
*-----------------------------------------------------------------------
*/
void
-Job_Touch(gn, silent)
+Job_Touch (gn, silent)
GNode *gn; /* the node of the file to touch */
Boolean silent; /* TRUE if should not print messages */
{
int streamID; /* ID of stream opened to do the touch */
- struct utimbuf times; /* Times for utime() call */
+ struct timeval times[2]; /* Times for utimes() call */
if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL)) {
/*
@@ -1027,10 +851,9 @@ Job_Touch(gn, silent)
*/
return;
}
-
+
if (!silent) {
- (void) fprintf(stdout, "touch %s\n", gn->name);
- (void) fflush(stdout);
+ printf ("touch %s\n", gn->name);
}
if (noExecute) {
@@ -1038,15 +861,16 @@ Job_Touch(gn, silent)
}
if (gn->type & OP_ARCHV) {
- Arch_Touch(gn);
+ Arch_Touch (gn);
} else if (gn->type & OP_LIB) {
- Arch_TouchLib(gn);
+ Arch_TouchLib (gn);
} else {
char *file = gn->path ? gn->path : gn->name;
- times.actime = times.modtime = now;
- if (utime(file, &times) < 0){
- streamID = open(file, O_RDWR | O_CREAT, 0666);
+ times[0].tv_sec = times[1].tv_sec = now;
+ times[0].tv_usec = times[1].tv_usec = 0;
+ if (utimes(file, times) < 0){
+ streamID = open (file, O_RDWR | O_CREAT, 0666);
if (streamID >= 0) {
char c;
@@ -1056,16 +880,13 @@ Job_Touch(gn, silent)
* modification time, then close the file.
*/
if (read(streamID, &c, 1) == 1) {
- (void) lseek(streamID, 0L, L_SET);
- (void) write(streamID, &c, 1);
+ lseek(streamID, 0L, L_SET);
+ write(streamID, &c, 1);
}
-
- (void) close(streamID);
- } else {
- (void) fprintf(stdout, "*** couldn't touch %s: %s",
- file, strerror(errno));
- (void) fflush(stdout);
- }
+
+ (void)close (streamID);
+ } else
+ printf("*** couldn't touch %s: %s", file, strerror(errno));
}
}
}
@@ -1073,7 +894,7 @@ Job_Touch(gn, silent)
/*-
*-----------------------------------------------------------------------
* Job_CheckCommands --
- * Make sure the given node has all the commands it needs.
+ * Make sure the given node has all the commands it needs.
*
* Results:
* TRUE if the commands list is/was ok.
@@ -1084,17 +905,17 @@ Job_Touch(gn, silent)
*-----------------------------------------------------------------------
*/
Boolean
-Job_CheckCommands(gn, abortProc)
+Job_CheckCommands (gn, abortProc)
GNode *gn; /* The target whose commands need
* verifying */
- void (*abortProc) __P((char *, ...));
+ void (*abortProc) __P((char *, ...));
/* Function to abort with message */
{
- if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) &&
+ if (OP_NOP(gn->type) && Lst_IsEmpty (gn->commands) &&
(gn->type & OP_LIB) == 0) {
/*
* No commands. Look for .DEFAULT rule from which we might infer
- * commands
+ * commands
*/
if ((DEFAULT != NILGNODE) && !Lst_IsEmpty(DEFAULT->commands)) {
char *p1;
@@ -1108,33 +929,32 @@ Job_CheckCommands(gn, abortProc)
* .DEFAULT itself.
*/
Make_HandleUse(DEFAULT, gn);
- Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
+ Var_Set (IMPSRC, Var_Value (TARGET, gn, &p1), gn);
if (p1)
free(p1);
- } else if (Dir_MTime(gn) == 0) {
+ } else if (Dir_MTime (gn) == 0) {
/*
* The node wasn't the target of an operator we have no .DEFAULT
* rule to go on and the target doesn't already exist. There's
* nothing more we can do for this branch. If the -k flag wasn't
* given, we stop in our tracks, otherwise we just don't update
- * this node's parents so they never get examined.
+ * this node's parents so they never get examined.
*/
- static const char msg[] = "make: don't know how to make";
-
if (gn->type & OP_OPTIONAL) {
- (void) fprintf(stdout, "%s %s(ignored)\n", msg, gn->name);
- (void) fflush(stdout);
+ printf ("make: don't know how to make %s (ignored)\n",
+ gn->name);
} else if (keepgoing) {
- (void) fprintf(stdout, "%s %s(continuing)\n", msg, gn->name);
- (void) fflush(stdout);
- return FALSE;
+ printf ("make: don't know how to make %s (continuing)\n",
+ gn->name);
+ return (FALSE);
} else {
- (*abortProc)("%s %s. Stop", msg, gn->name);
- return FALSE;
+ (*abortProc) ("make: don't know how to make %s. Stop",
+ gn->name);
+ return(FALSE);
}
}
}
- return TRUE;
+ return (TRUE);
}
#ifdef RMT_WILL_WATCH
/*-
@@ -1147,7 +967,7 @@ Job_CheckCommands(gn, abortProc)
*
* Side Effects:
* JobDoOutput is called.
- *
+ *
*-----------------------------------------------------------------------
*/
/*ARGSUSED*/
@@ -1181,20 +1001,19 @@ JobExec(job, argv)
char **argv;
{
int cpid; /* ID of new child */
-
+
if (DEBUG(JOB)) {
int i;
-
- (void) fprintf(stdout, "Running %s %sly\n", job->node->name,
- job->flags&JOB_REMOTE?"remote":"local");
- (void) fprintf(stdout, "\tCommand: ");
- for (i = 0; argv[i] != NULL; i++) {
- (void) fprintf(stdout, "%s ", argv[i]);
+
+ printf("Running %s %sly\n", job->node->name,
+ job->flags&JOB_REMOTE?"remote":"local");
+ printf("\tCommand: ");
+ for (i = 0; argv[i] != (char *)NULL; i++) {
+ printf("%s ", argv[i]);
}
- (void) fprintf(stdout, "\n");
- (void) fflush(stdout);
+ printf("\n");
}
-
+
/*
* Some jobs produce no output and it's disconcerting to have
* no feedback of their running (since they produce no output, the
@@ -1202,19 +1021,20 @@ JobExec(job, argv)
* provide that feedback, even if nothing follows it.
*/
if ((lastNode != job->node) && (job->flags & JOB_FIRST) &&
- !(job->flags & JOB_SILENT)) {
- MESSAGE(stdout, job->node);
+ !(job->flags & JOB_SILENT))
+ {
+ printf(targFmt, job->node->name);
lastNode = job->node;
}
-
+
#ifdef RMT_NO_EXEC
if (job->flags & JOB_REMOTE) {
goto jobExecFinish;
}
#endif /* RMT_NO_EXEC */
- if ((cpid = vfork()) == -1) {
- Punt("Cannot fork");
+ if ((cpid = vfork()) == -1) {
+ Punt ("Cannot fork");
} else if (cpid == 0) {
/*
@@ -1222,26 +1042,23 @@ JobExec(job, argv)
* reset it to the beginning (again). Since the stream was marked
* close-on-exec, we must clear that bit in the new input.
*/
- if (dup2(FILENO(job->cmdFILE), 0) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
- (void) fcntl(0, F_SETFD, 0);
- (void) lseek(0, 0, L_SET);
-
+ (void) dup2(fileno(job->cmdFILE), 0);
+ fcntl(0, F_SETFD, 0);
+ lseek(0, 0, L_SET);
+
if (usePipes) {
/*
* Set up the child's output to be routed through the pipe
* we've created for it.
*/
- if (dup2(job->outPipe, 1) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
+ (void) dup2 (job->outPipe, 1);
} else {
/*
* We're capturing output in a file, so we duplicate the
* descriptor to the temporary file into the standard
* output.
*/
- if (dup2(job->outFd, 1) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
+ (void) dup2 (job->outFd, 1);
}
/*
* The output channels are marked close on exec. This bit was
@@ -1249,9 +1066,8 @@ JobExec(job, argv)
* it before routing the shell's error output to the same place as
* its standard output.
*/
- (void) fcntl(1, F_SETFD, 0);
- if (dup2(1, 2) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
+ fcntl(1, F_SETFD, 0);
+ (void) dup2 (1, 2);
#ifdef USE_PGRP
/*
@@ -1259,27 +1075,15 @@ JobExec(job, argv)
* we can kill it and all its descendants in one fell swoop,
* by killing its process family, but not commit suicide.
*/
-# if defined(SYSV)
- (void) setsid();
-# else
- (void) setpgid(0, getpid());
-# endif
-#endif /* USE_PGRP */
-
-#ifdef REMOTE
- if (job->flags & JOB_REMOTE) {
- Rmt_Exec(shellPath, argv, FALSE);
- } else
-#endif /* REMOTE */
- (void) execv(shellPath, argv);
-
- (void) write(2, "Could not execute shell\n",
- sizeof("Could not execute shell"));
- _exit(1);
+
+ (void) setpgrp(0, getpid());
+#endif USE_PGRP
+
+ (void) execv (shellPath, argv);
+ (void) write (2, "Could not execute shell\n",
+ sizeof ("Could not execute shell"));
+ _exit (1);
} else {
-#ifdef REMOTE
- long omask = sigblock(sigmask(SIGCHLD));
-#endif
job->pid = cpid;
if (usePipes && (job->flags & JOB_FIRST) ) {
@@ -1289,7 +1093,7 @@ JobExec(job, argv)
* stream to watch in the outputs mask
*/
job->curPos = 0;
-
+
#ifdef RMT_WILL_WATCH
Rmt_Watch(job->inPipe, JobLocalInput, job);
#else
@@ -1298,34 +1102,27 @@ JobExec(job, argv)
}
if (job->flags & JOB_REMOTE) {
-#ifndef REMOTE
job->rmtID = 0;
-#else
- job->rmtID = Rmt_LastID(job->pid);
-#endif /* REMOTE */
} else {
nLocal += 1;
/*
- * XXX: Used to not happen if REMOTE. Why?
+ * XXX: Used to not happen if CUSTOMS. Why?
*/
- if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
- (void) fclose(job->cmdFILE);
+ if (job->cmdFILE != stdout) {
+ fclose(job->cmdFILE);
job->cmdFILE = NULL;
}
}
-#ifdef REMOTE
- (void) sigsetmask(omask);
-#endif
}
#ifdef RMT_NO_EXEC
-jobExecFinish:
+jobExecFinish:
#endif
/*
* Now the job is actually running, add it to the table.
*/
nJobs += 1;
- (void) Lst_AtEnd(jobs, (ClientData)job);
+ (void)Lst_AtEnd (jobs, (ClientData)job);
if (nJobs == maxJobs) {
jobFull = TRUE;
}
@@ -1335,7 +1132,7 @@ jobExecFinish:
*-----------------------------------------------------------------------
* JobMakeArgv --
* Create the argv needed to execute the shell for a given job.
- *
+ *
*
* Results:
*
@@ -1350,7 +1147,7 @@ JobMakeArgv(job, argv)
{
int argc;
static char args[10]; /* For merged arguments */
-
+
argv[0] = shellName;
argc = 1;
@@ -1383,13 +1180,13 @@ JobMakeArgv(job, argv)
argc++;
}
}
- argv[argc] = NULL;
+ argv[argc] = (char *)NULL;
}
/*-
*-----------------------------------------------------------------------
* JobRestart --
- * Restart a job that stopped for some reason.
+ * Restart a job that stopped for some reason.
*
* Results:
* None.
@@ -1403,91 +1200,44 @@ static void
JobRestart(job)
Job *job; /* Job to restart */
{
-#ifdef REMOTE
- int host;
-#endif
-
if (job->flags & JOB_REMIGRATE) {
- if (
-#ifdef REMOTE
- verboseRemigrates ||
-#endif
- DEBUG(JOB)) {
- (void) fprintf(stdout, "*** remigrating %x(%s)\n",
- job->pid, job->node->name);
- (void) fflush(stdout);
+ if (DEBUG(JOB)) {
+ printf("Remigrating %x\n", job->pid);
}
-
-#ifdef REMOTE
- if (!Rmt_ReExport(job->pid, job->node, &host)) {
- if (verboseRemigrates || DEBUG(JOB)) {
- (void) fprintf(stdout, "*** couldn't migrate...\n");
- (void) fflush(stdout);
- }
-#endif
- if (nLocal != maxLocal) {
+ if (nLocal != maxLocal) {
/*
* Job cannot be remigrated, but there's room on the local
* machine, so resume the job and note that another
* local job has started.
*/
- if (
-#ifdef REMOTE
- verboseRemigrates ||
-#endif
- DEBUG(JOB)) {
- (void) fprintf(stdout, "*** resuming on local machine\n");
- (void) fflush(stdout);
- }
+ if (DEBUG(JOB)) {
+ printf("resuming on local machine\n");
+ }
KILL(job->pid, SIGCONT);
nLocal +=1;
-#ifdef REMOTE
- job->flags &= ~(JOB_REMIGRATE|JOB_RESUME|JOB_REMOTE);
- job->flags |= JOB_CONTINUING;
-#else
job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
-#endif
} else {
/*
* Job cannot be restarted. Mark the table as full and
* place the job back on the list of stopped jobs.
*/
- if (
-#ifdef REMOTE
- verboseRemigrates ||
-#endif
- DEBUG(JOB)) {
- (void) fprintf(stdout, "*** holding\n");
- (void) fflush(stdout);
- }
+ if (DEBUG(JOB)) {
+ printf("holding\n");
+ }
(void)Lst_AtFront(stoppedJobs, (ClientData)job);
jobFull = TRUE;
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
+ printf("Job queue is full.\n");
}
return;
- }
-#ifdef REMOTE
- } else {
- /*
- * Clear out the remigrate and resume flags. Set the continuing
- * flag so we know later on that the process isn't exiting just
- * because of a signal.
- */
- job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
- job->flags |= JOB_CONTINUING;
- job->rmtID = host;
}
-#endif
-
+
(void)Lst_AtEnd(jobs, (ClientData)job);
nJobs += 1;
if (nJobs == maxJobs) {
jobFull = TRUE;
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
+ printf("Job queue is full.\n");
}
}
} else if (job->flags & JOB_RESTART) {
@@ -1497,65 +1247,38 @@ JobRestart(job)
* the 'exit' flag of the commandShell is used to cause it to exit
* upon receiving an error. If the JOB_SILENT flag is clear, the
* 'echo' flag of the commandShell is used to get it to start echoing
- * as soon as it starts processing commands.
+ * as soon as it starts processing commands.
*/
char *argv[4];
-
+
JobMakeArgv(job, argv);
-
+
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Restarting %s...", job->node->name);
- (void) fflush(stdout);
+ printf("Restarting %s...", job->node->name);
}
-#ifdef REMOTE
- if ((job->node->type&OP_NOEXPORT) ||
- (nLocal < maxLocal && runLocalFirst)
-# ifdef RMT_NO_EXEC
- || !Rmt_Export(shellPath, argv, job)
-# else
- || !Rmt_Begin(shellPath, argv, job->node)
-# endif
-#endif
- {
- if (((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL))) {
+ if (((nLocal >= maxLocal) && ! (job->flags & JOB_SPECIAL))) {
/*
* Can't be exported and not allowed to run locally -- put it
* back on the hold queue and mark the table full
*/
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "holding\n");
- (void) fflush(stdout);
+ printf("holding\n");
}
(void)Lst_AtFront(stoppedJobs, (ClientData)job);
jobFull = TRUE;
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
+ printf("Job queue is full.\n");
}
return;
- } else {
+ } else {
/*
* Job may be run locally.
*/
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "running locally\n");
- (void) fflush(stdout);
+ printf("running locally\n");
}
job->flags &= ~JOB_REMOTE;
- }
}
-#ifdef REMOTE
- else {
- /*
- * Can be exported. Hooray!
- */
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "exporting\n");
- (void) fflush(stdout);
- }
- job->flags |= JOB_REMOTE;
- }
-#endif
JobExec(job, argv);
} else {
/*
@@ -1563,20 +1286,13 @@ JobRestart(job)
* we don't know...
*/
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Resuming %s...", job->node->name);
- (void) fflush(stdout);
+ printf("Resuming %s...", job->node->name);
}
if (((job->flags & JOB_REMOTE) ||
- (nLocal < maxLocal) ||
-#ifdef REMOTE
- (((job->flags & JOB_SPECIAL) &&
- (job->node->type & OP_NOEXPORT)) &&
- (maxLocal == 0))) &&
-#else
- ((job->flags & JOB_SPECIAL) &&
- (maxLocal == 0))) &&
-#endif
- (nJobs != maxJobs))
+ (nLocal < maxLocal) ||
+ (((job->flags & JOB_SPECIAL)) &&
+ (maxLocal == 0))) &&
+ (nJobs != maxJobs))
{
/*
* If the job is remote, it's ok to resume it as long as the
@@ -1587,8 +1303,8 @@ JobRestart(job)
*/
Boolean error;
extern int errno;
- int status;
-
+ union wait status;
+
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
error = !Rmt_Signal(job, SIGCONT);
@@ -1602,20 +1318,19 @@ JobRestart(job)
* actually put the thing in the job table.
*/
job->flags |= JOB_CONTINUING;
- W_SETTERMSIG(&status, SIGCONT);
- JobFinish(job, &status);
-
+ status.w_termsig = SIGCONT;
+ JobFinish(job, status);
+
job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "done\n");
- (void) fflush(stdout);
+ printf("done\n");
}
} else {
Error("couldn't resume %s: %s",
job->node->name, strerror(errno));
- status = 0;
- W_SETEXITSTATUS(&status, 1);
- JobFinish(job, &status);
+ status.w_status = 0;
+ status.w_retcode = 1;
+ JobFinish(job, status);
}
} else {
/*
@@ -1623,14 +1338,12 @@ JobRestart(job)
* place the job back on the list of stopped jobs.
*/
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "table full\n");
- (void) fflush(stdout);
+ printf("table full\n");
}
- (void) Lst_AtFront(stoppedJobs, (ClientData)job);
+ (void)Lst_AtFront(stoppedJobs, (ClientData)job);
jobFull = TRUE;
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
+ printf("Job queue is full.\n");
}
}
}
@@ -1640,7 +1353,7 @@ JobRestart(job)
*-----------------------------------------------------------------------
* JobStart --
* Start a target-creation process going for the target described
- * by the graph node gn.
+ * by the graph node gn.
*
* Results:
* JOB_ERROR if there was an error in the commands, JOB_FINISHED
@@ -1653,7 +1366,7 @@ JobRestart(job)
*-----------------------------------------------------------------------
*/
static int
-JobStart(gn, flags, previous)
+JobStart (gn, flags, previous)
GNode *gn; /* target to create */
int flags; /* flags for the job to override normal ones.
* e.g. JOB_SPECIAL or JOB_IGNDOTS */
@@ -1667,12 +1380,12 @@ JobStart(gn, flags, previous)
Boolean local; /* Set true if the job was run locally */
Boolean noExec; /* Set true if we decide not to run the job */
- if (previous != NULL) {
- previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT|JOB_REMOTE);
+ if (previous != (Job *)NULL) {
+ previous->flags &= ~ (JOB_FIRST|JOB_IGNERR|JOB_SILENT|JOB_REMOTE);
job = previous;
} else {
- job = (Job *) emalloc(sizeof(Job));
- if (job == NULL) {
+ job = (Job *) emalloc (sizeof (Job));
+ if (job == (Job *)NULL) {
Punt("JobStart out of memory");
}
flags |= JOB_FIRST;
@@ -1687,10 +1400,10 @@ JobStart(gn, flags, previous)
* are also added to the field.
*/
job->flags = 0;
- if (Targ_Ignore(gn)) {
+ if (Targ_Ignore (gn)) {
job->flags |= JOB_IGNERR;
}
- if (Targ_Silent(gn)) {
+ if (Targ_Silent (gn)) {
job->flags |= JOB_SILENT;
}
job->flags |= flags;
@@ -1699,12 +1412,12 @@ JobStart(gn, flags, previous)
* Check the commands now so any attributes from .DEFAULT have a chance
* to migrate to the node
*/
- if (!compatMake && job->flags & JOB_FIRST) {
+ if (job->flags & JOB_FIRST) {
cmdsOK = Job_CheckCommands(gn, Error);
} else {
cmdsOK = TRUE;
}
-
+
/*
* If the -n flag wasn't given, we open up OUR (not the child's)
* temporary file to stuff commands in it. The thing is rd/wr so we don't
@@ -1719,12 +1432,12 @@ JobStart(gn, flags, previous)
if (!cmdsOK) {
DieHorribly();
}
-
- job->cmdFILE = fopen(tfile, "w+");
- if (job->cmdFILE == NULL) {
- Punt("Could not open %s", tfile);
+
+ job->cmdFILE = fopen (tfile, "w+");
+ if (job->cmdFILE == (FILE *) NULL) {
+ Punt ("Could not open %s", tfile);
}
- (void) fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
+ fcntl(fileno(job->cmdFILE), F_SETFD, 1);
/*
* Send the commands to the command file, flush all its buffers then
* rewind and remove the thing.
@@ -1747,14 +1460,13 @@ JobStart(gn, flags, previous)
if ((job->flags&JOB_FIRST) && (Lst_Open(gn->commands) != SUCCESS)){
cmdsOK = FALSE;
} else {
- LstNode ln = Lst_Next(gn->commands);
-
+ LstNode ln = Lst_Next (gn->commands);
+
if ((ln == NILLNODE) ||
- JobPrintCommand((ClientData) Lst_Datum(ln),
- (ClientData) job))
+ JobPrintCommand ((char *)Lst_Datum (ln), job))
{
noExec = TRUE;
- Lst_Close(gn->commands);
+ Lst_Close (gn->commands);
}
if (noExec && !(job->flags & JOB_FIRST)) {
/*
@@ -1768,7 +1480,21 @@ JobStart(gn, flags, previous)
* Job_CatchChildren b/c it wasn't clear if there were
* more commands to execute or not...
*/
- JobClose(job);
+ if (usePipes) {
+#ifdef RMT_WILL_WATCH
+ Rmt_Ignore(job->inPipe);
+#else
+ FD_CLR(job->inPipe, &outputs);
+#endif
+ if (job->outPipe != job->inPipe) {
+ (void)close (job->outPipe);
+ }
+ JobDoOutput (job, TRUE);
+ (void)close (job->inPipe);
+ } else {
+ (void)close (job->outFd);
+ JobDoOutput (job, TRUE);
+ }
}
}
} else {
@@ -1776,8 +1502,8 @@ JobStart(gn, flags, previous)
* We can do all the commands at once. hooray for sanity
*/
numCommands = 0;
- Lst_ForEach(gn->commands, JobPrintCommand, (ClientData)job);
-
+ Lst_ForEach (gn->commands, JobPrintCommand, (ClientData)job);
+
/*
* If we didn't print out any commands to the shell script,
* there's not much point in executing the shell, is there?
@@ -1792,7 +1518,7 @@ JobStart(gn, flags, previous)
* in one fell swoop. This will still set up job->tailCmds correctly.
*/
if (lastNode != gn) {
- MESSAGE(stdout, gn);
+ printf (targFmt, gn->name);
lastNode = gn;
}
job->cmdFILE = stdout;
@@ -1816,23 +1542,22 @@ JobStart(gn, flags, previous)
* up the graph.
*/
job->cmdFILE = stdout;
- Job_Touch(gn, job->flags&JOB_SILENT);
+ Job_Touch (gn, job->flags&JOB_SILENT);
noExec = TRUE;
}
/*
- * If we're not supposed to execute a shell, don't.
+ * If we're not supposed to execute a shell, don't.
*/
if (noExec) {
/*
* Unlink and close the command file if we opened one
*/
if (job->cmdFILE != stdout) {
- (void) eunlink(tfile);
- if (job->cmdFILE != NULL)
- (void) fclose(job->cmdFILE);
+ (void) unlink (tfile);
+ fclose(job->cmdFILE);
} else {
- (void) fflush(stdout);
+ fflush (stdout);
}
/*
@@ -1844,7 +1569,7 @@ JobStart(gn, flags, previous)
if (job->tailCmds != NILLNODE) {
Lst_ForEachFrom(job->node->commands, job->tailCmds,
JobSaveCommand,
- (ClientData)job->node);
+ (ClientData)job->node);
}
Make_Update(job->node);
}
@@ -1855,8 +1580,8 @@ JobStart(gn, flags, previous)
return(JOB_ERROR);
}
} else {
- (void) fflush(job->cmdFILE);
- (void) eunlink(tfile);
+ fflush (job->cmdFILE);
+ (void) unlink (tfile);
}
/*
@@ -1871,47 +1596,29 @@ JobStart(gn, flags, previous)
* starting a job and then set up its temporary-file name. This is just
* tfile with two extra digits tacked on -- jobno.
*/
- if (!compatMake || (job->flags & JOB_FIRST)) {
+ if (job->flags & JOB_FIRST) {
if (usePipes) {
int fd[2];
- if (pipe(fd) == -1)
- Punt("Cannot create pipe: %s", strerror(errno));
+ (void) pipe(fd);
job->inPipe = fd[0];
job->outPipe = fd[1];
- (void) fcntl(job->inPipe, F_SETFD, 1);
- (void) fcntl(job->outPipe, F_SETFD, 1);
+ (void)fcntl (job->inPipe, F_SETFD, 1);
+ (void)fcntl (job->outPipe, F_SETFD, 1);
} else {
- (void) fprintf(stdout, "Remaking `%s'\n", gn->name);
- (void) fflush(stdout);
- sprintf(job->outFile, "%s%02d", tfile, jobno);
+ printf ("Remaking `%s'\n", gn->name);
+ fflush (stdout);
+ sprintf (job->outFile, "%s%02d", tfile, jobno);
jobno = (jobno + 1) % 100;
job->outFd = open(job->outFile,O_WRONLY|O_CREAT|O_APPEND,0600);
- (void) fcntl(job->outFd, F_SETFD, 1);
+ (void)fcntl (job->outFd, F_SETFD, 1);
}
}
-#ifdef REMOTE
- if (!(gn->type & OP_NOEXPORT) && !(runLocalFirst && nLocal < maxLocal)) {
-#ifdef RMT_NO_EXEC
- local = !Rmt_Export(shellPath, argv, job);
-#else
- local = !Rmt_Begin(shellPath, argv, job->node);
-#endif /* RMT_NO_EXEC */
- if (!local) {
- job->flags |= JOB_REMOTE;
- }
- } else
-#endif
- local = TRUE;
+ local = TRUE;
if (local && (((nLocal >= maxLocal) &&
- !(job->flags & JOB_SPECIAL) &&
-#ifdef REMOTE
- (!(gn->type & OP_NOEXPORT) || (maxLocal != 0))
-#else
- (maxLocal != 0)
-#endif
- )))
+ !(job->flags & JOB_SPECIAL) &&
+ (maxLocal != 0))))
{
/*
* The job can only be run locally, but we've hit the limit of
@@ -1919,17 +1626,15 @@ JobStart(gn, flags, previous)
* finishes. Note that the special jobs (.BEGIN, .INTERRUPT and .END)
* may be run locally even when the local limit has been reached
* (e.g. when maxLocal == 0), though they will be exported if at
- * all possible. In addition, any target marked with .NOEXPORT will
- * be run locally if maxLocal is 0.
+ * all possible.
*/
jobFull = TRUE;
-
+
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Can only run job locally.\n");
- (void) fflush(stdout);
+ printf("Can only run job locally.\n");
}
job->flags |= JOB_RESTART;
- (void) Lst_AtEnd(stoppedJobs, (ClientData)job);
+ (void)Lst_AtEnd(stoppedJobs, (ClientData)job);
} else {
if ((nLocal >= maxLocal) && local) {
/*
@@ -1938,8 +1643,7 @@ JobStart(gn, flags, previous)
*/
jobFull = TRUE;
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Local job queue is full.\n");
- (void) fflush(stdout);
+ printf("Local job queue is full.\n");
}
}
JobExec(job, argv);
@@ -1947,52 +1651,6 @@ JobStart(gn, flags, previous)
return(JOB_RUNNING);
}
-static char *
-JobOutput(job, cp, endp, msg)
- register Job *job;
- register char *cp, *endp;
- int msg;
-{
- register char *ecp;
-
- if (commandShell->noPrint) {
- ecp = Str_FindSubstring(cp, commandShell->noPrint);
- while (ecp != NULL) {
- if (cp != ecp) {
- *ecp = '\0';
- if (msg && job->node != lastNode) {
- MESSAGE(stdout, job->node);
- lastNode = job->node;
- }
- /*
- * The only way there wouldn't be a newline after
- * this line is if it were the last in the buffer.
- * however, since the non-printable comes after it,
- * there must be a newline, so we don't print one.
- */
- (void) fprintf(stdout, "%s", cp);
- (void) fflush(stdout);
- }
- cp = ecp + commandShell->noPLen;
- if (cp != endp) {
- /*
- * Still more to print, look again after skipping
- * the whitespace following the non-printable
- * command....
- */
- cp++;
- while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
- cp++;
- }
- ecp = Str_FindSubstring(cp, commandShell->noPrint);
- } else {
- return cp;
- }
- }
- }
- return cp;
-}
-
/*-
*-----------------------------------------------------------------------
* JobDoOutput --
@@ -2020,14 +1678,13 @@ JobOutput(job, cp, endp, msg)
* curPos may be shifted as may the contents of outBuf.
*-----------------------------------------------------------------------
*/
-STATIC void
-JobDoOutput(job, finish)
+static void
+JobDoOutput (job, finish)
register Job *job; /* the job whose output needs printing */
Boolean finish; /* TRUE if this is the last time we'll be
* called for this job */
{
Boolean gotNL = FALSE; /* true if got a newline */
- Boolean fbuf; /* true if our buffer filled up */
register int nr; /* number of bytes read */
register int i; /* auxiliary index into outBuf */
register int max; /* limit for i (end of current data) */
@@ -2036,16 +1693,14 @@ JobDoOutput(job, finish)
FILE *oFILE; /* Stream pointer to shell's output file */
char inLine[132];
-
+
if (usePipes) {
/*
* Read as many bytes as will fit in the buffer.
*/
end_loop:
- gotNL = FALSE;
- fbuf = FALSE;
-
- nRead = read(job->inPipe, &job->outBuf[job->curPos],
+
+ nRead = read (job->inPipe, &job->outBuf[job->curPos],
JOB_BUFSIZE - job->curPos);
if (nRead < 0) {
if (DEBUG(JOB)) {
@@ -2069,11 +1724,11 @@ end_loop:
} else if (nr == 0) {
finish = FALSE;
}
-
+
/*
* Look for the last newline in the bytes we just got. If there is
* one, break out of the loop with 'i' as its index and gotNL set
- * TRUE.
+ * TRUE.
*/
max = job->curPos + nr;
for (i = job->curPos + nr - 1; i >= job->curPos; i--) {
@@ -2087,19 +1742,19 @@ end_loop:
job->outBuf[i] = ' ';
}
}
-
+
if (!gotNL) {
job->curPos += nr;
if (job->curPos == JOB_BUFSIZE) {
/*
* If we've run out of buffer space, we have no choice
- * but to print the stuff. sigh.
+ * but to print the stuff. sigh.
*/
- fbuf = TRUE;
+ gotNL = TRUE;
i = job->curPos;
}
}
- if (gotNL || fbuf) {
+ if (gotNL) {
/*
* Need to send the output to the screen. Null terminate it
* first, overwriting the newline character if there was one.
@@ -2108,13 +1763,49 @@ end_loop:
* by a target banner if this target isn't the same as the
* one for which we last printed something.
* The rest of the data in the buffer are then shifted down
- * to the start of the buffer and curPos is set accordingly.
+ * to the start of the buffer and curPos is set accordingly.
*/
job->outBuf[i] = '\0';
if (i >= job->curPos) {
- char *cp;
-
- cp = JobOutput(job, job->outBuf, &job->outBuf[i], FALSE);
+ register char *cp, *ecp;
+
+ cp = job->outBuf;
+ if (commandShell->noPrint) {
+ ecp = Str_FindSubstring(job->outBuf,
+ commandShell->noPrint);
+ while (ecp != (char *)NULL) {
+ if (cp != ecp) {
+ *ecp = '\0';
+ if (job->node != lastNode) {
+ printf (targFmt, job->node->name);
+ lastNode = job->node;
+ }
+ /*
+ * The only way there wouldn't be a newline after
+ * this line is if it were the last in the buffer.
+ * however, since the non-printable comes after it,
+ * there must be a newline, so we don't print one.
+ */
+ printf ("%s", cp);
+ }
+ cp = ecp + commandShell->noPLen;
+ if (cp != &job->outBuf[i]) {
+ /*
+ * Still more to print, look again after skipping
+ * the whitespace following the non-printable
+ * command....
+ */
+ cp++;
+ while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
+ cp++;
+ }
+ ecp = Str_FindSubstring (cp,
+ commandShell->noPrint);
+ } else {
+ break;
+ }
+ }
+ }
/*
* There's still more in that thar buffer. This time, though,
@@ -2123,18 +1814,19 @@ end_loop:
*/
if (*cp != '\0') {
if (job->node != lastNode) {
- MESSAGE(stdout, job->node);
+ printf (targFmt, job->node->name);
lastNode = job->node;
}
- (void) fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
- (void) fflush(stdout);
+ printf ("%s\n", cp);
}
+
+ fflush (stdout);
}
if (i < max - 1) {
/* shift the remaining characters down */
- (void) memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
+ memcpy ( job->outBuf, &job->outBuf[i + 1], max - (i + 1));
job->curPos = max - (i + 1);
-
+
} else {
/*
* We have written everything out, so we just start over
@@ -2146,11 +1838,10 @@ end_loop:
if (finish) {
/*
* If the finish flag is true, we must loop until we hit
- * end-of-file on the pipe. This is guaranteed to happen
- * eventually since the other end of the pipe is now closed
- * (we closed it explicitly and the child has exited). When
- * we do get an EOF, finish will be set FALSE and we'll fall
- * through and out.
+ * end-of-file on the pipe. This is guaranteed to happen eventually
+ * since the other end of the pipe is now closed (we closed it
+ * explicitly and the child has exited). When we do get an EOF,
+ * finish will be set FALSE and we'll fall through and out.
*/
goto end_loop;
}
@@ -2165,36 +1856,62 @@ end_loop:
* Change to read in blocks and do FindSubString type things as for
* pipes? That would allow for "@echo -n..."
*/
- oFILE = fopen(job->outFile, "r");
- if (oFILE != NULL) {
- (void) fprintf(stdout, "Results of making %s:\n", job->node->name);
- (void) fflush(stdout);
- while (fgets(inLine, sizeof(inLine), oFILE) != NULL) {
- register char *cp, *endp, *oendp;
+ oFILE = fopen (job->outFile, "r");
+ if (oFILE != (FILE *) NULL) {
+ printf ("Results of making %s:\n", job->node->name);
+ while (fgets (inLine, sizeof(inLine), oFILE) != NULL) {
+ register char *cp, *ecp, *endp;
cp = inLine;
- oendp = endp = inLine + strlen(inLine);
+ endp = inLine + strlen(inLine);
if (endp[-1] == '\n') {
*--endp = '\0';
}
- cp = JobOutput(job, inLine, endp, FALSE);
+ if (commandShell->noPrint) {
+ ecp = Str_FindSubstring(cp, commandShell->noPrint);
+ while (ecp != (char *)NULL) {
+ if (cp != ecp) {
+ *ecp = '\0';
+ /*
+ * The only way there wouldn't be a newline after
+ * this line is if it were the last in the buffer.
+ * however, since the non-printable comes after it,
+ * there must be a newline, so we don't print one.
+ */
+ printf ("%s", cp);
+ }
+ cp = ecp + commandShell->noPLen;
+ if (cp != endp) {
+ /*
+ * Still more to print, look again after skipping
+ * the whitespace following the non-printable
+ * command....
+ */
+ cp++;
+ while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
+ cp++;
+ }
+ ecp = Str_FindSubstring(cp, commandShell->noPrint);
+ } else {
+ break;
+ }
+ }
+ }
/*
* There's still more in that thar buffer. This time, though,
* we know there's no newline at the end, so we add one of
* our own free will.
*/
- (void) fprintf(stdout, "%s", cp);
- (void) fflush(stdout);
- if (endp != oendp) {
- (void) fprintf(stdout, "\n");
- (void) fflush(stdout);
+ if (*cp != '\0') {
+ printf ("%s\n", cp);
}
}
- (void) fclose(oFILE);
- (void) eunlink(job->outFile);
+ fclose (oFILE);
+ (void) unlink (job->outFile);
}
}
+ fflush(stdout);
}
/*-
@@ -2217,13 +1934,13 @@ end_loop:
*-----------------------------------------------------------------------
*/
void
-Job_CatchChildren(block)
+Job_CatchChildren (block)
Boolean block; /* TRUE if should block on the wait. */
{
int pid; /* pid of dead child */
register Job *job; /* job descriptor for dead child */
LstNode jnode; /* list element for finding job */
- int status; /* Exit/termination status */
+ union wait status; /* Exit/termination status */
/*
* Don't even bother if we know there's no one around.
@@ -2231,55 +1948,41 @@ Job_CatchChildren(block)
if (nLocal == 0) {
return;
}
-
- while ((pid = waitpid((pid_t) -1, &status,
- (block?0:WNOHANG)|WUNTRACED)) > 0)
+
+ while ((pid = wait3((int *)&status, (block?0:WNOHANG)|WUNTRACED,
+ (struct rusage *)0)) > 0)
{
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d exited or stopped.\n", pid);
- (void) fflush(stdout);
- }
+ if (DEBUG(JOB))
+ printf("Process %d exited or stopped.\n", pid);
+
-
- jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid);
+ jnode = Lst_Find (jobs, (ClientData)&pid, JobCmpPid);
if (jnode == NILLNODE) {
- if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
+ if (WIFSIGNALED(status) && (status.w_termsig == SIGCONT)) {
jnode = Lst_Find(stoppedJobs, (ClientData) &pid, JobCmpPid);
if (jnode == NILLNODE) {
Error("Resumed child (%d) not in table", pid);
continue;
}
job = (Job *)Lst_Datum(jnode);
- (void) Lst_Remove(stoppedJobs, jnode);
+ (void)Lst_Remove(stoppedJobs, jnode);
} else {
- Error("Child (%d) not in table?", pid);
+ Error ("Child (%d) not in table?", pid);
continue;
}
} else {
- job = (Job *) Lst_Datum(jnode);
- (void) Lst_Remove(jobs, jnode);
+ job = (Job *) Lst_Datum (jnode);
+ (void)Lst_Remove (jobs, jnode);
nJobs -= 1;
if (jobFull && DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is no longer full.\n");
- (void) fflush(stdout);
+ printf("Job queue is no longer full.\n");
}
jobFull = FALSE;
-#ifdef REMOTE
- if (!(job->flags & JOB_REMOTE)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Job queue has one fewer local process.\n");
- (void) fflush(stdout);
- }
- nLocal -= 1;
- }
-#else
nLocal -= 1;
-#endif
}
- JobFinish(job, &status);
+ JobFinish (job, status);
}
}
@@ -2290,17 +1993,17 @@ Job_CatchChildren(block)
* pipes do so. Otherwise just block time until we get a
* signal (most likely a SIGCHLD) since there's no point in
* just spinning when there's nothing to do and the reaping
- * of a child can wait for a while.
+ * of a child can wait for a while.
*
* Results:
- * None
+ * None
*
* Side Effects:
* Output is read from pipes if we're piping.
* -----------------------------------------------------------------------
*/
void
-Job_CatchOutput()
+Job_CatchOutput ()
{
int nfds;
struct timeval timeout;
@@ -2311,7 +2014,7 @@ Job_CatchOutput()
int pnJobs; /* Previous nJobs */
#endif
- (void) fflush(stdout);
+ fflush(stdout);
#ifdef RMT_WILL_WATCH
pnJobs = nJobs;
@@ -2340,21 +2043,21 @@ Job_CatchOutput()
timeout.tv_sec = SEL_SEC;
timeout.tv_usec = SEL_USEC;
- if ((nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0,
- (fd_set *) 0, &timeout)) <= 0)
+ if ((nfds = select (FD_SETSIZE, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout)) < 0)
+ {
return;
- else {
- if (Lst_Open(jobs) == FAILURE) {
- Punt("Cannot open job table");
+ } else {
+ if (Lst_Open (jobs) == FAILURE) {
+ Punt ("Cannot open job table");
}
- while (nfds && (ln = Lst_Next(jobs)) != NILLNODE) {
- job = (Job *) Lst_Datum(ln);
+ while (nfds && (ln = Lst_Next (jobs)) != NILLNODE) {
+ job = (Job *) Lst_Datum (ln);
if (FD_ISSET(job->inPipe, &readfds)) {
- JobDoOutput(job, FALSE);
+ JobDoOutput (job, FALSE);
nfds -= 1;
}
}
- Lst_Close(jobs);
+ Lst_Close (jobs);
}
}
#endif /* RMT_WILL_WATCH */
@@ -2375,10 +2078,10 @@ Job_CatchOutput()
*-----------------------------------------------------------------------
*/
void
-Job_Make(gn)
+Job_Make (gn)
GNode *gn;
{
- (void) JobStart(gn, 0, NULL);
+ (void)JobStart (gn, 0, (Job *)NULL);
}
/*-
@@ -2394,7 +2097,7 @@ Job_Make(gn)
*-----------------------------------------------------------------------
*/
void
-Job_Init(maxproc, maxlocal)
+Job_Init (maxproc, maxlocal)
int maxproc; /* the greatest number of jobs which may be
* running at one time */
int maxlocal; /* the greatest number of local jobs which may
@@ -2402,9 +2105,9 @@ Job_Init(maxproc, maxlocal)
{
GNode *begin; /* node for commands to do at the very start */
- (void) sprintf(tfile, "/tmp/make%05d", getpid());
+ sprintf (tfile, "/tmp/make%05d", getpid());
- jobs = Lst_Init(FALSE);
+ jobs = Lst_Init (FALSE);
stoppedJobs = Lst_Init(FALSE);
maxJobs = maxproc;
maxLocal = maxlocal;
@@ -2417,11 +2120,7 @@ Job_Init(maxproc, maxlocal)
lastNode = NILGNODE;
- if (maxJobs == 1
-#ifdef REMOTE
- || noMessages
-#endif
- ) {
+ if (maxJobs == 1) {
/*
* If only one job can run at a time, there's no need for a banner,
* no is there?
@@ -2430,8 +2129,8 @@ Job_Init(maxproc, maxlocal)
} else {
targFmt = TARG_FMT;
}
-
- if (shellPath == NULL) {
+
+ if (shellPath == (char *) NULL) {
/*
* The user didn't specify a shell to use, so we are using the
* default one... Both the absolute path and the last component
@@ -2440,13 +2139,13 @@ Job_Init(maxproc, maxlocal)
* All default shells are located in _PATH_DEFSHELLDIR.
*/
shellName = commandShell->name;
- shellPath = str_concat(_PATH_DEFSHELLDIR, shellName, STR_ADDSLASH);
+ shellPath = str_concat (_PATH_DEFSHELLDIR, shellName, STR_ADDSLASH);
}
- if (commandShell->exit == NULL) {
+ if (commandShell->exit == (char *)NULL) {
commandShell->exit = "";
}
- if (commandShell->echo == NULL) {
+ if (commandShell->echo == (char *)NULL) {
commandShell->echo = "";
}
@@ -2454,17 +2153,17 @@ Job_Init(maxproc, maxlocal)
* Catch the four signals that POSIX specifies if they aren't ignored.
* JobPassSig will take care of calling JobInterrupt if appropriate.
*/
- if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGINT, JobPassSig);
+ if (signal (SIGINT, SIG_IGN) != SIG_IGN) {
+ signal (SIGINT, JobPassSig);
}
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGHUP, JobPassSig);
+ if (signal (SIGHUP, SIG_IGN) != SIG_IGN) {
+ signal (SIGHUP, JobPassSig);
}
- if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGQUIT, JobPassSig);
+ if (signal (SIGQUIT, SIG_IGN) != SIG_IGN) {
+ signal (SIGQUIT, JobPassSig);
}
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGTERM, JobPassSig);
+ if (signal (SIGTERM, SIG_IGN) != SIG_IGN) {
+ signal (SIGTERM, JobPassSig);
}
/*
* There are additional signals that need to be caught and passed if
@@ -2473,32 +2172,32 @@ Job_Init(maxproc, maxlocal)
* signals from the terminal driver as we own the terminal)
*/
#if defined(RMT_WANTS_SIGNALS) || defined(USE_PGRP)
- if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGTSTP, JobPassSig);
+ if (signal (SIGTSTP, SIG_IGN) != SIG_IGN) {
+ signal (SIGTSTP, JobPassSig);
}
- if (signal(SIGTTOU, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGTTOU, JobPassSig);
+ if (signal (SIGTTOU, SIG_IGN) != SIG_IGN) {
+ signal (SIGTTOU, JobPassSig);
}
- if (signal(SIGTTIN, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGTTIN, JobPassSig);
+ if (signal (SIGTTIN, SIG_IGN) != SIG_IGN) {
+ signal (SIGTTIN, JobPassSig);
}
- if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) {
- (void) signal(SIGWINCH, JobPassSig);
+ if (signal (SIGWINCH, SIG_IGN) != SIG_IGN) {
+ signal (SIGWINCH, JobPassSig);
}
#endif
-
- begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
+
+ begin = Targ_FindNode (".BEGIN", TARG_NOCREATE);
if (begin != NILGNODE) {
- JobStart(begin, JOB_SPECIAL, (Job *)0);
+ JobStart (begin, JOB_SPECIAL, (Job *)0);
while (nJobs) {
Job_CatchOutput();
#ifndef RMT_WILL_WATCH
- Job_CatchChildren(!usePipes);
+ Job_CatchChildren (!usePipes);
#endif /* RMT_WILL_WATCH */
}
}
- postCommands = Targ_FindNode(".END", TARG_CREATE);
+ postCommands = Targ_FindNode (".END", TARG_CREATE);
}
/*-
@@ -2516,9 +2215,9 @@ Job_Init(maxproc, maxlocal)
*-----------------------------------------------------------------------
*/
Boolean
-Job_Full()
+Job_Full ()
{
- return(aborting || jobFull);
+ return (aborting || jobFull);
}
/*-
@@ -2538,7 +2237,7 @@ Job_Full()
* -----------------------------------------------------------------------
*/
Boolean
-Job_Empty()
+Job_Empty ()
{
if (nJobs == 0) {
if (!Lst_IsEmpty(stoppedJobs) && !aborting) {
@@ -2547,7 +2246,9 @@ Job_Empty()
* it...Try and restart the stopped jobs.
*/
jobFull = FALSE;
- JobRestartJobs();
+ while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
+ JobRestart((Job *)Lst_DeQueue(stoppedJobs));
+ }
return(FALSE);
} else {
return(TRUE);
@@ -2571,7 +2272,7 @@ Job_Empty()
*-----------------------------------------------------------------------
*/
static Shell *
-JobMatchShell(name)
+JobMatchShell (name)
char *name; /* Final component of shell path */
{
register Shell *sh; /* Pointer into shells table */
@@ -2580,23 +2281,24 @@ JobMatchShell(name)
*cp2;
char *eoname;
- eoname = name + strlen(name);
+ eoname = name + strlen (name);
- match = NULL;
+ match = (Shell *) NULL;
for (sh = shells; sh->name != NULL; sh++) {
- for (cp1 = eoname - strlen(sh->name), cp2 = sh->name;
+ for (cp1 = eoname - strlen (sh->name), cp2 = sh->name;
*cp1 != '\0' && *cp1 == *cp2;
cp1++, cp2++) {
continue;
}
if (*cp1 != *cp2) {
continue;
- } else if (match == NULL || strlen(match->name) < strlen(sh->name)) {
- match = sh;
+ } else if (match == (Shell *) NULL ||
+ strlen (match->name) < strlen (sh->name)) {
+ match = sh;
}
}
- return(match == NULL ? sh : match);
+ return (match == (Shell *) NULL ? sh : match);
}
/*-
@@ -2643,7 +2345,7 @@ JobMatchShell(name)
*-----------------------------------------------------------------------
*/
ReturnStatus
-Job_ParseShell(line)
+Job_ParseShell (line)
char *line; /* The shell spec */
{
char **words;
@@ -2654,64 +2356,64 @@ Job_ParseShell(line)
Shell newShell;
Boolean fullSpec = FALSE;
- while (isspace(*line)) {
+ while (isspace (*line)) {
line++;
}
- words = brk_string(line, &wordCount, TRUE);
-
- memset((Address)&newShell, 0, sizeof(newShell));
+ words = brk_string (line, &wordCount, TRUE);
+ memset ((Address)&newShell, 0, sizeof(newShell));
+
/*
* Parse the specification by keyword
*/
- for (path = NULL, argc = wordCount - 1, argv = words + 1;
+ for (path = (char *)NULL, argc = wordCount - 1, argv = words + 1;
argc != 0;
argc--, argv++) {
- if (strncmp(*argv, "path=", 5) == 0) {
+ if (strncmp (*argv, "path=", 5) == 0) {
path = &argv[0][5];
- } else if (strncmp(*argv, "name=", 5) == 0) {
+ } else if (strncmp (*argv, "name=", 5) == 0) {
newShell.name = &argv[0][5];
} else {
- if (strncmp(*argv, "quiet=", 6) == 0) {
+ if (strncmp (*argv, "quiet=", 6) == 0) {
newShell.echoOff = &argv[0][6];
- } else if (strncmp(*argv, "echo=", 5) == 0) {
+ } else if (strncmp (*argv, "echo=", 5) == 0) {
newShell.echoOn = &argv[0][5];
- } else if (strncmp(*argv, "filter=", 7) == 0) {
+ } else if (strncmp (*argv, "filter=", 7) == 0) {
newShell.noPrint = &argv[0][7];
newShell.noPLen = strlen(newShell.noPrint);
- } else if (strncmp(*argv, "echoFlag=", 9) == 0) {
+ } else if (strncmp (*argv, "echoFlag=", 9) == 0) {
newShell.echo = &argv[0][9];
- } else if (strncmp(*argv, "errFlag=", 8) == 0) {
+ } else if (strncmp (*argv, "errFlag=", 8) == 0) {
newShell.exit = &argv[0][8];
- } else if (strncmp(*argv, "hasErrCtl=", 10) == 0) {
+ } else if (strncmp (*argv, "hasErrCtl=", 10) == 0) {
char c = argv[0][10];
newShell.hasErrCtl = !((c != 'Y') && (c != 'y') &&
- (c != 'T') && (c != 't'));
- } else if (strncmp(*argv, "check=", 6) == 0) {
+ (c != 'T') && (c != 't'));
+ } else if (strncmp (*argv, "check=", 6) == 0) {
newShell.errCheck = &argv[0][6];
- } else if (strncmp(*argv, "ignore=", 7) == 0) {
+ } else if (strncmp (*argv, "ignore=", 7) == 0) {
newShell.ignErr = &argv[0][7];
} else {
- Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"",
+ Parse_Error (PARSE_FATAL, "Unknown keyword \"%s\"",
*argv);
- return(FAILURE);
+ return (FAILURE);
}
fullSpec = TRUE;
}
}
- if (path == NULL) {
+ if (path == (char *)NULL) {
/*
* If no path was given, the user wants one of the pre-defined shells,
* yes? So we find the one s/he wants with the help of JobMatchShell
* and set things up the right way. shellPath will be set up by
* Job_Init.
*/
- if (newShell.name == NULL) {
- Parse_Error(PARSE_FATAL, "Neither path nor name specified");
- return(FAILURE);
+ if (newShell.name == (char *)NULL) {
+ Parse_Error (PARSE_FATAL, "Neither path nor name specified");
+ return (FAILURE);
} else {
- commandShell = JobMatchShell(newShell.name);
+ commandShell = JobMatchShell (newShell.name);
shellName = newShell.name;
}
} else {
@@ -2723,19 +2425,19 @@ Job_ParseShell(line)
* path the user gave for the shell.
*/
shellPath = path;
- path = strrchr(path, '/');
- if (path == NULL) {
+ path = strrchr (path, '/');
+ if (path == (char *)NULL) {
path = shellPath;
} else {
path += 1;
}
- if (newShell.name != NULL) {
+ if (newShell.name != (char *)NULL) {
shellName = newShell.name;
} else {
shellName = path;
}
if (!fullSpec) {
- commandShell = JobMatchShell(shellName);
+ commandShell = JobMatchShell (shellName);
} else {
commandShell = (Shell *) emalloc(sizeof(Shell));
*commandShell = newShell;
@@ -2745,21 +2447,21 @@ Job_ParseShell(line)
if (commandShell->echoOn && commandShell->echoOff) {
commandShell->hasEchoCtl = TRUE;
}
-
+
if (!commandShell->hasErrCtl) {
- if (commandShell->errCheck == NULL) {
+ if (commandShell->errCheck == (char *)NULL) {
commandShell->errCheck = "";
}
- if (commandShell->ignErr == NULL) {
+ if (commandShell->ignErr == (char *)NULL) {
commandShell->ignErr = "%s\n";
}
}
-
+
/*
* Do not free up the words themselves, since they might be in use by the
* shell specification...
*/
- free(words);
+ free (words);
return SUCCESS;
}
@@ -2777,27 +2479,28 @@ Job_ParseShell(line)
*-----------------------------------------------------------------------
*/
static void
-JobInterrupt(runINTERRUPT, signo)
+JobInterrupt (runINTERRUPT)
int runINTERRUPT; /* Non-zero if commands for the .INTERRUPT
* target should be executed */
- int signo; /* signal received */
{
LstNode ln; /* element in job table */
Job *job; /* job descriptor in that element */
GNode *interrupt; /* the node describing the .INTERRUPT target */
-
+
aborting = ABORT_INTERRUPT;
- (void) Lst_Open(jobs);
- while ((ln = Lst_Next(jobs)) != NILLNODE) {
- job = (Job *) Lst_Datum(ln);
+ (void)Lst_Open (jobs);
+ while ((ln = Lst_Next (jobs)) != NILLNODE) {
+ job = (Job *) Lst_Datum (ln);
- if (!Targ_Precious(job->node)) {
- char *file = (job->node->path == NULL ?
+ if (!Targ_Precious (job->node)) {
+ char *file = (job->node->path == (char *)NULL ?
job->node->name :
job->node->path);
- if (!noExecute && eunlink(file) != -1) {
- Error("*** %s removed", file);
+ struct stat st;
+ if (!noExecute && lstat(file, &st) != -1 && !S_ISDIR(st.st_mode) &&
+ unlink(file) != -1) {
+ Error ("*** %s removed", file);
}
}
#ifdef RMT_WANTS_SIGNALS
@@ -2805,117 +2508,51 @@ JobInterrupt(runINTERRUPT, signo)
/*
* If job is remote, let the Rmt module do the killing.
*/
- if (!Rmt_Signal(job, signo)) {
+ if (!Rmt_Signal(job, SIGINT)) {
/*
* If couldn't kill the thing, finish it out now with an
* error code, since no exit report will come in likely.
*/
- int status;
+ union wait status;
status.w_status = 0;
status.w_retcode = 1;
- JobFinish(job, &status);
+ JobFinish(job, status);
}
} else if (job->pid) {
- KILL(job->pid, signo);
+ KILL(job->pid, SIGINT);
}
#else
if (job->pid) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing signal to child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
- KILL(job->pid, signo);
- }
-#endif /* RMT_WANTS_SIGNALS */
- }
-
-#ifdef REMOTE
- (void)Lst_Open(stoppedJobs);
- while ((ln = Lst_Next(stoppedJobs)) != NILLNODE) {
- job = (Job *) Lst_Datum(ln);
-
- if (job->flags & JOB_RESTART) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "%s%s",
- "JobInterrupt skipping job on stopped queue",
- "-- it was waiting to be restarted.\n");
- (void) fflush(stdout);
- }
- continue;
- }
- if (!Targ_Precious(job->node)) {
- char *file = (job->node->path == NULL ?
- job->node->name :
- job->node->path);
- if (eunlink(file) == 0) {
- Error("*** %s removed", file);
- }
- }
- /*
- * Resume the thing so it will take the signal.
- */
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing CONT to stopped child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
- KILL(job->pid, SIGCONT);
-#ifdef RMT_WANTS_SIGNALS
- if (job->flags & JOB_REMOTE) {
- /*
- * If job is remote, let the Rmt module do the killing.
- */
- if (!Rmt_Signal(job, SIGINT)) {
- /*
- * If couldn't kill the thing, finish it out now with an
- * error code, since no exit report will come in likely.
- */
- int status;
- status.w_status = 0;
- status.w_retcode = 1;
- JobFinish(job, &status);
- }
- } else if (job->pid) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing interrupt to stopped child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
KILL(job->pid, SIGINT);
}
#endif /* RMT_WANTS_SIGNALS */
}
-#endif
- Lst_Close(stoppedJobs);
+ Lst_Close (jobs);
if (runINTERRUPT && !touchFlag) {
- interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
+ interrupt = Targ_FindNode (".INTERRUPT", TARG_NOCREATE);
if (interrupt != NILGNODE) {
ignoreErrors = FALSE;
- JobStart(interrupt, JOB_IGNDOTS, (Job *)0);
+ JobStart (interrupt, JOB_IGNDOTS, (Job *)0);
while (nJobs) {
Job_CatchOutput();
#ifndef RMT_WILL_WATCH
- Job_CatchChildren(!usePipes);
+ Job_CatchChildren (!usePipes);
#endif /* RMT_WILL_WATCH */
}
}
}
- (void) eunlink(tfile);
- exit(signo);
+ (void) unlink (tfile);
+ exit (0);
}
/*
*-----------------------------------------------------------------------
* Job_End --
* Do final processing such as the running of the commands
- * attached to the .END target.
+ * attached to the .END target.
*
* Results:
* Number of errors reported.
@@ -2926,23 +2563,24 @@ JobInterrupt(runINTERRUPT, signo)
*-----------------------------------------------------------------------
*/
int
-Job_End()
+Job_End ()
{
- if (postCommands != NILGNODE && !Lst_IsEmpty(postCommands->commands)) {
+ if (postCommands != NILGNODE && !Lst_IsEmpty (postCommands->commands)) {
if (errors) {
- Error("Errors reported so .END ignored");
+ Error ("Errors reported so .END ignored");
} else {
- JobStart(postCommands, JOB_SPECIAL | JOB_IGNDOTS, NULL);
+ JobStart (postCommands, JOB_SPECIAL | JOB_IGNDOTS,
+ (Job *)0);
while (nJobs) {
Job_CatchOutput();
#ifndef RMT_WILL_WATCH
- Job_CatchChildren(!usePipes);
+ Job_CatchChildren (!usePipes);
#endif /* RMT_WILL_WATCH */
}
}
}
- (void) eunlink(tfile);
+ (void) unlink (tfile);
return(errors);
}
@@ -2988,23 +2626,23 @@ Job_Wait()
*-----------------------------------------------------------------------
*/
void
-Job_AbortAll()
+Job_AbortAll ()
{
- LstNode ln; /* element in job table */
+ LstNode ln; /* element in job table */
Job *job; /* the job descriptor in that element */
int foo;
-
+
aborting = ABORT_ERROR;
-
+
if (nJobs) {
- (void) Lst_Open(jobs);
- while ((ln = Lst_Next(jobs)) != NILLNODE) {
- job = (Job *) Lst_Datum(ln);
+ (void)Lst_Open (jobs);
+ while ((ln = Lst_Next (jobs)) != NILLNODE) {
+ job = (Job *) Lst_Datum (ln);
/*
* kill the child process with increasingly drastic signals to make
- * darn sure it's dead.
+ * darn sure it's dead.
*/
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
@@ -3020,92 +2658,11 @@ Job_AbortAll()
#endif /* RMT_WANTS_SIGNALS */
}
}
-
+
/*
* Catch as many children as want to report in at first, then give up
*/
- while (waitpid((pid_t) -1, &foo, WNOHANG) > 0)
+ while (wait3(&foo, WNOHANG, (struct rusage *)0) > 0)
continue;
- (void) eunlink(tfile);
-}
-
-#ifdef REMOTE
-/*-
- *-----------------------------------------------------------------------
- * JobFlagForMigration --
- * Handle the eviction of a child. Called from RmtStatusChange.
- * Flags the child as remigratable and then suspends it.
- *
- * Results:
- * none.
- *
- * Side Effects:
- * The job descriptor is flagged for remigration.
- *
- *-----------------------------------------------------------------------
- */
-void
-JobFlagForMigration(hostID)
- int hostID; /* ID of host we used, for matching children. */
-{
- register Job *job; /* job descriptor for dead child */
- LstNode jnode; /* list element for finding job */
-
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "JobFlagForMigration(%d) called.\n", hostID);
- (void) fflush(stdout);
- }
- jnode = Lst_Find(jobs, (ClientData)hostID, JobCmpRmtID);
-
- if (jnode == NILLNODE) {
- jnode = Lst_Find(stoppedJobs, (ClientData)hostID, JobCmpRmtID);
- if (jnode == NILLNODE) {
- if (DEBUG(JOB)) {
- Error("Evicting host(%d) not in table", hostID);
- }
- return;
- }
- }
- job = (Job *) Lst_Datum(jnode);
-
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobFlagForMigration(%d) found job '%s'.\n", hostID,
- job->node->name);
- (void) fflush(stdout);
- }
-
- KILL(job->pid, SIGSTOP);
-
- job->flags |= JOB_REMIGRATE;
-}
-
-#endif
-
-/*-
- *-----------------------------------------------------------------------
- * JobRestartJobs --
- * Tries to restart stopped jobs if there are slots available.
- * Note that this tries to restart them regardless of pending errors.
- * It's not good to leave stopped jobs lying around!
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Resumes(and possibly migrates) jobs.
- *
- *-----------------------------------------------------------------------
- */
-static void
-JobRestartJobs()
-{
- while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Job queue is not full. Restarting a stopped job.\n");
- (void) fflush(stdout);
- }
- JobRestart((Job *)Lst_DeQueue(stoppedJobs));
- }
+ (void) unlink (tfile);
}
diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h
index d9cdcc02efa0..5feb43fb6e43 100644
--- a/usr.bin/make/job.h
+++ b/usr.bin/make/job.h
@@ -1,8 +1,6 @@
-/* $NetBSD: job.h,v 1.4 1995/06/14 15:19:26 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)job.h 8.1 (Berkeley) 6/6/93
+ * @(#)job.h 8.2 (Berkeley) 4/28/95
*/
/*-
@@ -53,14 +51,14 @@
/*
* The SEL_ constants determine the maximum amount of time spent in select
* before coming out to see if a child has finished. SEL_SEC is the number of
- * seconds and SEL_USEC is the number of micro-seconds
+ * seconds and SEL_USEC is the number of micro-seconds
*/
#define SEL_SEC 0
#define SEL_USEC 500000
/*-
- * Job Table definitions.
+ * Job Table definitions.
*
* Each job has several things associated with it:
* 1) The process id of the child shell
@@ -81,11 +79,11 @@
* 6) An identifier provided by and for the exclusive use of the
* Rmt module.
* 7) A word of flags which determine how the module handles errors,
- * echoing, etc. for the job
+ * echoing, etc. for the job
*
* The job "table" is kept as a linked Lst in 'jobs', with the number of
* active jobs maintained in the 'nJobs' variable. At no time will this
- * exceed the value of 'maxJobs', initialized by the Job_Init function.
+ * exceed the value of 'maxJobs', initialized by the Job_Init function.
*
* When a job is finished, the Make_Update function is called on each of the
* parents of the node which was just remade. This takes care of the upward
@@ -107,7 +105,7 @@ typedef struct Job {
* if we can't export it and maxLocal is 0 */
#define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing
* commands */
-#define JOB_REMOTE 0x010 /* Job is running remotely */
+#define JOB_REMOTE 0x010 /* Job is running remotely */
#define JOB_FIRST 0x020 /* Job is first job for the node */
#define JOB_REMIGRATE 0x040 /* Job needs to be remigrated */
#define JOB_RESTART 0x080 /* Job needs to be completely restarted */
@@ -195,7 +193,7 @@ typedef struct Shell {
char *errCheck; /* string to turn error checking on */
char *ignErr; /* string to turn off error checking */
/*
- * command-line flags
+ * command-line flags
*/
char *echo; /* echo commands */
char *exit; /* exit on error */
diff --git a/usr.bin/make/list.h b/usr.bin/make/list.h
index e150d2e4c64e..41b9a1930293 100644
--- a/usr.bin/make/list.h
+++ b/usr.bin/make/list.h
@@ -1,8 +1,6 @@
-/* $NetBSD: list.h,v 1.4 1995/06/14 15:19:28 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)list.h 8.1 (Berkeley) 6/6/93
+ * @(#)list.h 8.2 (Berkeley) 4/28/95
*/
/*
@@ -62,39 +60,39 @@
* to a list as a whole, the user keeps a pointer to the header; that
* header is initialized by a call to List_Init(), which creates an empty
* list given a pointer to a List_Links structure (described below).
- *
+ *
* The links are contained in a two-element structure called List_Links.
* A list joins List_Links records (that is, each List_Links structure
* points to other List_Links structures), but if the List_Links is the
* first field within a larger structure, then the larger structures are
* effectively linked together as follows:
- *
+ *
* header
* (List_Links) first elt. second elt.
- * ----------------- ----------------- -----------------
+ * ----------------- ----------------- -----------------
* ..-> | nextPtr | ----> | List_Links | ----> | List_Links |----..
- * | - - - - - - - | | | | |
+ * | - - - - - - - | | | | |
* ..-- | prevPtr | <---- | | <---- | |<---..
* ----------------- - --- --- --- - - --- --- --- -
- * | rest of | | rest of |
- * | structure | | structure |
+ * | rest of | | rest of |
+ * | structure | | structure |
* | | | |
- * | ... | | ... |
- * ----------------- -----------------
- *
+ * | ... | | ... |
+ * ----------------- -----------------
+ *
* It is possible to link structures through List_Links fields that are
* not at the beginning of the larger structure, but it is then necessary
* to perform pointer arithmetic to find the beginning of the larger
* structure, given a pointer to some point within it.
- *
+ *
* A typical structure might be something like:
- *
+ *
* typedef struct {
* List_Links links;
* char ch;
* integer flags;
* } EditChar;
- *
+ *
* Before an element is inserted in a list for the first time, it must
* be initialized by calling the macro List_InitElement().
*/
@@ -131,7 +129,7 @@ void List_Move(); /* move an element elsewhere in a list */
#define List_InitElement(elementPtr) \
(elementPtr)->prevPtr = (List_Links *) NIL; \
(elementPtr)->nextPtr = (List_Links *) NIL;
-
+
/*
* Macros for stepping through or selecting parts of lists
*/
@@ -144,10 +142,10 @@ void List_Move(); /* move an element elsewhere in a list */
* Macro to loop through a list and perform an operation on each member.
*
* Usage: LIST_FORALL(headerPtr, itemPtr) {
- * / *
+ * / *
* * operation on itemPtr, which points to successive members
* * of the list
- * *
+ * *
* * It may be appropriate to first assign
* * foobarPtr = (Foobar *) itemPtr;
* * to refer to the entire Foobar structure.
@@ -281,7 +279,7 @@ void List_Move(); /* move an element elsewhere in a list */
* LIST_ATFRONT(headerPtr) -- insert at front of list
* LIST_ATREAR(headerPtr) -- insert at end of list
*
- * For example,
+ * For example,
*
* List_Insert(itemPtr, LIST_AFTER(otherPtr));
*
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index ff4a40c9afe8..8d8abe04c814 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -1,8 +1,6 @@
-/* $NetBSD: lst.h,v 1.6 1996/02/04 22:20:46 christos Exp $ */
-
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)lst.h 8.1 (Berkeley) 6/6/93
+ * @(#)lst.h 8.2 (Berkeley) 4/28/95
*/
/*-
@@ -48,7 +46,6 @@
#define _LST_H_
#include <sprite.h>
-#include <sys/param.h>
#if __STDC__
#include <stdlib.h>
#endif
@@ -120,12 +117,12 @@ ClientData Lst_Datum __P((LstNode));
* Functions for entire lists
*/
/* Find an element in a list */
-LstNode Lst_Find __P((Lst, ClientData,
+LstNode Lst_Find __P((Lst, ClientData,
int (*)(ClientData, ClientData)));
/* Find an element starting from somewhere */
LstNode Lst_FindFrom __P((Lst, LstNode, ClientData,
int (*cProc)(ClientData, ClientData)));
-/*
+/*
* See if the given datum is on the list. Returns the LstNode containing
* the datum
*/
diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c
index b6f15d371536..93800db01a0b 100644
--- a/usr.bin/make/lst.lib/lstAppend.c
+++ b/usr.bin/make/lst.lib/lstAppend.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstAppend.c,v 1.4 1995/06/14 15:20:44 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstAppend.c,v 1.4 1995/06/14 15:20:44 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstAppend.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -76,23 +70,23 @@ Lst_Append (l, ln, d)
register List list;
register ListNode lNode;
register ListNode nLNode;
-
+
if (LstValid (l) && (ln == NILLNODE && LstIsEmpty (l))) {
goto ok;
}
-
+
if (!LstValid (l) || LstIsEmpty (l) || ! LstNodeValid (ln, l)) {
return (FAILURE);
}
ok:
-
+
list = (List)l;
lNode = (ListNode)ln;
PAlloc (nLNode, ListNode);
nLNode->datum = d;
nLNode->useCount = nLNode->flags = 0;
-
+
if (lNode == NilListNode) {
if (list->isCirc) {
nLNode->nextPtr = nLNode->prevPtr = nLNode;
@@ -103,17 +97,17 @@ Lst_Append (l, ln, d)
} else {
nLNode->prevPtr = lNode;
nLNode->nextPtr = lNode->nextPtr;
-
+
lNode->nextPtr = nLNode;
if (nLNode->nextPtr != NilListNode) {
nLNode->nextPtr->prevPtr = nLNode;
}
-
+
if (lNode == list->lastPtr) {
list->lastPtr = nLNode;
}
}
-
+
return (SUCCESS);
}
diff --git a/usr.bin/make/lst.lib/lstAtEnd.c b/usr.bin/make/lst.lib/lstAtEnd.c
index a4ed0d7b0181..e61a28c0673f 100644
--- a/usr.bin/make/lst.lib/lstAtEnd.c
+++ b/usr.bin/make/lst.lib/lstAtEnd.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstAtEnd.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -50,7 +44,7 @@ static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Ex
*/
#include "lstInt.h"
-
+
/*-
*-----------------------------------------------------------------------
* Lst_AtEnd --
@@ -70,7 +64,7 @@ Lst_AtEnd (l, d)
ClientData d; /* Datum to add */
{
register LstNode end;
-
+
end = Lst_Last (l);
return (Lst_Append (l, end, d));
}
diff --git a/usr.bin/make/lst.lib/lstAtFront.c b/usr.bin/make/lst.lib/lstAtFront.c
index ef694d345d4e..5e8b7f1ab4c2 100644
--- a/usr.bin/make/lst.lib/lstAtFront.c
+++ b/usr.bin/make/lst.lib/lstAtFront.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstAtFront.c,v 1.4 1995/06/14 15:20:48 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.4 1995/06/14 15:20:48 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstAtFront.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -71,7 +65,7 @@ Lst_AtFront (l, d)
ClientData d;
{
register LstNode front;
-
+
front = Lst_First (l);
return (Lst_Insert (l, front, d));
}
diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c
index e07ed4a81c81..6f9174f3db8a 100644
--- a/usr.bin/make/lst.lib/lstClose.c
+++ b/usr.bin/make/lst.lib/lstClose.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstClose.c,v 1.4 1995/06/14 15:20:50 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstClose.c,v 1.4 1995/06/14 15:20:50 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstClose.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -74,7 +68,7 @@ Lst_Close (l)
Lst l; /* The list to close */
{
register List list = (List) l;
-
+
if (LstValid(l) == TRUE) {
list->isOpen = FALSE;
list->atEnd = Unknown;
diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c
index 74baa86b2096..e7726a862b60 100644
--- a/usr.bin/make/lst.lib/lstConcat.c
+++ b/usr.bin/make/lst.lib/lstConcat.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstConcat.c,v 1.5 1995/06/14 15:20:53 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstConcat.c,v 1.5 1995/06/14 15:20:53 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstConcat.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -155,7 +149,7 @@ Lst_Concat (l1, l2, flags)
/*
* Finish bookkeeping. The last new element becomes the last element
- * of list one.
+ * of list one.
*/
list1->lastPtr = last;
@@ -179,4 +173,4 @@ Lst_Concat (l1, l2, flags)
return (SUCCESS);
}
-
+
diff --git a/usr.bin/make/lst.lib/lstDatum.c b/usr.bin/make/lst.lib/lstDatum.c
index 6125b665174b..6b0988e0fa2b 100644
--- a/usr.bin/make/lst.lib/lstDatum.c
+++ b/usr.bin/make/lst.lib/lstDatum.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstDatum.c,v 1.4 1995/06/14 15:20:54 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstDatum.c,v 1.4 1995/06/14 15:20:54 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstDatum.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstDeQueue.c b/usr.bin/make/lst.lib/lstDeQueue.c
index b4c5f8bb805a..4b901257b001 100644
--- a/usr.bin/make/lst.lib/lstDeQueue.c
+++ b/usr.bin/make/lst.lib/lstDeQueue.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstDeQueue.c,v 1.4 1995/06/14 15:20:56 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.4 1995/06/14 15:20:56 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstDeQueue.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -71,12 +65,12 @@ Lst_DeQueue (l)
{
ClientData rd;
register ListNode tln;
-
+
tln = (ListNode) Lst_First (l);
if (tln == NilListNode) {
return ((ClientData) NIL);
}
-
+
rd = tln->datum;
if (Lst_Remove (l, (LstNode)tln) == FAILURE) {
return ((ClientData) NIL);
diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c
index 23e0ecd6b7d7..56ea5c528fe6 100644
--- a/usr.bin/make/lst.lib/lstDestroy.c
+++ b/usr.bin/make/lst.lib/lstDestroy.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstDestroy.c,v 1.5 1995/06/14 15:20:58 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstDestroy.c,v 1.5 1995/06/14 15:20:58 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstDestroy.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -74,7 +68,7 @@ Lst_Destroy (l, freeProc)
register ListNode ln;
register ListNode tln = NilListNode;
register List list = (List)l;
-
+
if (l == NILLST || ! l) {
/*
* Note the check for l == (Lst)0 to catch uninitialized static Lst's.
@@ -103,6 +97,6 @@ Lst_Destroy (l, freeProc)
free ((Address)ln);
}
}
-
+
free ((Address)l);
}
diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c
index b0d36f83a0e5..184b386228d3 100644
--- a/usr.bin/make/lst.lib/lstDupl.c
+++ b/usr.bin/make/lst.lib/lstDupl.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstDupl.c,v 1.5 1995/06/14 15:21:02 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstDupl.c,v 1.5 1995/06/14 15:21:02 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstDupl.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -74,7 +68,7 @@ Lst_Duplicate (l, copyProc)
register Lst nl;
register ListNode ln;
register List list = (List)l;
-
+
if (!LstValid (l)) {
return (NILLST);
}
@@ -100,6 +94,6 @@ Lst_Duplicate (l, copyProc)
ln = ln->nextPtr;
}
}
-
+
return (nl);
}
diff --git a/usr.bin/make/lst.lib/lstEnQueue.c b/usr.bin/make/lst.lib/lstEnQueue.c
index cdd865cfad05..1016c88d2834 100644
--- a/usr.bin/make/lst.lib/lstEnQueue.c
+++ b/usr.bin/make/lst.lib/lstEnQueue.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstEnQueue.c,v 1.4 1995/06/14 15:21:04 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.4 1995/06/14 15:21:04 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstEnQueue.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -73,7 +67,7 @@ Lst_EnQueue (l, d)
if (LstValid (l) == FALSE) {
return (FAILURE);
}
-
+
return (Lst_Append (l, Lst_Last(l), d));
}
diff --git a/usr.bin/make/lst.lib/lstFind.c b/usr.bin/make/lst.lib/lstFind.c
index 41b9e1cf4b9d..bab85ccd173c 100644
--- a/usr.bin/make/lst.lib/lstFind.c
+++ b/usr.bin/make/lst.lib/lstFind.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstFind.c,v 1.5 1995/06/14 15:21:07 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstFind.c,v 1.5 1995/06/14 15:21:07 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstFind.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c
index 19cd4e04867e..08de990afe5c 100644
--- a/usr.bin/make/lst.lib/lstFindFrom.c
+++ b/usr.bin/make/lst.lib/lstFindFrom.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstFindFrom.c,v 1.5 1995/06/14 15:21:09 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.5 1995/06/14 15:21:09 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstFindFrom.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -75,13 +69,13 @@ Lst_FindFrom (l, ln, d, cProc)
{
register ListNode tln;
Boolean found = FALSE;
-
+
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
return (NILLNODE);
}
-
+
tln = (ListNode)ln;
-
+
do {
if ((*cProc) (tln->datum, d) == 0) {
found = TRUE;
@@ -90,7 +84,7 @@ Lst_FindFrom (l, ln, d, cProc)
tln = tln->nextPtr;
}
} while (tln != (ListNode)ln && tln != NilListNode);
-
+
if (found) {
return ((LstNode)tln);
} else {
diff --git a/usr.bin/make/lst.lib/lstFirst.c b/usr.bin/make/lst.lib/lstFirst.c
index f97c12c1f624..9a95018777ab 100644
--- a/usr.bin/make/lst.lib/lstFirst.c
+++ b/usr.bin/make/lst.lib/lstFirst.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstFirst.c,v 1.4 1995/06/14 15:21:12 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstFirst.c,v 1.4 1995/06/14 15:21:12 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstFirst.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstForEach.c b/usr.bin/make/lst.lib/lstForEach.c
index 00c1fa91dc64..1d6ba9396dc6 100644
--- a/usr.bin/make/lst.lib/lstForEach.c
+++ b/usr.bin/make/lst.lib/lstForEach.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstForEach.c,v 1.5 1995/06/14 15:21:14 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstForEach.c,v 1.5 1995/06/14 15:21:14 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstForEach.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstForEachFrom.c b/usr.bin/make/lst.lib/lstForEachFrom.c
index a5efc640d299..7c9e51e749f0 100644
--- a/usr.bin/make/lst.lib/lstForEachFrom.c
+++ b/usr.bin/make/lst.lib/lstForEachFrom.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstForEachFrom.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -57,7 +51,7 @@ static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 chris
* Lst_ForEachFrom --
* Apply the given function to each element of the given list. The
* function should return 0 if traversal should continue and non-
- * zero if it should abort.
+ * zero if it should abort.
*
* Results:
* None.
@@ -72,7 +66,7 @@ void
Lst_ForEachFrom (l, ln, proc, d)
Lst l;
LstNode ln;
- register int (*proc) __P((ClientData, ClientData));
+ register int (*proc)();
register ClientData d;
{
register ListNode tln = (ListNode)ln;
@@ -80,19 +74,19 @@ Lst_ForEachFrom (l, ln, proc, d)
register ListNode next;
Boolean done;
int result;
-
+
if (!LstValid (list) || LstIsEmpty (list)) {
return;
}
-
+
do {
/*
* Take care of having the current element deleted out from under
* us.
*/
-
+
next = tln->nextPtr;
-
+
(void) tln->useCount++;
result = (*proc) (tln->datum, d);
(void) tln->useCount--;
@@ -105,7 +99,7 @@ Lst_ForEachFrom (l, ln, proc, d)
*/
done = (next == tln->nextPtr &&
(next == NilListNode || next == list->firstPtr));
-
+
next = tln->nextPtr;
if (tln->flags & LN_DELETED) {
@@ -113,6 +107,5 @@ Lst_ForEachFrom (l, ln, proc, d)
}
tln = next;
} while (!result && !LstIsEmpty(list) && !done);
-
+
}
-
diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c
index dfcb873971af..17276be6f1e7 100644
--- a/usr.bin/make/lst.lib/lstInit.c
+++ b/usr.bin/make/lst.lib/lstInit.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstInit.c,v 1.4 1995/06/14 15:21:18 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstInit.c,v 1.4 1995/06/14 15:21:18 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstInit.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -69,14 +63,14 @@ Lst_Init(circ)
Boolean circ; /* TRUE if the list should be made circular */
{
register List nList;
-
+
PAlloc (nList, List);
-
+
nList->firstPtr = NilListNode;
nList->lastPtr = NilListNode;
nList->isOpen = FALSE;
nList->isCirc = circ;
nList->atEnd = Unknown;
-
+
return ((Lst)nList);
}
diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c
index 07070202e470..724924adf071 100644
--- a/usr.bin/make/lst.lib/lstInsert.c
+++ b/usr.bin/make/lst.lib/lstInsert.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstInsert.c,v 1.4 1995/06/14 15:21:21 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstInsert.c,v 1.4 1995/06/14 15:21:21 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstInsert.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -82,17 +76,17 @@ Lst_Insert (l, ln, d)
*/
if (LstValid (l) && (LstIsEmpty (l) && ln == NILLNODE))
goto ok;
-
+
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
return (FAILURE);
}
-
+
ok:
PAlloc (nLNode, ListNode);
-
+
nLNode->datum = d;
nLNode->useCount = nLNode->flags = 0;
-
+
if (ln == NILLNODE) {
if (list->isCirc) {
nLNode->prevPtr = nLNode->nextPtr = nLNode;
@@ -103,17 +97,17 @@ Lst_Insert (l, ln, d)
} else {
nLNode->prevPtr = lNode->prevPtr;
nLNode->nextPtr = lNode;
-
+
if (nLNode->prevPtr != NilListNode) {
nLNode->prevPtr->nextPtr = nLNode;
}
lNode->prevPtr = nLNode;
-
+
if (lNode == list->firstPtr) {
list->firstPtr = nLNode;
}
}
-
+
return (SUCCESS);
}
-
+
diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h
index 975d5dc5fe89..1253660f8e81 100644
--- a/usr.bin/make/lst.lib/lstInt.h
+++ b/usr.bin/make/lst.lib/lstInt.h
@@ -1,5 +1,3 @@
-/* $NetBSD: lstInt.h,v 1.6 1995/11/10 21:27:27 cgd Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -35,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
+ * @(#)lstInt.h 8.2 (Berkeley) 4/28/95
*/
/*-
@@ -45,7 +43,6 @@
#ifndef _LSTINT_H_
#define _LSTINT_H_
-#include "make.h"
#include "lst.h"
typedef struct ListNode {
@@ -90,7 +87,7 @@ typedef struct {
* PAlloc (var, ptype) --
* Allocate a pointer-typedef structure 'ptype' into the variable 'var'
*/
-#define PAlloc(var,ptype) var = (ptype) emalloc (sizeof (*var))
+#define PAlloc(var,ptype) var = (ptype) malloc (sizeof (*var))
/*
* LstValid (l) --
diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c
index be17403b43bc..7fdf68dca49c 100644
--- a/usr.bin/make/lst.lib/lstIsAtEnd.c
+++ b/usr.bin/make/lst.lib/lstIsAtEnd.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstIsAtEnd.c,v 1.4 1995/06/14 15:21:25 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.4 1995/06/14 15:21:25 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstIsAtEnd.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstIsEmpty.c b/usr.bin/make/lst.lib/lstIsEmpty.c
index 6fc9b908f758..da475611bfa8 100644
--- a/usr.bin/make/lst.lib/lstIsEmpty.c
+++ b/usr.bin/make/lst.lib/lstIsEmpty.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstIsEmpty.c,v 1.4 1995/06/14 15:21:27 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstIsEmpty.c,v 1.4 1995/06/14 15:21:27 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstIsEmpty.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstLast.c b/usr.bin/make/lst.lib/lstLast.c
index 1c28fd7c7e77..a87c50c0f837 100644
--- a/usr.bin/make/lst.lib/lstLast.c
+++ b/usr.bin/make/lst.lib/lstLast.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstLast.c,v 1.4 1995/06/14 15:21:29 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstLast.c,v 1.4 1995/06/14 15:21:29 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstLast.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstMember.c b/usr.bin/make/lst.lib/lstMember.c
index fc9b1bbc03ac..a6145ee64fd3 100644
--- a/usr.bin/make/lst.lib/lstMember.c
+++ b/usr.bin/make/lst.lib/lstMember.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstMember.c,v 1.4 1995/06/14 15:21:32 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstMember.c,v 1.4 1995/06/14 15:21:32 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstMember.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -63,7 +57,7 @@ Lst_Member (l, d)
if (lNode == NilListNode) {
return NILLNODE;
}
-
+
do {
if (lNode->datum == d) {
return (LstNode)lNode;
diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c
index d36e5065ee00..b6986d866d59 100644
--- a/usr.bin/make/lst.lib/lstNext.c
+++ b/usr.bin/make/lst.lib/lstNext.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstNext.c,v 1.4 1995/06/14 15:21:35 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstNext.c,v 1.4 1995/06/14 15:21:35 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstNext.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -77,14 +71,14 @@ Lst_Next (l)
{
register ListNode tln;
register List list = (List)l;
-
+
if ((LstValid (l) == FALSE) ||
(list->isOpen == FALSE)) {
return (NILLNODE);
}
-
+
list->prevPtr = list->curPtr;
-
+
if (list->curPtr == NilListNode) {
if (list->atEnd == Unknown) {
/*
@@ -114,7 +108,7 @@ Lst_Next (l)
list->atEnd = Middle;
}
}
-
+
return ((LstNode)tln);
}
diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c
index ae492b17e3bd..9da8cfab5769 100644
--- a/usr.bin/make/lst.lib/lstOpen.c
+++ b/usr.bin/make/lst.lib/lstOpen.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstOpen.c,v 1.4 1995/06/14 15:21:37 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstOpen.c,v 1.4 1995/06/14 15:21:37 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstOpen.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c
index 7d13cae0e6ca..98eb3ce53493 100644
--- a/usr.bin/make/lst.lib/lstRemove.c
+++ b/usr.bin/make/lst.lib/lstRemove.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstRemove.c,v 1.4 1995/06/14 15:21:39 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstRemove.c,v 1.4 1995/06/14 15:21:39 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstRemove.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -78,7 +72,7 @@ Lst_Remove (l, ln)
!LstNodeValid (ln, l)) {
return (FAILURE);
}
-
+
/*
* unlink it from the list
*/
@@ -88,7 +82,7 @@ Lst_Remove (l, ln)
if (lNode->prevPtr != NilListNode) {
lNode->prevPtr->nextPtr = lNode->nextPtr;
}
-
+
/*
* if either the firstPtr or lastPtr of the list point to this node,
* adjust them accordingly
@@ -121,7 +115,7 @@ Lst_Remove (l, ln)
if (list->firstPtr == lNode) {
list->firstPtr = NilListNode;
}
-
+
/*
* note that the datum is unmolested. The caller must free it as
* necessary and as expected.
@@ -131,7 +125,7 @@ Lst_Remove (l, ln)
} else {
lNode->flags |= LN_DELETED;
}
-
+
return (SUCCESS);
}
diff --git a/usr.bin/make/lst.lib/lstReplace.c b/usr.bin/make/lst.lib/lstReplace.c
index 635e2c86a403..8adb6895aec1 100644
--- a/usr.bin/make/lst.lib/lstReplace.c
+++ b/usr.bin/make/lst.lib/lstReplace.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstReplace.c,v 1.4 1995/06/14 15:21:41 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstReplace.c,v 1.4 1995/06/14 15:21:41 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstReplace.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/lst.lib/lstSucc.c b/usr.bin/make/lst.lib/lstSucc.c
index 971e540ad9e9..a5875f686874 100644
--- a/usr.bin/make/lst.lib/lstSucc.c
+++ b/usr.bin/make/lst.lib/lstSucc.c
@@ -1,5 +1,3 @@
-/* $NetBSD: lstSucc.c,v 1.4 1995/06/14 15:21:42 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +35,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: lstSucc.c,v 1.4 1995/06/14 15:21:42 christos Exp $";
-#endif
+static char sccsid[] = "@(#)lstSucc.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index d8b1708fd65a..8607fbb08bb6 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,5 +1,3 @@
-/* $NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -45,11 +43,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
-#else
-static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $";
-#endif
+static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -85,10 +79,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $
#include <sys/resource.h>
#include <sys/signal.h>
#include <sys/stat.h>
-#ifndef MACHINE
#include <sys/utsname.h>
-#endif
-#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -105,7 +96,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $
#ifndef DEFMAXLOCAL
#define DEFMAXLOCAL DEFMAXJOBS
-#endif /* DEFMAXLOCAL */
+#endif DEFMAXLOCAL
#define MAKEFLAGS ".MAKEFLAGS"
@@ -116,9 +107,7 @@ Boolean allPrecious; /* .PRECIOUS given on line by itself */
static Boolean noBuiltins; /* -r flag */
static Lst makefiles; /* ordered list of makefiles to read */
-static Boolean printVars; /* print value of one or more vars */
-static Lst variables; /* list of variables to print */
-int maxJobs; /* -j argument */
+int maxJobs; /* -J argument */
static int maxLocal; /* -L argument */
Boolean compatMake; /* -B argument */
Boolean debug; /* -d flag */
@@ -133,10 +122,8 @@ Boolean oldVars; /* variable substitution style */
Boolean checkEnvFirst; /* -e flag */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
-static void MainParseArgs __P((int, char **));
-char * chdir_verify_path __P((char *, char *));
-static int ReadMakefile __P((ClientData, ClientData));
-static void usage __P((void));
+static Boolean ReadMakefile();
+static void usage();
static char *curdir; /* startup directory */
static char *objdir; /* where we chdir'ed to */
@@ -163,13 +150,12 @@ MainParseArgs(argc, argv)
extern int optind;
extern char *optarg;
int c;
- int forceJobs = 0;
optind = 1; /* since we're called more than once */
-#ifdef REMOTE
-# define OPTFLAGS "BD:I:L:PSV:d:ef:ij:km:nqrst"
+#ifdef notyet
+# define OPTFLAGS "BD:I:L:PSd:ef:ij:knqrst"
#else
-# define OPTFLAGS "BD:I:PSV:d:ef:ij:km:nqrst"
+# define OPTFLAGS "D:I:d:ef:ij:knqrst"
#endif
rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
switch(c) {
@@ -183,22 +169,15 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
- case 'V':
- printVars = TRUE;
- (void)Lst_AtEnd(variables, (ClientData)optarg);
- Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
- Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
- break;
+#ifdef notyet
case 'B':
compatMake = TRUE;
break;
-#ifdef REMOTE
case 'L':
maxLocal = atoi(optarg);
Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
-#endif
case 'P':
usePipes = FALSE;
Var_Append(MAKEFLAGS, "-P", VAR_GLOBAL);
@@ -207,6 +186,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
keepgoing = FALSE;
Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL);
break;
+#endif
case 'd': {
char *modules = optarg;
@@ -274,11 +254,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
break;
case 'j':
- forceJobs = TRUE;
maxJobs = atoi(optarg);
-#ifndef REMOTE
- maxLocal = maxJobs;
-#endif
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
@@ -286,11 +262,6 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
keepgoing = TRUE;
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
break;
- case 'm':
- Dir_AddDir(sysIncPath, optarg);
- Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
- Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
- break;
case 'n':
noExecute = TRUE;
Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
@@ -318,13 +289,6 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
}
}
- /*
- * Be compatible if user did not specify -j and did not explicitly
- * turned compatibility on
- */
- if (!compatMake && !forceJobs)
- compatMake = TRUE;
-
oldVars = TRUE;
/*
@@ -345,7 +309,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
optind = 1; /* - */
goto rearg;
}
- (void)Lst_AtEnd(create, (ClientData)estrdup(*argv));
+ (void)Lst_AtEnd(create, (ClientData)strdup(*argv));
}
}
@@ -382,34 +346,6 @@ Main_ParseArgLine(line)
MainParseArgs(argc, argv);
}
-char *
-chdir_verify_path(path, obpath)
- char *path;
- char *obpath;
-{
- struct stat sb;
-
- if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
- if (chdir(path)) {
- (void)fprintf(stderr, "make warning: %s: %s.\n",
- path, strerror(errno));
- return 0;
- }
- else {
- if (path[0] != '/') {
- (void) snprintf(obpath, MAXPATHLEN, "%s/%s",
- curdir, path);
- return obpath;
- }
- else
- return path;
- }
- }
-
- return 0;
-}
-
-
/*-
* main --
* The main function, for obvious reasons. Initializes variables
@@ -435,29 +371,13 @@ main(argc, argv)
Lst targs; /* target nodes to create -- passed to Make_Init */
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
struct stat sb, sa;
- char *p, *p1, *path, *pathp, *pwd;
+ char *p, *p1, *path, *pwd, *getenv(), *getwd();
char mdpath[MAXPATHLEN + 1];
char obpath[MAXPATHLEN + 1];
char cdpath[MAXPATHLEN + 1];
+ struct utsname utsname;
char *machine = getenv("MACHINE");
- Lst sysMkPath; /* Path of sys.mk */
- char *cp = NULL, *start;
- /* avoid faults on read-only strings */
- static char syspath[] = _PATH_DEFSYSPATH;
-#ifdef RLIMIT_NOFILE
- /*
- * get rid of resource limit on file descriptors
- */
- {
- struct rlimit rl;
- if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&
- rl.rlim_cur != rl.rlim_max) {
- rl.rlim_cur = rl.rlim_max;
- (void) setrlimit(RLIMIT_NOFILE, &rl);
- }
- }
-#endif
/*
* Find where we are and take care of PWD for the automounter...
* All this code is so that we know where we are when we start up
@@ -477,7 +397,7 @@ main(argc, argv)
if ((pwd = getenv("PWD")) != NULL) {
if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&
- sa.st_dev == sb.st_dev)
+ sa.st_dev == sb.st_dev)
(void) strcpy(curdir, pwd);
}
@@ -490,53 +410,62 @@ main(argc, argv)
* MACHINE_ARCH is always known at compile time.
*/
if (!machine) {
-#ifndef MACHINE
- struct utsname utsname;
-
- if (uname(&utsname) == -1) {
+ if (uname(&utsname)) {
perror("make: uname");
exit(2);
}
machine = utsname.machine;
-#else
- machine = MACHINE;
-#endif
}
/*
- * If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
- * exists, change into it and build there. (If a .${MACHINE} suffix
- * exists, use that directory instead).
- * Otherwise check MAKEOBJDIRPREFIX`cwd` (or by default,
- * _PATH_OBJDIRPREFIX`cwd`) and build there if it exists.
- * If all fails, use the current directory to build.
- *
- * Once things are initted,
- * have to add the original directory to the search path,
+ * if the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
+ * exists, change into it and build there. Once things are
+ * initted, have to add the original directory to the search path,
* and modify the paths for the Makefiles apropriately. The
* current directory is also placed as a variable for make scripts.
*/
- if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {
- if (!(path = getenv("MAKEOBJDIR"))) {
- path = _PATH_OBJDIR;
- pathp = _PATH_OBJDIRPREFIX;
- (void) snprintf(mdpath, MAXPATHLEN, "%s.%s",
- path, machine);
- if (!(objdir = chdir_verify_path(mdpath, obpath)))
- if (!(objdir=chdir_verify_path(path, obpath))) {
- (void) snprintf(mdpath, MAXPATHLEN,
- "%s%s", pathp, curdir);
- if (!(objdir=chdir_verify_path(mdpath,
- obpath)))
- objdir = curdir;
- }
- }
- else if (!(objdir = chdir_verify_path(path, obpath)))
+ if (!(path = getenv("MAKEOBJDIR"))) {
+ path = _PATH_OBJDIR;
+ (void) sprintf(mdpath, "%s.%s", path, machine);
+ }
+ else
+ (void) strncpy(mdpath, path, MAXPATHLEN + 1);
+
+ if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+
+ if (chdir(mdpath)) {
+ (void)fprintf(stderr, "make warning: %s: %s.\n",
+ mdpath, strerror(errno));
objdir = curdir;
+ }
+ else {
+ if (mdpath[0] != '/') {
+ (void) sprintf(obpath, "%s/%s", curdir, mdpath);
+ objdir = obpath;
+ }
+ else
+ objdir = mdpath;
+ }
}
else {
- (void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
- if (!(objdir = chdir_verify_path(mdpath, obpath)))
+ if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+
+ if (chdir(path)) {
+ (void)fprintf(stderr, "make warning: %s: %s.\n",
+ path, strerror(errno));
+ objdir = curdir;
+ }
+ else {
+ if (path[0] != '/') {
+ (void) sprintf(obpath, "%s/%s", curdir,
+ path);
+ objdir = obpath;
+ }
+ else
+ objdir = obpath;
+ }
+ }
+ else
objdir = curdir;
}
@@ -544,8 +473,6 @@ main(argc, argv)
create = Lst_Init(FALSE);
makefiles = Lst_Init(FALSE);
- printVars = FALSE;
- variables = Lst_Init(FALSE);
beSilent = FALSE; /* Print commands as executed */
ignoreErrors = FALSE; /* Pay attention to non-zero returns */
noExecute = FALSE; /* Execute all commands */
@@ -558,14 +485,14 @@ main(argc, argv)
debug = 0; /* No debug verbosity, please. */
jobsRunning = FALSE;
- maxLocal = DEFMAXLOCAL; /* Set default local max concurrency */
-#ifdef REMOTE
maxJobs = DEFMAXJOBS; /* Set default max concurrency */
+ maxLocal = DEFMAXLOCAL; /* Set default local max concurrency */
+#ifdef notyet
+ compatMake = FALSE; /* No compat mode */
#else
- maxJobs = maxLocal;
+ compatMake = TRUE; /* No compat mode */
#endif
- compatMake = FALSE; /* No compat mode */
-
+
/*
* Initialize the parsing, directory and variable modules to prepare
@@ -608,7 +535,7 @@ main(argc, argv)
#else
Main_ParseArgLine(getenv("MAKE"));
#endif
-
+
MainParseArgs(argc, argv);
/*
@@ -639,41 +566,13 @@ main(argc, argv)
} else
Var_Set(".TARGETS", "", VAR_GLOBAL);
-
- /*
- * If no user-supplied system path was given (through the -m option)
- * add the directories from the DEFSYSPATH (more than one may be given
- * as dir1:...:dirn) to the system include path.
- */
- if (Lst_IsEmpty(sysIncPath)) {
- for (start = syspath; *start != '\0'; start = cp) {
- for (cp = start; *cp != '\0' && *cp != ':'; cp++)
- continue;
- if (*cp == '\0') {
- Dir_AddDir(sysIncPath, start);
- } else {
- *cp++ = '\0';
- Dir_AddDir(sysIncPath, start);
- }
- }
- }
-
/*
- * Read in the built-in rules first, followed by the specified
- * makefile, if it was (makefile != (char *) NULL), or the default
- * Makefile and makefile, in that order, if it wasn't.
+ * Read in the built-in rules first, followed by the specified makefile,
+ * if it was (makefile != (char *) NULL), or the default Makefile and
+ * makefile, in that order, if it wasn't.
*/
- if (!noBuiltins) {
- LstNode ln;
-
- sysMkPath = Lst_Init (FALSE);
- Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
- if (Lst_IsEmpty(sysMkPath))
- Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
- ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile);
- if (ln != NILLNODE)
- Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- }
+ if (!noBuiltins && !ReadMakefile(_PATH_DEFSYSMK))
+ Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
@@ -681,10 +580,10 @@ main(argc, argv)
ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
if (ln != NILLNODE)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- } else if (!ReadMakefile("makefile", NULL))
- (void)ReadMakefile("Makefile", NULL);
+ } else if (!ReadMakefile("makefile"))
+ (void)ReadMakefile("Makefile");
- (void)ReadMakefile(".depend", NULL);
+ (void)ReadMakefile(".depend");
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
if (p1)
@@ -742,21 +641,6 @@ main(argc, argv)
if (DEBUG(GRAPH1))
Targ_PrintGraph(1);
- /* print the values of any variables requested by the user */
- if (printVars) {
- LstNode ln;
-
- for (ln = Lst_First(variables); ln != NILLNODE;
- ln = Lst_Succ(ln)) {
- char *value = Var_Value((char *)Lst_Datum(ln),
- VAR_GLOBAL, &p1);
-
- printf("%s\n", value ? value : "");
- if (p1)
- free(p1);
- }
- }
-
/*
* Have now read the entire graph and need to make a list of targets
* to create. If none was given on the command line, we consult the
@@ -767,7 +651,11 @@ main(argc, argv)
else
targs = Targ_FindList(create, TARG_CREATE);
- if (!compatMake && !printVars) {
+/*
+ * this was original amMake -- want to allow parallelism, so put this
+ * back in, eventually.
+ */
+ if (!compatMake) {
/*
* Initialize job module before traversing the graph, now that
* any .BEGIN and .END targets have been read. This is done
@@ -783,16 +671,14 @@ main(argc, argv)
/* Traverse the graph, checking on all the targets */
outOfDate = Make_Run(targs);
- } else if (!printVars) {
+ } else
/*
* Compat_Init will take care of creating all the targets as
* well as initializing the module.
*/
Compat_Run(targs);
- }
-
+
Lst_Destroy(targs, NOFREE);
- Lst_Destroy(variables, NOFREE);
Lst_Destroy(makefiles, NOFREE);
Lst_Destroy(create, (void (*) __P((ClientData))) free);
@@ -825,11 +711,10 @@ main(argc, argv)
* lots
*/
static Boolean
-ReadMakefile(p, q)
- ClientData p, q;
+ReadMakefile(fname)
+ char *fname; /* makefile to read */
{
- char *fname = p; /* makefile to read */
- extern Lst parseIncPath;
+ extern Lst parseIncPath, sysIncPath;
FILE *stream;
char *name, path[MAXPATHLEN + 1];
@@ -867,142 +752,6 @@ found: Var_Set("MAKEFILE", fname, VAR_GLOBAL);
}
/*-
- * Cmd_Exec --
- * Execute the command in cmd, and return the output of that command
- * in a string.
- *
- * Results:
- * A string containing the output of the command, or the empty string
- * If err is not NULL, it contains the reason for the command failure
- *
- * Side Effects:
- * The string must be freed by the caller.
- */
-char *
-Cmd_Exec(cmd, err)
- char *cmd;
- char **err;
-{
- char *args[4]; /* Args for invoking the shell */
- int fds[2]; /* Pipe streams */
- int cpid; /* Child PID */
- int pid; /* PID from wait() */
- char *res; /* result */
- int status; /* command exit status */
- Buffer buf; /* buffer to store the result */
- char *cp;
- int cc;
-
-
- *err = NULL;
-
- /*
- * Set up arguments for shell
- */
- args[0] = "sh";
- args[1] = "-c";
- args[2] = cmd;
- args[3] = NULL;
-
- /*
- * Open a pipe for fetching its output
- */
- if (pipe(fds) == -1) {
- *err = "Couldn't create pipe for \"%s\"";
- goto bad;
- }
-
- /*
- * Fork
- */
- switch (cpid = vfork()) {
- case 0:
- /*
- * Close input side of pipe
- */
- (void) close(fds[0]);
-
- /*
- * Duplicate the output stream to the shell's output, then
- * shut the extra thing down. Note we don't fetch the error
- * stream...why not? Why?
- */
- (void) dup2(fds[1], 1);
- (void) close(fds[1]);
-
- (void) execv("/bin/sh", args);
- _exit(1);
- /*NOTREACHED*/
-
- case -1:
- *err = "Couldn't exec \"%s\"";
- goto bad;
-
- default:
- /*
- * No need for the writing half
- */
- (void) close(fds[1]);
-
- buf = Buf_Init (MAKE_BSIZE);
-
- do {
- char result[BUFSIZ];
- cc = read(fds[0], result, sizeof(result));
- if (cc > 0)
- Buf_AddBytes(buf, cc, (Byte *) result);
- }
- while (cc > 0 || (cc == -1 && errno == EINTR));
-
- /*
- * Close the input side of the pipe.
- */
- (void) close(fds[0]);
-
- /*
- * Wait for the process to exit.
- */
- while(((pid = wait(&status)) != cpid) && (pid >= 0))
- continue;
-
- res = (char *)Buf_GetAll (buf, &cc);
- Buf_Destroy (buf, FALSE);
-
- if (cc == 0)
- *err = "Couldn't read shell's output for \"%s\"";
-
- if (status)
- *err = "\"%s\" returned non-zero status";
-
- /*
- * Null-terminate the result, convert newlines to spaces and
- * install it in the variable.
- */
- res[cc] = '\0';
- cp = &res[cc] - 1;
-
- if (*cp == '\n') {
- /*
- * A final newline is just stripped
- */
- *cp-- = '\0';
- }
- while (cp >= res) {
- if (*cp == '\n') {
- *cp = ' ';
- }
- cp--;
- }
- break;
- }
- return res;
-bad:
- res = emalloc(1);
- *res = '\0';
- return res;
-}
-
-/*-
* Error --
* Print an error message given its format.
*
@@ -1084,7 +833,7 @@ Fatal(va_alist)
* a message and exits.
*
* Results:
- * None
+ * None
*
* Side Effects:
* All children are killed indiscriminately and the program Lib_Exits
@@ -1140,10 +889,10 @@ DieHorribly()
/*
* Finish --
* Called when aborting due to errors in child shell to signal
- * abnormal exit.
+ * abnormal exit.
*
* Results:
- * None
+ * None
*
* Side Effects:
* The program exits
@@ -1159,47 +908,18 @@ Finish(errors)
* emalloc --
* malloc, but die on error.
*/
-void *
+char *
emalloc(len)
size_t len;
{
- void *p;
-
- if ((p = malloc(len)) == NULL)
- enomem();
- return(p);
-}
-
-/*
- * estrdup --
- * strdup, but die on error.
- */
-char *
-estrdup(str)
- const char *str;
-{
char *p;
- if ((p = strdup(str)) == NULL)
+ if ((p = (char *) malloc(len)) == NULL)
enomem();
return(p);
}
/*
- * erealloc --
- * realloc, but die on error.
- */
-void *
-erealloc(ptr, size)
- void *ptr;
- size_t size;
-{
- if ((ptr = realloc(ptr, size)) == NULL)
- enomem();
- return(ptr);
-}
-
-/*
* enomem --
* die when out of memory.
*/
@@ -1211,26 +931,6 @@ enomem()
}
/*
- * enunlink --
- * Remove a file carefully, avoiding directories.
- */
-int
-eunlink(file)
- const char *file;
-{
- struct stat st;
-
- if (lstat(file, &st) == -1)
- return -1;
-
- if (S_ISDIR(st.st_mode)) {
- errno = EISDIR;
- return -1;
- }
- return unlink(file);
-}
-
-/*
* usage --
* exit with usage message
*/
@@ -1238,9 +938,8 @@ static void
usage()
{
(void)fprintf(stderr,
-"usage: make [-Beiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
- [-I directory] [-j max_jobs] [-m directory] [-V variable]\n\
- [variable=value] [target ...]\n");
+"usage: make [-eiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
+ [-I directory] [-j max_jobs] [variable=value]\n");
exit(2);
}
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 64efe0a89632..b1392cc6e944 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,5 +1,3 @@
-.\" $NetBSD: make.1,v 1.15 1996/08/30 17:59:40 thorpej Exp $
-.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -31,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
+.\" @(#)make.1 8.8 (Berkeley) 6/13/95
.\"
-.Dd March 19, 1994
+.Dd June 13, 1995
.Dt MAKE 1
.Os
.Sh NAME
@@ -41,16 +39,14 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm make
-.Op Fl Beiknqrst
+.Op Fl eiknqrstv
.Op Fl D Ar variable
.Op Fl d Ar flags
.Op Fl f Ar makefile
.Op Fl I Ar directory
.Bk -words
.Op Fl j Ar max_jobs
-.Op Fl m Ar directory
.Ek
-.Op Fl V Ar variable
.Op Ar variable=value
.Op Ar target ...
.Sh DESCRIPTION
@@ -77,9 +73,6 @@ and makefiles, please refer to
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl B
-Try to be backwards compatible by executing a single shell per command and
-by executing the commands to make the sources of a dependency line in sequence.
.It Fl D Ar variable
Define
.Ar variable
@@ -133,9 +126,8 @@ standard input is read.
Multiple makefile's may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
-The system makefile directory (or directories, see the
-.Fl m
-option) is automatically included as part of this list.
+The system makefile directory is automatically included as part of this
+list.
.It Fl i
Ignore non-zero exit of shell commands in the makefile.
Equivalent to specifying
@@ -144,20 +136,10 @@ before each command line in the makefile.
.It Fl j Ar max_jobs
Specify the maximum number of jobs that
.Nm make
-may have running at any one time. Turns compatibility mode off, unless the
-.Ar B
-flag is also specified.
+may have running at any one time.
.It Fl k
Continue processing after errors are encountered, but only on those targets
that do not depend on the target whose creation caused the error.
-.It Fl m Ar directory
-Specify a directory in which to search for sys.mk and makefiles included
-via the <...> style. Multiple directories can be added to form a search path.
-This path will override the default system include path: /usr/share/mk.
-Furthermore the system include path will be appended to the search path used
-for "..."-style inclusions (see the
-.Fl I
-option).
.It Fl n
Display the commands that would have been executed, but do not actually
execute them.
@@ -174,16 +156,6 @@ before each command line in the makefile.
.It Fl t
Rather than re-building a target as specified in the makefile, create it
or update its modification time to make it appear up-to-date.
-.It Fl V Ar variable
-Print
-.Nm make Ns 's
-idea of the value of
-.Ar variable ,
-in the global context.
-Do not build any targets.
-Multiple instances of this option may be specified;
-the variables will be printed one per line,
-with a blank line for each null or undefined variable.
.It Ar variable=value
Set the value of the variable
.Ar variable
@@ -428,28 +400,6 @@ variable which is then
entered into the environment for all programs which
.Nm make
executes.
-.It Ev PWD
-Alternate path to the current directory.
-.Nm make
-normally sets
-.Ql Va .CURDIR
-to the canonical path given by
-.Xr getcwd 2 .
-However, if the environment variable
-.Ql Ev PWD
-is set and gives a path to the current directory, then
-.Nm make
-sets
-.Ql Va .CURDIR
-to the value of
-.Ql Ev PWD
-instead.
-.Ql Ev PWD
-is set to the value of
-.Ql Va .OBJDIR
-for all programs which
-.Nm make
-executes.
.El
.Pp
Variable expansion may be modified to select or modify each word of the
@@ -537,23 +487,23 @@ This is the
.At V
style variable substitution.
It must be the last modifier specified.
-If
+If
.Ar old_string
or
.Ar new_string
do not contain the pattern matching character
.Ar %
-then it is assumed that they are
+then it is assumed that they are
anchored at the end of each word, so only suffixes or entire
-words may be replaced. Otherwise
+words may be replaced. Otherwise
.Ar %
-is the substring of
-.Ar old_string
+is the substring of
+.Ar old_string
to be replaced in
.Ar new_string
.El
.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
-Makefile inclusion, conditional structures and for loops reminiscent
+Makefile inclusion, conditional structures and for loops reminiscent
of the C programming language are provided in
.Nm make .
All such structures are identified by a line beginning with a single
@@ -679,7 +629,7 @@ As in C,
.Nm make
will only evaluate a conditional as far as is necessary to determine
its value.
-Parentheses may be used to change the order of evaluation.
+Parenthesis may be used to change the order of evaluation.
The boolean operator
.Ql Ic \&!
may be used to logically negate an entire
@@ -755,14 +705,14 @@ In both cases this continues until a
or
.Ql Ic .endif
is found.
-.Pp
+.Pp
For loops are typically used to apply a set of rules to a list of files.
The syntax of a for loop is:
.Bl -tag -width Ds
.It Xo
.Ic \&.for
-.Ar variable
-.Ic in
+.Ar variable
+.Ic in
.Ar expression
.Xc
.It Xo
@@ -773,12 +723,12 @@ The syntax of a for loop is:
.Xc
.El
After the for
-.Ic expression
-is evaluated, it is split into words. The
+.Ic expression
+is evaluated, it is split into words. The
iteration
.Ic variable
-is successively set to each word, and substituted in the
-.Ic make-rules
+is successively set to each word, and substituted in the
+.Ic make-rules
inside the body of the for loop.
.Sh COMMENTS
Comments begin with a hash
@@ -810,6 +760,12 @@ If a target is marked with this attribute and
.Nm make
can't figure out how to create it, it will ignore this fact and assume
the file isn't needed or already exists.
+.It Ic .PHONY
+If this special target is present in a Makefile, all sources for the
+target will considered to be `phony' targets. I.e. they don't refer
+to real files, and they will always be considered out-of-date. This
+is useful in case one wants to create a target called `install', in
+a directory where a file `install' already exists.
.It Ic .PRECIOUS
When
.Nm make
@@ -832,12 +788,6 @@ If the target already has commands, the
.Ic .USE
target's commands are appended
to them.
-.It Ic .WAIT
-If special
-.Ic .WAIT
-source is appears in a dependency line, the sources that precede it are
-made before the sources that succeed it in the line. Loops are not being
-detected and targets that form loops will be silently ignored.
.El
.Sh "SPECIAL TARGETS"
Special targets may not be included with other targets, i.e. they must be
@@ -886,30 +836,11 @@ The flags are as if typed to the shell, though the
.Fl f
option will have
no effect.
-.\" XXX: NOT YET!!!!
-.\" .It Ic .NOTPARALLEL
-.\" The named targets are executed in non parallel mode. If no targets are
-.\" specified, then all targets are executed in non parallel mode.
-.It Ic .NOTPARALLEL
-Disable parallel mode.
-.It Ic .NO_PARALLEL
-Same as above, for compatibility with other pmake variants.
-.It Ic .ORDER
-The named targets are made in sequence.
-.\" XXX: NOT YET!!!!
-.\" .It Ic .PARALLEL
-.\" The named targets are executed in parallel mode. If no targets are
-.\" specified, then all targets are executed in parallel mode.
.It Ic .PATH
The sources are directories which are to be searched for files not
found in the current directory.
If no sources are specified, any previously specified directories are
deleted.
-.It Ic .PHONY
-Apply the
-.Ic .PHONY
-attribute to any specified sources. Targets with this attribute are always
-considered to be out of date.
.It Ic .PRECIOUS
Apply the
.Ic .PRECIOUS
@@ -933,12 +864,10 @@ If no sources are specified, any previous specified suffices are deleted.
.Sh ENVIRONMENT
.Nm Make
utilizes the following environment variables, if they exist:
-.Ev MACHINE ,
.Ev MAKE ,
-.Ev MAKEFLAGS ,
-.Ev MAKEOBJDIR ,
+.Ev MAKEFLAGS
and
-.Ev PWD .
+.Ev MAKEOBJDIR .
.Sh FILES
.Bl -tag -width /usr/share/mk -compact
.It .depend
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index 68a579bf4865..6d17b2ed87f3 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -1,5 +1,3 @@
-/* $NetBSD: make.c,v 1.9 1996/08/30 23:21:10 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
-#else
-static char rcsid[] = "$NetBSD: make.c,v 1.9 1996/08/30 23:21:10 christos Exp $";
-#endif
+static char sccsid[] = "@(#)make.c 8.3 (Berkeley) 6/13/95";
#endif /* not lint */
/*-
@@ -102,10 +96,10 @@ static int MakePrintStatus __P((ClientData, ClientData));
*-----------------------------------------------------------------------
* Make_TimeStamp --
* Set the cmtime field of a parent node based on the mtime stamp in its
- * child. Called from MakeOODate via Lst_ForEach.
+ * child. Called from MakeOODate via Lst_ForEach.
*
* Results:
- * Always returns 0.
+ * Always returns 0.
*
* Side Effects:
* The cmtime of the parent node will be changed if the mtime
@@ -142,7 +136,7 @@ MakeTimeStamp (pgn, cgn)
* will have been recreated.
*
* Results:
- * TRUE if the node is out of date. FALSE otherwise.
+ * TRUE if the node is out of date. FALSE otherwise.
*
* Side Effects:
* The mtime field of the node and the cmtime field of its parents
@@ -159,7 +153,7 @@ Make_OODate (gn)
* Certain types of targets needn't even be sought as their datedness
* doesn't depend on their modification time...
*/
- if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
+ if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_PHONY)) == 0) {
(void) Dir_MTime (gn);
if (DEBUG(MAKE)) {
if (gn->mtime != 0) {
@@ -184,7 +178,14 @@ Make_OODate (gn)
* These weird rules are brought to you by Backward-Compatability and
* the strange people who wrote 'Make'.
*/
- if (gn->type & OP_USE) {
+ if (gn->type & OP_PHONY) {
+ /*
+ * A PHONY node is always out of date
+ */
+ if (DEBUG(MAKE))
+ printf("phony...");
+ return TRUE;
+ } else if (gn->type & OP_USE) {
/*
* If the node is a USE node it is *never* out of date
* no matter *what*.
@@ -213,7 +214,7 @@ Make_OODate (gn)
printf(".JOIN node...");
}
oodate = gn->childMade;
- } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
+ } else if (gn->type & (OP_FORCE|OP_EXEC)) {
/*
* A node which is the object of the force (!) operator or which has
* the .EXEC attribute is always considered out-of-date.
@@ -221,8 +222,6 @@ Make_OODate (gn)
if (DEBUG(MAKE)) {
if (gn->type & OP_FORCE) {
printf("! operator...");
- } else if (gn->type & OP_PHONY) {
- printf(".PHONY node...");
} else {
printf(".EXEC node...");
}
@@ -340,7 +339,7 @@ Make_HandleUse (cgn, pgn)
*/
(void) Lst_Concat (pgn->commands, cgn->commands, LST_CONCNEW);
}
-
+
if (Lst_Open (cgn->children) == SUCCESS) {
while ((ln = Lst_Next (cgn->children)) != NILLNODE) {
gn = (GNode *)Lst_Datum (ln);
@@ -353,7 +352,7 @@ Make_HandleUse (cgn, pgn)
}
Lst_Close (cgn->children);
}
-
+
pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM);
/*
@@ -382,7 +381,7 @@ MakeHandleUse (pgn, cgn)
* Make_Update --
* Perform update on the parents of a node. Used by JobFinish once
* a node has been dealt with and by MakeStartJobs if it finds an
- * up-to-date node.
+ * up-to-date node.
*
* Results:
* Always returns 0
@@ -481,7 +480,7 @@ Make_Update (cgn)
}
#endif
}
-
+
if (Lst_Open (cgn->parents) == SUCCESS) {
while ((ln = Lst_Next (cgn->parents)) != NILLNODE) {
pgn = (GNode *)Lst_Datum (ln);
@@ -526,7 +525,7 @@ Make_Update (cgn)
(void)Lst_EnQueue(toBeMade, (ClientData)succ);
}
}
-
+
/*
* Set the .PREFIX and .IMPSRC variables for all the implied parents
* of this node.
@@ -578,16 +577,9 @@ MakeAddAllSrc (cgnp, pgnp)
GNode *pgn = (GNode *) pgnp;
if ((cgn->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) == 0) {
char *child;
- char *p1 = NULL;
+ char *p1;
- if (OP_NOP(cgn->type)) {
- /*
- * this node is only source; use the specific pathname for it
- */
- child = cgn->path ? cgn->path : cgn->name;
- }
- else
- child = Var_Value(TARGET, cgn, &p1);
+ child = Var_Value(TARGET, cgn, &p1);
Var_Append (ALLSRC, child, pgn);
if (pgn->type & OP_JOIN) {
if (cgn->made == MADE) {
@@ -683,7 +675,7 @@ static Boolean
MakeStartJobs ()
{
register GNode *gn;
-
+
while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
gn = (GNode *) Lst_DeQueue (toBeMade);
if (DEBUG(MAKE)) {
@@ -716,7 +708,7 @@ MakeStartJobs ()
continue;
}
}
-
+
numNodes--;
if (Make_OODate (gn)) {
if (DEBUG(MAKE)) {
@@ -741,7 +733,7 @@ MakeStartJobs ()
*/
Make_DoAllVar (gn);
}
-
+
Make_Update (gn);
}
}
@@ -836,22 +828,22 @@ Make_Run (targs)
examine = Lst_Duplicate(targs, NOCOPY);
numNodes = 0;
-
+
/*
* Make an initial downward pass over the graph, marking nodes to be made
* as we go down. We call Suff_FindDeps to find where a node is and
* to get some children for it if it has none and also has no commands.
* If the node is a leaf, we stick it on the toBeMade queue to
* be looked at in a minute, otherwise we add its children to our queue
- * and go on about our business.
+ * and go on about our business.
*/
while (!Lst_IsEmpty (examine)) {
gn = (GNode *) Lst_DeQueue (examine);
-
+
if (!gn->make) {
gn->make = TRUE;
numNodes++;
-
+
/*
* Apply any .USE rules before looking for implicit dependencies
* to make sure everything has commands that should...
@@ -866,7 +858,7 @@ Make_Run (targs)
}
}
}
-
+
Lst_Destroy (examine, NOFREE);
if (queryFlag) {
@@ -882,7 +874,7 @@ Make_Run (targs)
* get started, nothing will happen since the remaining upward
* traversal of the graph is performed by the routines in job.c upon
* the finishing of a job. So we fill the Job table as much as we can
- * before going into our loop.
+ * before going into our loop.
*/
(void) MakeStartJobs();
}
@@ -911,6 +903,6 @@ Make_Run (targs)
*/
errors = ((errors == 0) && (numNodes != 0));
Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors);
-
+
return (TRUE);
}
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index c0fe81b68dbf..3af67f7e4157 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -1,5 +1,3 @@
-/* $NetBSD: make.h,v 1.10 1996/08/13 16:39:30 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)make.h 8.3 (Berkeley) 6/13/95
+ * @(#)make.h 8.3 (Berkeley) 6/13/95
*/
/*-
@@ -52,15 +50,13 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#if !defined(MAKE_BOOTSTRAP) && defined(BSD)
+#ifndef MAKE_BOOTSTRAP
#include <sys/cdefs.h>
#else
-#ifndef __P
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else
-#define __P(protos) () /* traditional C preprocessor */
-#endif
+#define __P(protos) () /* traditional C preprocessor */
#endif
#endif
#if __STDC__
@@ -98,13 +94,12 @@
* 16) a Lst of ``local'' variables that are specific to this target
* and this target only (qv. var.c [$@ $< $?, etc.])
* 17) a Lst of strings that are commands to be given to a shell
- * to create this target.
+ * to create this target.
*/
typedef struct GNode {
char *name; /* The target's name */
char *path; /* The full pathname of the file */
int type; /* Its type (see the OP flags, below) */
- int order; /* Its wait weight */
Boolean make; /* TRUE if this target needs to be remade */
enum {
@@ -155,7 +150,7 @@ typedef struct GNode {
} GNode;
/*
- * Manifest constants
+ * Manifest constants
*/
#define NILGNODE ((GNode *) NIL)
@@ -166,7 +161,7 @@ typedef struct GNode {
* placed in the 'type' field of each node. Any node that has
* a 'type' field which satisfies the OP_NOP function was never never on
* the lefthand side of an operator, though it may have been on the
- * righthand side...
+ * righthand side...
*/
#define OP_DEPENDS 0x00000001 /* Execution of commands depends on
* kids (:) */
@@ -221,7 +216,7 @@ typedef struct GNode {
* do if the desired node(s) is (are) not found. If the TARG_CREATE constant
* is given, a new, empty node will be created for the target, placed in the
* table of all targets and its address returned. If TARG_NOCREATE is given,
- * a NIL pointer will be returned.
+ * a NIL pointer will be returned.
*/
#define TARG_CREATE 0x01 /* create node if not found */
#define TARG_NOCREATE 0x00 /* don't create it */
@@ -233,7 +228,7 @@ typedef struct GNode {
* If longer, it should be increased. Reducing it will cause more copying to
* be done for longer lines, but will save space for shorter ones. In any
* case, it ought to be a power of two simply because most storage allocation
- * schemes allocate in powers of two.
+ * schemes allocate in powers of two.
*/
#define MAKE_BSIZE 256 /* starting size for expandable buffers */
@@ -244,7 +239,7 @@ typedef struct GNode {
* be used instead of a space. If neither is given, no intervening characters
* will be placed between the two strings in the final output. If the
* STR_DOFREE bit is set, the two input strings will be freed before
- * Str_Concat returns.
+ * Str_Concat returns.
*/
#define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */
#define STR_DOFREE 0x02 /* free source strings after concatenation */
@@ -284,7 +279,7 @@ typedef struct GNode {
#define DPREFIX "*D" /* directory part of PREFIX */
/*
- * Global Variables
+ * Global Variables
*/
extern Lst create; /* The list of target names specified on the
* command line. used to resolve #if
@@ -328,8 +323,6 @@ extern time_t now; /* The time at the start of this whole
extern Boolean oldVars; /* Do old-style variable substitution */
-extern Lst sysIncPath; /* The system include path. */
-
/*
* debug control:
* There is one bit per module. It is up to the module what debug
diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h
index 705412654fd7..039d4b967ed2 100644
--- a/usr.bin/make/nonints.h
+++ b/usr.bin/make/nonints.h
@@ -1,5 +1,3 @@
-/* $NetBSD: nonints.h,v 1.11 1996/08/13 16:42:11 christos Exp $ */
-
/*-
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
+ * @(#)nonints.h 8.4 (Berkeley) 4/28/95
*/
/* arch.c */
@@ -65,18 +63,14 @@ void For_Run __P((void));
/* main.c */
void Main_ParseArgLine __P((char *));
int main __P((int, char **));
-char *Cmd_Exec __P((char *, char **));
void Error __P((char *, ...));
void Fatal __P((char *, ...));
void Punt __P((char *, ...));
void DieHorribly __P((void));
int PrintAddr __P((ClientData, ClientData));
void Finish __P((int));
-char *estrdup __P((const char *));
-void *emalloc __P((size_t));
-void *erealloc __P((void *, size_t));
+char *emalloc __P((size_t));
void enomem __P((void));
-int eunlink __P((const char *));
/* parse.c */
void Parse_Error __P((int, char *, ...));
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 669c68a15436..e4d8446279bd 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,5 +1,3 @@
-/* $NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
-#else
-static char rcsid[] = "$NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $";
-#endif
+static char sccsid[] = "@(#)parse.c 8.6 (Berkeley) 6/13/95";
#endif /* not lint */
/*-
@@ -96,6 +90,7 @@ static char rcsid[] = "$NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
+#include <sys/wait.h>
#include "make.h"
#include "hash.h"
#include "dir.h"
@@ -167,20 +162,17 @@ typedef enum {
NotParallel, /* .NOTPARALELL */
Null, /* .NULL */
Order, /* .ORDER */
- Parallel, /* .PARALLEL */
ExPath, /* .PATH */
- Phony, /* .PHONY */
Precious, /* .PRECIOUS */
+ Reserved, /* .RESERVED or .[A-Z]* */
ExShell, /* .SHELL */
Silent, /* .SILENT */
SingleShell, /* .SINGLESHELL */
Suffixes, /* .SUFFIXES */
- Wait, /* .WAIT */
Attribute /* Generic attribute */
} ParseSpecial;
static ParseSpecial specType;
-static int waiting;
/*
* Predecessor node for handling .ORDER. Initialized to NILGNODE when .ORDER
@@ -200,44 +192,70 @@ static struct {
ParseSpecial spec; /* Type when used as a target */
int op; /* Operator when used as a source */
} parseKeywords[] = {
+#define DOT_BEGIN 0
{ ".BEGIN", Begin, 0 },
+#define DOT_DEFAULT 1
{ ".DEFAULT", Default, 0 },
+#define DOT_END 2
{ ".END", End, 0 },
+#define DOT_EXEC 3
{ ".EXEC", Attribute, OP_EXEC },
+#define DOT_IGNORE 4
{ ".IGNORE", Ignore, OP_IGNORE },
+#define DOT_INCLUDES 5
{ ".INCLUDES", Includes, 0 },
+#define DOT_INTERRUPT 6
{ ".INTERRUPT", Interrupt, 0 },
+#define DOT_INVISIBLE 7
{ ".INVISIBLE", Attribute, OP_INVISIBLE },
+#define DOT_JOIN 8
{ ".JOIN", Attribute, OP_JOIN },
+#define DOT_LIBS 9
{ ".LIBS", Libs, 0 },
+#define DOT_MAIN 10
{ ".MAIN", Main, 0 },
+#define DOT_MAKE 11
{ ".MAKE", Attribute, OP_MAKE },
+#define DOT_MAKEFLAGS 12
{ ".MAKEFLAGS", MFlags, 0 },
+#define DOT_MFLAGS 13
{ ".MFLAGS", MFlags, 0 },
+#define DOT_NOTMAIN 14
{ ".NOTMAIN", Attribute, OP_NOTMAIN },
+#define DOT_NOTPARALLEL 15
{ ".NOTPARALLEL", NotParallel, 0 },
-{ ".NO_PARALLEL", NotParallel, 0 },
+#define DOT_NULL 16
{ ".NULL", Null, 0 },
+#define DOT_OPTIONAL 17
{ ".OPTIONAL", Attribute, OP_OPTIONAL },
+#define DOT_ORDER 18
{ ".ORDER", Order, 0 },
-{ ".PARALLEL", Parallel, 0 },
+#define DOT_PATH 19
{ ".PATH", ExPath, 0 },
-{ ".PHONY", Phony, OP_PHONY },
+#define DOT_PHONY 20
+{ ".PHONY", Attribute, OP_PHONY },
+#define DOT_PRECIOUS 21
{ ".PRECIOUS", Precious, OP_PRECIOUS },
+#define DOT_RECURSIVE 22
{ ".RECURSIVE", Attribute, OP_MAKE },
+#define DOT_RESERVED 23
+{ ".RESERVED", Reserved, 0 },
+#define DOT_SHELL 24
{ ".SHELL", ExShell, 0 },
+#define DOT_SILENT 25
{ ".SILENT", Silent, OP_SILENT },
+#define DOT_SINGLESHELL 26
{ ".SINGLESHELL", SingleShell, 0 },
+#define DOT_SUFFIXES 27
{ ".SUFFIXES", Suffixes, 0 },
+#define DOT_USE 28
{ ".USE", Attribute, OP_USE },
-{ ".WAIT", Wait, 0 },
};
static int ParseFindKeyword __P((char *));
static int ParseLinkSrc __P((ClientData, ClientData));
static int ParseDoOp __P((ClientData, ClientData));
-static int ParseAddDep __P((ClientData, ClientData));
-static void ParseDoSrc __P((int, char *, Lst));
+static void ParseDoSrc __P((int, char *));
static int ParseFindMain __P((ClientData, ClientData));
static int ParseAddDir __P((ClientData, ClientData));
static int ParseClearPath __P((ClientData, ClientData));
@@ -275,7 +293,7 @@ ParseFindKeyword (str)
end,
cur;
register int diff;
-
+
start = 0;
end = (sizeof(parseKeywords)/sizeof(parseKeywords[0])) - 1;
@@ -291,7 +309,12 @@ ParseFindKeyword (str)
start = cur + 1;
}
} while (start <= end);
- return (-1);
+
+ cur = 0;
+ for (++str; *str; str++)
+ if (!isupper((unsigned char) *str))
+ break;
+ return *str ? -1 : DOT_RESERVED;
}
/*-
@@ -398,7 +421,7 @@ ParseDoOp (gnp, opp)
/*
* If the dependency mask of the operator and the node don't match and
* the node has actually had an operator applied to it before, and
- * the operator actually has some dependency information in it, complain.
+ * the operator actually has some dependency information in it, complain.
*/
if (((op & OP_OPMASK) != (gn->type & OP_OPMASK)) &&
!OP_NOP(gn->type) && !OP_NOP(op))
@@ -418,7 +441,7 @@ ParseDoOp (gnp, opp)
*/
register GNode *cohort;
LstNode ln;
-
+
cohort = Targ_NewGN(gn->name);
/*
* Duplicate links to parents so graph traversal is simple. Perhaps
@@ -442,7 +465,7 @@ ParseDoOp (gnp, opp)
}
/*
* We don't want to nuke any previous flags (whatever they were) so we
- * just OR the new operator into the old
+ * just OR the new operator into the old
*/
gn->type |= op;
@@ -451,45 +474,6 @@ ParseDoOp (gnp, opp)
/*-
*---------------------------------------------------------------------
- * ParseAddDep --
- * Check if the pair of GNodes given needs to be synchronized.
- * This has to be when two nodes are on different sides of a
- * .WAIT directive.
- *
- * Results:
- * Returns 1 if the two targets need to be ordered, 0 otherwise.
- * If it returns 1, the search can stop
- *
- * Side Effects:
- * A dependency can be added between the two nodes.
- *
- *---------------------------------------------------------------------
- */
-int
-ParseAddDep(pp, sp)
- ClientData pp;
- ClientData sp;
-{
- GNode *p = (GNode *) pp;
- GNode *s = (GNode *) sp;
-
- if (p->order < s->order) {
- /*
- * XXX: This can cause loops, and loops can cause unmade targets,
- * but checking is tedious, and the debugging output can show the
- * problem
- */
- (void)Lst_AtEnd(p->successors, (ClientData)s);
- (void)Lst_AtEnd(s->preds, (ClientData)p);
- return 0;
- }
- else
- return 1;
-}
-
-
-/*-
- *---------------------------------------------------------------------
* ParseDoSrc --
* Given the name of a source, figure out if it is an attribute
* and apply it to the targets if it is. Else decide if there is
@@ -506,31 +490,23 @@ ParseAddDep(pp, sp)
*---------------------------------------------------------------------
*/
static void
-ParseDoSrc (tOp, src, allsrc)
+ParseDoSrc (tOp, src)
int tOp; /* operator (if any) from special targets */
char *src; /* name of the source to handle */
- Lst allsrc; /* List of all sources to wait for */
-
{
- GNode *gn = NULL;
+ int op; /* operator (if any) from special source */
+ GNode *gn;
+ op = 0;
if (*src == '.' && isupper (src[1])) {
int keywd = ParseFindKeyword(src);
if (keywd != -1) {
- int op = parseKeywords[keywd].op;
- if (op != 0) {
- Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
- return;
- }
- if (parseKeywords[keywd].spec == Wait) {
- waiting++;
- return;
- }
+ op = parseKeywords[keywd].op;
}
}
-
- switch (specType) {
- case Main:
+ if (op != 0) {
+ Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
+ } else if (specType == Main) {
/*
* If we have noted the existence of a .MAIN, it means we need
* to add the sources of said target to the list of things
@@ -539,15 +515,13 @@ ParseDoSrc (tOp, src, allsrc)
* invoked if the user didn't specify a target on the command
* line. This is to allow #ifmake's to succeed, or something...
*/
- (void) Lst_AtEnd (create, (ClientData)estrdup(src));
+ (void) Lst_AtEnd (create, (ClientData)strdup(src));
/*
* Add the name to the .TARGETS variable as well, so the user cna
* employ that, if desired.
*/
Var_Append(".TARGETS", src, VAR_GLOBAL);
- return;
-
- case Order:
+ } else if (specType == Order) {
/*
* Create proper predecessor/successor links between the previous
* source and the current one.
@@ -561,9 +535,7 @@ ParseDoSrc (tOp, src, allsrc)
* The current source now becomes the predecessor for the next one.
*/
predecessor = gn;
- break;
-
- default:
+ } else {
/*
* If the source is not an attribute, we need to find/create
* a node for it. After that we can apply any operator to it
@@ -594,13 +566,6 @@ ParseDoSrc (tOp, src, allsrc)
}
}
}
- break;
- }
-
- gn->order = waiting;
- (void)Lst_AtEnd(allsrc, (ClientData)gn);
- if (waiting) {
- Lst_ForEach(allsrc, ParseAddDep, (ClientData)gn);
}
}
@@ -723,21 +688,17 @@ ParseDoDependency (line)
Lst paths; /* List of search paths to alter when parsing
* a list of .PATH targets */
int tOp; /* operator from special target */
- Lst sources; /* list of archive source names after
- * expansion */
+ Lst sources; /* list of source names after expansion */
Lst curTargs; /* list of target names to be found and added
* to the targets list */
- Lst curSrcs; /* list of sources in order */
tOp = 0;
specType = Not;
- waiting = 0;
paths = (Lst)NULL;
curTargs = Lst_Init(FALSE);
- curSrcs = Lst_Init(FALSE);
-
+
do {
for (cp = line;
*cp && !isspace (*cp) &&
@@ -785,11 +746,11 @@ ParseDoDependency (line)
}
}
savec = *cp;
-
+
if (!*cp) {
/*
* Ending a dependency line without an operator is a Bozo
- * no-no
+ * no-no
*/
Parse_Error (PARSE_FATAL, "Need an operator");
return;
@@ -802,7 +763,7 @@ ParseDoDependency (line)
if (*line == '.' && isupper (line[1])) {
/*
* See if the target is a special target that must have it
- * or its sources handled specially.
+ * or its sources handled specially.
*/
int keywd = ParseFindKeyword(line);
if (keywd != -1) {
@@ -810,7 +771,7 @@ ParseDoDependency (line)
Parse_Error(PARSE_FATAL, "Mismatched special targets");
return;
}
-
+
specType = parseKeywords[keywd].spec;
tOp = parseKeywords[keywd].op;
@@ -833,7 +794,6 @@ ParseDoDependency (line)
* life easier later, when we'll
* use Make_HandleUse to actually
* apply the .DEFAULT commands.
- * .PHONY The list of targets
* .BEGIN
* .END
* .INTERRUPT Are not to be considered the
@@ -870,7 +830,7 @@ ParseDoDependency (line)
case NotParallel:
{
extern int maxJobs;
-
+
maxJobs = 1;
break;
}
@@ -880,6 +840,12 @@ ParseDoDependency (line)
case Order:
predecessor = NILGNODE;
break;
+ case Reserved:
+ /*
+ * A posix reserved target that we don't know
+ * how to deal with.
+ */
+ return;
default:
break;
}
@@ -890,7 +856,7 @@ ParseDoDependency (line)
* modify.
*/
Lst path;
-
+
specType = ExPath;
path = Suff_GetPath (&line[5]);
if (path == NILLST) {
@@ -906,10 +872,10 @@ ParseDoDependency (line)
}
}
}
-
+
/*
* Have word in line. Get or create its node and stick it at
- * the end of the targets list
+ * the end of the targets list
*/
if ((specType == Not) && (*line != '\0')) {
if (Dir_HasWildcards(line)) {
@@ -920,9 +886,9 @@ ParseDoDependency (line)
* Dir module could have added a directory to the path...
*/
Lst emptyPath = Lst_Init(FALSE);
-
+
Dir_Expand(line, emptyPath, curTargs);
-
+
Lst_Destroy(emptyPath, Dir_Destroy);
} else {
/*
@@ -931,22 +897,22 @@ ParseDoDependency (line)
*/
(void)Lst_AtEnd(curTargs, (ClientData)line);
}
-
+
while(!Lst_IsEmpty(curTargs)) {
char *targName = (char *)Lst_DeQueue(curTargs);
-
+
if (!Suff_IsTransform (targName)) {
gn = Targ_FindNode (targName, TARG_CREATE);
} else {
gn = Suff_AddTransform (targName);
}
-
+
(void)Lst_AtEnd (targets, (ClientData)gn);
}
} else if (specType == ExPath && *line != '.' && *line != '\0') {
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
}
-
+
*cp = savec;
/*
* If it is a special type and not .PATH, it's the only target we
@@ -954,7 +920,7 @@ ParseDoDependency (line)
*/
if (specType != Not && specType != ExPath) {
Boolean warn = FALSE;
-
+
while ((*cp != '!') && (*cp != ':') && *cp) {
if (*cp != ' ' && *cp != '\t') {
warn = TRUE;
@@ -1021,7 +987,7 @@ ParseDoDependency (line)
Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
/*
- * Get to the first source
+ * Get to the first source
*/
while (*cp && isspace (*cp)) {
cp++;
@@ -1074,9 +1040,9 @@ ParseDoDependency (line)
} else if ((specType == NotParallel) || (specType == SingleShell)) {
*line = '\0';
}
-
+
/*
- * NOW GO FOR THE SOURCES
+ * NOW GO FOR THE SOURCES
*/
if ((specType == Suffixes) || (specType == ExPath) ||
(specType == Includes) || (specType == Libs) ||
@@ -1177,7 +1143,7 @@ ParseDoDependency (line)
while (!Lst_IsEmpty (sources)) {
gn = (GNode *) Lst_DeQueue (sources);
- ParseDoSrc (tOp, gn->name, curSrcs);
+ ParseDoSrc (tOp, gn->name);
}
Lst_Destroy (sources, NOFREE);
cp = line;
@@ -1187,7 +1153,7 @@ ParseDoDependency (line)
cp += 1;
}
- ParseDoSrc (tOp, line, curSrcs);
+ ParseDoSrc (tOp, line);
}
while (*cp && isspace (*cp)) {
cp++;
@@ -1195,7 +1161,7 @@ ParseDoDependency (line)
line = cp;
}
}
-
+
if (mainNode == NILGNODE) {
/*
* If we have yet to decide on a main target to make, in the
@@ -1206,10 +1172,6 @@ ParseDoDependency (line)
Lst_ForEach (targets, ParseFindMain, (ClientData)0);
}
- /*
- * Finally, destroy the list of sources
- */
- Lst_Destroy(curSrcs, NOFREE);
}
/*-
@@ -1234,80 +1196,60 @@ Parse_IsVar (line)
{
register Boolean wasSpace = FALSE; /* set TRUE if found a space */
register Boolean haveName = FALSE; /* Set TRUE if have a variable name */
- int level = 0;
-#define ISEQOPERATOR(c) \
- (((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!'))
/*
* Skip to variable name
*/
- for (;(*line == ' ') || (*line == '\t'); line++)
- continue;
+ while ((*line == ' ') || (*line == '\t')) {
+ line++;
+ }
- for (; *line != '=' || level != 0; line++)
- switch (*line) {
- case '\0':
+ while (*line != '=') {
+ if (*line == '\0') {
/*
* end-of-line -- can't be a variable assignment.
*/
- return FALSE;
-
- case ' ':
- case '\t':
+ return (FALSE);
+ } else if ((*line == ' ') || (*line == '\t')) {
/*
* there can be as much white space as desired so long as there is
- * only one word before the operator
+ * only one word before the operator
*/
wasSpace = TRUE;
- break;
-
- case '(':
- case '{':
- level++;
- break;
-
- case '}':
- case ')':
- level--;
- break;
-
- default:
- if (wasSpace && haveName) {
- if (ISEQOPERATOR(*line)) {
- /*
- * We must have a finished word
- */
- if (level != 0)
- return FALSE;
-
- /*
- * When an = operator [+?!:] is found, the next
- * character must be an = or it ain't a valid
- * assignment.
- */
- if (line[1] == '=')
- return haveName;
-#ifdef SUNSHCMD
- /*
- * This is a shell command
- */
- if (strncmp(line, ":sh", 3) == 0)
- return haveName;
-#endif
- }
- /*
- * This is the start of another word, so not assignment.
- */
- return FALSE;
- }
- else {
- haveName = TRUE;
- wasSpace = FALSE;
+ } else if (wasSpace && haveName) {
+ /*
+ * Stop when an = operator is found.
+ */
+ if ((*line == '+') || (*line == ':') || (*line == '?') ||
+ (*line == '!')) {
+ break;
}
- break;
+
+ /*
+ * This is the start of another word, so not assignment.
+ */
+ return (FALSE);
+ } else {
+ haveName = TRUE;
+ wasSpace = FALSE;
}
+ line++;
+ }
- return haveName;
+ /*
+ * A final check: if we stopped on a +, ?, ! or :, the next character must
+ * be an = or it ain't a valid assignment
+ */
+ if (((*line == '+') ||
+ (*line == '?') ||
+ (*line == ':') ||
+ (*line == '!')) &&
+ (line[1] != '='))
+ {
+ return (FALSE);
+ } else {
+ return (haveName);
+ }
}
/*-
@@ -1340,9 +1282,9 @@ Parse_DoVar (line, ctxt)
enum {
VAR_SUBST, VAR_APPEND, VAR_SHELL, VAR_NORMAL
} type; /* Type of assignment */
- char *opc; /* ptr to operator character to
+ char *opc; /* ptr to operator character to
* null-terminate the variable name */
- /*
+ /*
* Avoid clobbered variable warnings by forcing the compiler
* to ``unregister'' variables
*/
@@ -1401,17 +1343,6 @@ Parse_DoVar (line, ctxt)
break;
default:
-#ifdef SUNSHCMD
- while (*opc != ':')
- if (--opc < line)
- break;
-
- if (strncmp(opc, ":sh", 3) == 0) {
- type = VAR_SHELL;
- *opc = '\0';
- break;
- }
-#endif
type = VAR_NORMAL;
break;
}
@@ -1443,38 +1374,156 @@ Parse_DoVar (line, ctxt)
Var_Set(line, cp, ctxt);
free(cp);
} else if (type == VAR_SHELL) {
- Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
- * if any variable expansion was performed */
- char *res, *err;
+ char *args[4]; /* Args for invoking the shell */
+ int fds[2]; /* Pipe streams */
+ int cpid; /* Child PID */
+ int pid; /* PID from wait() */
+ Boolean freeCmd; /* TRUE if the command needs to be freed, i.e.
+ * if any variable expansion was performed */
+
+ /*
+ * Avoid clobbered variable warnings by forcing the compiler
+ * to ``unregister'' variables
+ */
+#if __GNUC__
+ (void) &freeCmd;
+#endif
- if (strchr(cp, '$') != NULL) {
+ /*
+ * Set up arguments for shell
+ */
+ args[0] = "sh";
+ args[1] = "-c";
+ if (strchr(cp, '$') != (char *)NULL) {
/*
* There's a dollar sign in the command, so perform variable
* expansion on the whole thing. The resulting string will need
* freeing when we're done, so set freeCmd to TRUE.
*/
- cp = Var_Subst(NULL, cp, VAR_CMD, TRUE);
+ args[2] = Var_Subst(NULL, cp, VAR_CMD, TRUE);
freeCmd = TRUE;
+ } else {
+ args[2] = cp;
+ freeCmd = FALSE;
}
+ args[3] = (char *)NULL;
+
+ /*
+ * Open a pipe for fetching its output
+ */
+ pipe(fds);
+
+ /*
+ * Fork
+ */
+ cpid = vfork();
+ if (cpid == 0) {
+ /*
+ * Close input side of pipe
+ */
+ close(fds[0]);
- res = Cmd_Exec(cp, &err);
- Var_Set(line, res, ctxt);
- free(res);
+ /*
+ * Duplicate the output stream to the shell's output, then
+ * shut the extra thing down. Note we don't fetch the error
+ * stream...why not? Why?
+ */
+ dup2(fds[1], 1);
+ close(fds[1]);
+
+ execv("/bin/sh", args);
+ _exit(1);
+ } else if (cpid < 0) {
+ /*
+ * Couldn't fork -- tell the user and make the variable null
+ */
+ Parse_Error(PARSE_WARNING, "Couldn't exec \"%s\"", cp);
+ Var_Set(line, "", ctxt);
+ } else {
+ int status;
+ int cc;
+ Buffer buf;
+ char *res;
- if (err)
- Parse_Error(PARSE_WARNING, err, cp);
+ /*
+ * No need for the writing half
+ */
+ close(fds[1]);
+
+ buf = Buf_Init (MAKE_BSIZE);
+
+ do {
+ char result[BUFSIZ];
+ cc = read(fds[0], result, sizeof(result));
+ if (cc > 0)
+ Buf_AddBytes(buf, cc, (Byte *) result);
+ }
+ while (cc > 0 || (cc == -1 && errno == EINTR));
+
+ /*
+ * Close the input side of the pipe.
+ */
+ close(fds[0]);
- if (freeCmd)
- free(cp);
+ /*
+ * Wait for the process to exit.
+ */
+ while(((pid = wait(&status)) != cpid) && (pid >= 0))
+ continue;
+
+ res = (char *)Buf_GetAll (buf, &cc);
+ Buf_Destroy (buf, FALSE);
+
+ if (cc == 0) {
+ /*
+ * Couldn't read the child's output -- tell the user and
+ * set the variable to null
+ */
+ Parse_Error(PARSE_WARNING, "Couldn't read shell's output");
+ }
+
+ if (status) {
+ /*
+ * Child returned an error -- tell the user but still use
+ * the result.
+ */
+ Parse_Error(PARSE_WARNING, "\"%s\" returned non-zero", cp);
+ }
+
+ /*
+ * Null-terminate the result, convert newlines to spaces and
+ * install it in the variable.
+ */
+ res[cc] = '\0';
+ cp = &res[cc] - 1;
+
+ if (*cp == '\n') {
+ /*
+ * A final newline is just stripped
+ */
+ *cp-- = '\0';
+ }
+ while (cp >= res) {
+ if (*cp == '\n') {
+ *cp = ' ';
+ }
+ cp--;
+ }
+ Var_Set(line, res, ctxt);
+ free(res);
+
+ }
+ if (freeCmd) {
+ free(args[2]);
+ }
} else {
/*
* Normal assignment -- just do it.
*/
- Var_Set(line, cp, ctxt);
+ Var_Set (line, cp, ctxt);
}
}
-
/*-
* ParseAddCmd --
* Lst_ForEach function to add a command line to all targets
@@ -1548,7 +1597,7 @@ Parse_AddIncludeDir (dir)
*---------------------------------------------------------------------
* ParseDoInclude --
* Push to another file.
- *
+ *
* The input is the line minus the #include. A file spec is a string
* enclosed in <> or "". The former is looked for only in sysIncPath.
* The latter in . and the directories specified by -I command line
@@ -1632,20 +1681,17 @@ ParseDoInclude (file)
* leading path components and call Dir_FindFile to see if
* we can locate the beast.
*/
- char *prefEnd, *Fname;
+ char *prefEnd;
- /* Make a temporary copy of this, to be safe. */
- Fname = estrdup(fname);
-
- prefEnd = strrchr (Fname, '/');
+ prefEnd = strrchr (fname, '/');
if (prefEnd != (char *)NULL) {
char *newName;
-
+
*prefEnd = '\0';
if (file[0] == '/')
- newName = estrdup(file);
+ newName = strdup(file);
else
- newName = str_concat (Fname, file, STR_ADDSLASH);
+ newName = str_concat (fname, file, STR_ADDSLASH);
fullname = Dir_FindFile (newName, parseIncPath);
if (fullname == (char *)NULL) {
fullname = Dir_FindFile(newName, dirSearchPath);
@@ -1655,7 +1701,6 @@ ParseDoInclude (file)
} else {
fullname = (char *)NULL;
}
- free (Fname);
} else {
fullname = (char *)NULL;
}
@@ -1730,7 +1775,7 @@ ParseDoInclude (file)
*---------------------------------------------------------------------
* Parse_FromString --
* Start Parsing from the given string
- *
+ *
* Results:
* None
*
@@ -1753,14 +1798,14 @@ Parse_FromString(str)
oldFile->fname = fname;
oldFile->F = curFILE;
oldFile->p = curPTR;
-
+
(void) Lst_AtFront (includes, (ClientData)oldFile);
curFILE = NULL;
curPTR = (PTR *) emalloc (sizeof (PTR));
curPTR->str = curPTR->ptr = str;
lineno = 0;
- fname = estrdup(fname);
+ fname = strdup(fname);
}
@@ -1769,7 +1814,7 @@ Parse_FromString(str)
*---------------------------------------------------------------------
* ParseTraditionalInclude --
* Push to another file.
- *
+ *
* The input is the line minus the "include". The file name is
* the string following the "include".
*
@@ -1832,7 +1877,7 @@ ParseTraditionalInclude (file)
prefEnd = strrchr (fname, '/');
if (prefEnd != (char *)NULL) {
char *newName;
-
+
*prefEnd = '\0';
newName = str_concat (fname, file, STR_ADDSLASH);
fullname = Dir_FindFile (newName, parseIncPath);
@@ -1952,7 +1997,7 @@ ParseEOF (opened)
/*-
*---------------------------------------------------------------------
* ParseReadc --
- * Read a character from the current file
+ * Read a character from the current file
*
* Results:
* The character that was read
@@ -1965,7 +2010,7 @@ ParseReadc()
{
if (curFILE)
return fgetc(curFILE);
-
+
if (curPTR && *curPTR->ptr)
return *curPTR->ptr++;
return EOF;
@@ -1975,7 +2020,7 @@ ParseReadc()
/*-
*---------------------------------------------------------------------
* ParseUnreadc --
- * Put back a character to the current file
+ * Put back a character to the current file
*
* Results:
* None.
@@ -2006,43 +2051,54 @@ ParseSkipLine(skip)
int skip; /* Skip lines that don't start with . */
{
char *line;
- int c, lastc, lineLength = 0;
+ int c, lastc = '\0', lineLength;
Buffer buf;
- buf = Buf_Init(MAKE_BSIZE);
-
- do {
- Buf_Discard(buf, lineLength);
- lastc = '\0';
-
- while (((c = ParseReadc()) != '\n' || lastc == '\\')
- && c != EOF) {
- if (c == '\n') {
- Buf_ReplaceLastByte(buf, (Byte)' ');
- lineno++;
-
- while ((c = ParseReadc()) == ' ' || c == '\t');
-
- if (c == EOF)
- break;
- }
-
- Buf_AddByte(buf, (Byte)c);
- lastc = c;
- }
+ c = ParseReadc();
- if (c == EOF) {
- Parse_Error(PARSE_FATAL, "Unclosed conditional/for loop");
- Buf_Destroy(buf, TRUE);
- return((char *)NULL);
- }
-
- lineno++;
- Buf_AddByte(buf, (Byte)'\0');
- line = (char *)Buf_GetAll(buf, &lineLength);
- } while (skip == 1 && line[0] != '.');
-
- Buf_Destroy(buf, FALSE);
+ if (skip) {
+ /*
+ * Skip lines until get to one that begins with a
+ * special char.
+ */
+ while ((c != '.') && (c != EOF)) {
+ while (((c != '\n') || (lastc == '\\')) && (c != EOF))
+ {
+ /*
+ * Advance to next unescaped newline
+ */
+ if ((lastc = c) == '\n') {
+ lineno++;
+ }
+ c = ParseReadc();
+ }
+ lineno++;
+
+ lastc = c;
+ c = ParseReadc ();
+ }
+ }
+
+ if (c == EOF) {
+ Parse_Error (PARSE_FATAL, "Unclosed conditional/for loop");
+ return ((char *)NULL);
+ }
+
+ /*
+ * Read the entire line into buf
+ */
+ buf = Buf_Init (MAKE_BSIZE);
+ if (c != '\n') {
+ do {
+ Buf_AddByte (buf, (Byte)c);
+ c = ParseReadc();
+ } while ((c != '\n') && (c != EOF));
+ }
+ lineno++;
+
+ Buf_AddByte (buf, (Byte)'\0');
+ line = (char *)Buf_GetAll (buf, &lineLength);
+ Buf_Destroy (buf, FALSE);
return line;
}
@@ -2108,11 +2164,11 @@ ParseReadLine ()
break;
}
}
-
+
if (c != EOF) {
lastc = c;
buf = Buf_Init(MAKE_BSIZE);
-
+
while (((c = ParseReadc ()) != '\n' || (lastc == '\\')) &&
(c != EOF))
{
@@ -2160,7 +2216,7 @@ test_char:
*/
ParseUnreadc('\t');
goto line_read;
- }
+ }
break;
case '=':
if (!semiNL) {
@@ -2186,11 +2242,7 @@ test_char:
break;
case '#':
if (!ignComment) {
- if (
-#if 0
- compatMake &&
-#endif
- (lastc != '\\')) {
+ if (compatMake && (lastc != '\\')) {
/*
* If the character is a hash mark and it isn't escaped
* (or we're being compatible), the thing is a comment.
@@ -2227,11 +2279,11 @@ test_char:
*/
Buf_AddByte (buf, (Byte)lastc);
lastc = c;
-
+
}
line_read:
lineno++;
-
+
if (lastc != '\0') {
Buf_AddByte (buf, (Byte)lastc);
}
@@ -2247,13 +2299,13 @@ test_char:
ep = line;
while (*ep)
++ep;
- while (ep > line + 1 && (ep[-1] == ' ' || ep[-1] == '\t')) {
+ while (ep > line && (ep[-1] == ' ' || ep[-1] == '\t')) {
if (ep > line + 1 && ep[-2] == '\\')
break;
--ep;
}
*ep = 0;
-
+
if (line[0] == '.') {
/*
* The line might be a conditional. Ask the conditional module
@@ -2285,7 +2337,7 @@ test_char:
*/
line = ParseSkipLine(0);
if (line == NULL) {
- Parse_Error (PARSE_FATAL,
+ Parse_Error (PARSE_FATAL,
"Unexpected end of file in for loop.\n");
break;
}
@@ -2333,7 +2385,7 @@ ParseFinishLine()
inLine = FALSE;
}
}
-
+
/*-
*---------------------------------------------------------------------
@@ -2394,11 +2446,12 @@ Parse_File(name, stream)
goto nextLine;
}
}
- if (*line == '#') {
- /* If we're this far, the line must be a comment. */
+ if (*line == '#' || *line == '\0') {
+ /* If we're this far, the line must be a comment.
+ (Empty lines are ignored as well) */
goto nextLine;
}
-
+
if (*line == '\t') {
/*
* If a line starts with a tab, it can only hope to be
@@ -2415,20 +2468,19 @@ Parse_File(name, stream)
/*
* So long as it's not a blank line and we're actually
* in a dependency spec, add the command to the list of
- * commands of all targets in the dependency spec
+ * commands of all targets in the dependency spec
*/
Lst_ForEach (targets, ParseAddCmd, cp);
Lst_AtEnd(targCmds, (ClientData) line);
continue;
} else {
Parse_Error (PARSE_FATAL,
- "Unassociated shell command \"%s\"",
+ "Unassociated shell command \"%.20s\"",
cp);
}
}
#ifdef SYSVINCLUDE
- } else if (strncmp (line, "include", 7) == 0 &&
- isspace((unsigned char) line[7]) &&
+ } else if (strncmp (line, "include", 7) == 0 &&
strchr(line, ':') == NULL) {
/*
* It's an S3/S5-style "include".
@@ -2453,7 +2505,7 @@ Parse_File(name, stream)
#ifndef POSIX
Boolean nonSpace = FALSE;
#endif
-
+
cp = line;
if (isspace((unsigned char) line[0])) {
while ((*cp != '\0') && isspace((unsigned char) *cp)) {
@@ -2469,7 +2521,7 @@ Parse_File(name, stream)
}
#endif
}
-
+
#ifndef POSIX
if (*cp == '\0') {
if (inLine) {
@@ -2486,16 +2538,16 @@ Parse_File(name, stream)
cp = Var_Subst (NULL, line, VAR_CMD, TRUE);
free (line);
line = cp;
-
+
/*
- * Need a non-circular list for the target nodes
+ * Need a non-circular list for the target nodes
*/
if (targets)
Lst_Destroy(targets, NOFREE);
targets = Lst_Init (FALSE);
inLine = TRUE;
-
+
ParseDoDependency (line);
#ifndef POSIX
}
@@ -2507,7 +2559,7 @@ Parse_File(name, stream)
free (line);
}
/*
- * Reached EOF, but it may be just EOF of an include file...
+ * Reached EOF, but it may be just EOF of an include file...
*/
} while (ParseEOF(1) == CONTINUE);
@@ -2537,11 +2589,30 @@ Parse_File(name, stream)
void
Parse_Init ()
{
+ char *cp = NULL, *start;
+ /* avoid faults on read-only strings */
+ static char syspath[] = _PATH_DEFSYSPATH;
+
mainNode = NILGNODE;
parseIncPath = Lst_Init (FALSE);
sysIncPath = Lst_Init (FALSE);
includes = Lst_Init (FALSE);
targCmds = Lst_Init (FALSE);
+
+ /*
+ * Add the directories from the DEFSYSPATH (more than one may be given
+ * as dir1:...:dirn) to the system include path.
+ */
+ for (start = syspath; *start != '\0'; start = cp) {
+ for (cp = start; *cp != '\0' && *cp != ':'; cp++)
+ continue;
+ if (*cp == '\0') {
+ Dir_AddDir(sysIncPath, start);
+ } else {
+ *cp++ = '\0';
+ Dir_AddDir(sysIncPath, start);
+ }
+ }
}
void
@@ -2554,7 +2625,7 @@ Parse_End()
Lst_Destroy(parseIncPath, Dir_Destroy);
Lst_Destroy(includes, NOFREE); /* Should be empty now */
}
-
+
/*-
*-----------------------------------------------------------------------
@@ -2578,7 +2649,7 @@ Parse_MainName()
main = Lst_Init (FALSE);
if (mainNode == NILGNODE) {
- Punt ("no target to make.");
+ Punt ("make: no target to make.\n");
/*NOTREACHED*/
} else if (mainNode->type & OP_DOUBLEDEP) {
(void) Lst_AtEnd (main, (ClientData)mainNode);
diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h
index 9f46b26d0bb0..8cb066148393 100644
--- a/usr.bin/make/pathnames.h
+++ b/usr.bin/make/pathnames.h
@@ -1,5 +1,3 @@
-/* $NetBSD: pathnames.h,v 1.5 1996/08/30 17:59:41 thorpej Exp $ */
-
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,11 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90
+ * @(#)pathnames.h 8.2 (Berkeley) 4/28/95
*/
#define _PATH_OBJDIR "obj"
-#define _PATH_OBJDIRPREFIX "/usr/obj"
#define _PATH_DEFSHELLDIR "/bin"
#define _PATH_DEFSYSMK "sys.mk"
#define _PATH_DEFSYSPATH "/usr/share/mk"
diff --git a/usr.bin/make/sprite.h b/usr.bin/make/sprite.h
index 65e732c1bae7..0da22f180d05 100644
--- a/usr.bin/make/sprite.h
+++ b/usr.bin/make/sprite.h
@@ -1,5 +1,3 @@
-/* $NetBSD: sprite.h,v 1.5 1995/06/14 15:19:54 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93
+ * @(#)sprite.h 8.2 (Berkeley) 4/28/95
*/
/*
@@ -71,7 +69,7 @@ typedef int Boolean;
typedef int ReturnStatus;
/*
- * The following statuses overlap with the first 2 generic statuses
+ * The following statuses overlap with the first 2 generic statuses
* defined in status.h:
*
* SUCCESS There was no error.
@@ -83,7 +81,7 @@ typedef int ReturnStatus;
/*
- * A nil pointer must be something that will cause an exception if
+ * A nil pointer must be something that will cause an exception if
* referenced. There are two nils: the kernels nil and the nil used
* by user processes.
*/
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
index e1e5968922bd..7df8e8d2f113 100644
--- a/usr.bin/make/str.c
+++ b/usr.bin/make/str.c
@@ -1,5 +1,3 @@
-/* $NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $ */
-
/*-
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,12 +37,8 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
-#else
-static char rcsid[] = "$NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $";
-#endif
-#endif /* not lint */
+static char sccsid[] = "@(#)str.c 8.6 (Berkeley) 4/28/95";
+#endif /* not lint */
#include "make.h"
@@ -60,7 +54,7 @@ void
str_init()
{
char *p1;
- argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *));
+ argv = (char **)emalloc((argmax = 50) * sizeof(char *));
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
}
@@ -73,15 +67,15 @@ str_init()
void
str_end()
{
- if (argv) {
- if (argv[0])
- free(argv[0]);
+ if (argv[0]) {
+ free(argv[0]);
free((Address) argv);
}
if (buffer)
free(buffer);
}
+
/*-
* str_concat --
* concatenate the two strings, inserting a space or slash between them,
@@ -207,8 +201,9 @@ brk_string(str, store_argc, expand)
*t++ = '\0';
if (argc == argmax) {
argmax *= 2; /* ramp up fast */
- argv = (char **)erealloc(argv,
- (argmax + 1) * sizeof(char *));
+ if (!(argv = (char **)realloc(argv,
+ argmax * sizeof(char *))))
+ enomem();
}
argv[argc++] = start;
start = (char *)NULL;
@@ -223,7 +218,7 @@ brk_string(str, store_argc, expand)
ch = *++p;
break;
}
-
+
switch (ch = *++p) {
case '\0':
case '\n':
@@ -260,12 +255,12 @@ done: argv[argc] = (char *)NULL;
/*
* Str_FindSubstring -- See if a string contains a particular substring.
- *
+ *
* Results: If string contains substring, the return value is the location of
* the first matching instance of substring in string. If string doesn't
* contain substring, the return value is NULL. Matching is done on an exact
* character-for-character basis with no wildcards or special characters.
- *
+ *
* Side effects: None.
*/
char *
@@ -298,13 +293,13 @@ Str_FindSubstring(string, substring)
/*
* Str_Match --
- *
+ *
* See if a particular string matches a particular pattern.
- *
+ *
* Results: Non-zero is returned if string matches pattern, 0 otherwise. The
* matching operation permits the following special characters in the
* pattern: *?\[] (see the man page for details on what these mean).
- *
+ *
* Side effects: None.
*/
int
@@ -401,8 +396,8 @@ thisCharOK: ++pattern;
/*-
*-----------------------------------------------------------------------
* Str_SYSVMatch --
- * Check word against pattern for a match (% is wild),
- *
+ * Check word against pattern for a match (% is wild),
+ *
* Results:
* Returns the beginning position of a match or null. The number
* of characters matched is returned in len.
@@ -452,7 +447,7 @@ Str_SYSVMatch(word, pattern, len)
return m;
}
while (*w++ != '\0');
-
+
return NULL;
}
@@ -463,7 +458,7 @@ Str_SYSVMatch(word, pattern, len)
* Substitute '%' on the pattern with len characters from src.
* If the pattern does not contain a '%' prepend len characters
* from src.
- *
+ *
* Results:
* None
*
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 0bbbe170de56..1b344d499490 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -1,5 +1,3 @@
-/* $NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
-#else
-static char rcsid[] = "$NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $";
-#endif
+static char sccsid[] = "@(#)suff.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -101,6 +95,7 @@ static char rcsid[] = "$NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $
#include "make.h"
#include "hash.h"
#include "dir.h"
+#include "bit.h"
static Lst sufflist; /* Lst of suffixes */
static Lst suffClean; /* Lst of suffixes to be cleaned */
@@ -164,7 +159,6 @@ static int SuffSuffIsSuffixP __P((ClientData, ClientData));
static int SuffSuffHasNameP __P((ClientData, ClientData));
static int SuffSuffIsPrefix __P((ClientData, ClientData));
static int SuffGNHasNameP __P((ClientData, ClientData));
-static void SuffUnRef __P((ClientData, ClientData));
static void SuffFree __P((ClientData));
static void SuffInsert __P((Lst, Suff *));
static void SuffRemove __P((Lst, Suff *));
@@ -511,7 +505,7 @@ SuffParseTransform(str, srcPtr, targPtr)
srcLn = NILLNODE;
singleLn = NILLNODE;
-
+
/*
* Loop looking first for a suffix that matches the start of the
* string and then for one that exactly matches the rest of it. If
@@ -611,7 +605,7 @@ Suff_AddTransform (line)
if (ln == NILLNODE) {
/*
* Make a new graph node for the transformation. It will be filled in
- * by the Parse module.
+ * by the Parse module.
*/
gn = Targ_NewGN (line);
(void)Lst_AtEnd (transforms, (ClientData)gn);
@@ -634,7 +628,7 @@ Suff_AddTransform (line)
(void)SuffParseTransform(line, &s, &t);
/*
- * link the two together in the proper relationship and order
+ * link the two together in the proper relationship and order
*/
if (DEBUG(SUFF)) {
printf("defining transformation from `%s' to `%s'\n",
@@ -669,7 +663,7 @@ Suff_EndTransform(gnp, dummy)
ClientData dummy; /* Node for transformation */
{
GNode *gn = (GNode *) gnp;
-
+
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
Lst_IsEmpty(gn->children))
{
@@ -802,7 +796,7 @@ Suff_AddSuffix (str)
if (ln == NILLNODE) {
s = (Suff *) emalloc (sizeof (Suff));
- s->name = estrdup (str);
+ s->name = strdup (str);
s->nameLen = strlen (s->name);
s->searchPath = Lst_Init (FALSE);
s->children = Lst_Init (FALSE);
@@ -818,7 +812,7 @@ Suff_AddSuffix (str)
* XXX: Only do this after a Suff_ClearSuffixes?
*/
Lst_ForEach (transforms, SuffRebuildGraph, (ClientData)s);
- }
+ }
}
/*-
@@ -1001,7 +995,7 @@ SuffAddSrc (sp, lsp)
Src *targ; /* Target structure */
targ = ls->s;
-
+
if ((s->flags & SUFF_NULL) && (*s->name != '\0')) {
/*
* If the suffix has been marked as the NULL suffix, also create a Src
@@ -1009,7 +1003,7 @@ SuffAddSrc (sp, lsp)
* that...
*/
s2 = (Src *) emalloc (sizeof (Src));
- s2->file = estrdup(targ->pref);
+ s2->file = strdup(targ->pref);
s2->pref = targ->pref;
s2->parent = targ;
s2->node = NILGNODE;
@@ -1272,7 +1266,7 @@ SuffFindCmds (targ, slst)
* again (ick)), and return the new structure.
*/
ret = (Src *)emalloc (sizeof (Src));
- ret->file = estrdup(s->name);
+ ret->file = strdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
suff->refCount++;
@@ -1331,7 +1325,7 @@ SuffExpandChildren(cgnp, pgnp)
* after the child
*/
prevLN = Lst_Member(pgn->children, (ClientData)cgn);
-
+
/*
* First do variable expansion -- this takes precedence over
* wildcard expansion. If the result contains wildcards, they'll be gotten
@@ -1346,7 +1340,7 @@ SuffExpandChildren(cgnp, pgnp)
if (cp != (char *)NULL) {
Lst members = Lst_Init(FALSE);
-
+
if (cgn->type & OP_ARCHV) {
/*
* Node was an archive(member) target, so we want to call
@@ -1367,7 +1361,7 @@ SuffExpandChildren(cgnp, pgnp)
char *start;
char *initcp = cp; /* For freeing... */
- for (start = cp; *start == ' ' || *start == '\t'; start++)
+ for (start = cp; *start == ' ' || *start == '\t'; start++)
continue;
for (cp = start; *cp != '\0'; cp++) {
if (*cp == ' ' || *cp == '\t') {
@@ -1474,7 +1468,7 @@ SuffExpandChildren(cgnp, pgnp)
if (DEBUG(SUFF)) {
printf("Wildcard expanding \"%s\"...", cgn->name);
}
-
+
if (ln != NILLNODE) {
Suff *s = (Suff *)Lst_Datum(ln);
@@ -1522,7 +1516,7 @@ SuffExpandChildren(cgnp, pgnp)
* Nuke what's left of the list
*/
Lst_Destroy(exp, NOFREE);
-
+
/*
* Now the source is expanded, remove it from the list of children to
* keep it from being processed.
@@ -1615,7 +1609,7 @@ SuffApplyTransform(tGn, sGn, t, s)
}
gn = (GNode *)Lst_Datum(ln);
-
+
if (DEBUG(SUFF)) {
printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
}
@@ -1624,7 +1618,7 @@ SuffApplyTransform(tGn, sGn, t, s)
* Record last child for expansion purposes
*/
ln = Lst_Last(tGn->children);
-
+
/*
* Pass the buck to Make_HandleUse to apply the rule
*/
@@ -1677,7 +1671,7 @@ SuffFindArchiveDeps(gn, slst)
int i; /* Index into copy and vals */
Suff *ms; /* Suffix descriptor for member */
char *name; /* Start of member's name */
-
+
/*
* The node is an archive(member) pair. so we must find a
* suffix for both of them.
@@ -1689,7 +1683,7 @@ SuffFindArchiveDeps(gn, slst)
*eoarch = '\0'; /* So a suffix can be found */
name = eoarch + 1;
-
+
/*
* To simplify things, call Suff_FindDeps recursively on the member now,
* so we can simply compare the member's .PREFIX and .TARGET variables
@@ -1708,7 +1702,7 @@ SuffFindArchiveDeps(gn, slst)
(void)Lst_AtEnd(mem->parents, (ClientData)gn);
gn->unmade += 1;
}
-
+
/*
* Copy in the variables from the member node to this one.
*/
@@ -1821,7 +1815,7 @@ SuffFindNormalDeps(gn, slst)
eoname = gn->name + strlen(gn->name);
sopref = gn->name;
-
+
/*
* Begin at the beginning...
*/
@@ -1847,8 +1841,7 @@ SuffFindNormalDeps(gn, slst)
* children, then look for any overriding transformations they imply.
* Should we find one, we discard the one we found before.
*/
-
- while (ln != NILLNODE) {
+ while(ln != NILLNODE) {
/*
* Look for next possible suffix...
*/
@@ -1857,12 +1850,12 @@ SuffFindNormalDeps(gn, slst)
if (ln != NILLNODE) {
int prefLen; /* Length of the prefix */
Src *targ;
-
+
/*
* Allocate a Src structure to which things can be transformed
*/
targ = (Src *)emalloc(sizeof (Src));
- targ->file = estrdup(gn->name);
+ targ->file = strdup(gn->name);
targ->suff = (Suff *)Lst_Datum(ln);
targ->suff->refCount++;
targ->node = gn;
@@ -1871,7 +1864,7 @@ SuffFindNormalDeps(gn, slst)
#ifdef DEBUG_SRC
targ->cp = Lst_Init(FALSE);
#endif
-
+
/*
* Allocate room for the prefix, whose end is found by subtracting
* the length of the suffix from the end of the name.
@@ -1903,17 +1896,17 @@ SuffFindNormalDeps(gn, slst)
*/
if (Lst_IsEmpty(targs) && suffNull != NULL) {
if (DEBUG(SUFF)) {
- printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
+ printf("\tNo known suffix on %s. Using .NULL suffix: ", gn->name);
}
-
+
targ = (Src *)emalloc(sizeof (Src));
- targ->file = estrdup(gn->name);
+ targ->file = strdup(gn->name);
targ->suff = suffNull;
targ->suff->refCount++;
targ->node = gn;
targ->parent = (Src *)NULL;
targ->children = 0;
- targ->pref = estrdup(sopref);
+ targ->pref = strdup(sopref);
#ifdef DEBUG_SRC
targ->cp = Lst_Init(FALSE);
#endif
@@ -1925,16 +1918,16 @@ SuffFindNormalDeps(gn, slst)
if (Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children))
SuffAddLevel(srcs, targ);
else {
- if (DEBUG(SUFF))
+ if (DEBUG(SUFF))
printf("not ");
}
- if (DEBUG(SUFF))
+ if (DEBUG(SUFF))
printf("adding suffix rules\n");
(void)Lst_AtEnd(targs, (ClientData)targ);
}
-
+
/*
* Using the list of possible sources built up from the target suffix(es),
* try and find an existing file/target that matches.
@@ -1976,7 +1969,7 @@ SuffFindNormalDeps(gn, slst)
* that still contain variables or wildcards in their names.
*/
Lst_ForEach(gn->children, SuffExpandChildren, (ClientData)gn);
-
+
if (targ == NULL) {
if (DEBUG(SUFF)) {
printf("\tNo valid suffix on %s\n", gn->name);
@@ -1995,7 +1988,6 @@ sfnd_abort:
(targ == NULL ? dirSearchPath :
targ->suff->searchPath));
if (gn->path != NULL) {
- char *ptr;
Var_Set(TARGET, gn->path, gn);
if (targ != NULL) {
@@ -2003,7 +1995,7 @@ sfnd_abort:
* Suffix known for the thing -- trim the suffix off
* the path to form the proper .PREFIX variable.
*/
- int savep = strlen(gn->path) - targ->suff->nameLen;
+ int len = strlen(gn->path);
char savec;
if (gn->suffix)
@@ -2011,17 +2003,12 @@ sfnd_abort:
gn->suffix = targ->suff;
gn->suffix->refCount++;
- savec = gn->path[savep];
- gn->path[savep] = '\0';
+ savec = gn->path[len-targ->suff->nameLen];
+ gn->path[len-targ->suff->nameLen] = '\0';
- if ((ptr = strrchr(gn->path, '/')) != NULL)
- ptr++;
- else
- ptr = gn->path;
+ Var_Set(PREFIX, gn->path, gn);
- Var_Set(PREFIX, ptr, gn);
-
- gn->path[savep] = savec;
+ gn->path[len-targ->suff->nameLen] = savec;
} else {
/*
* The .PREFIX gets the full path if the target has
@@ -2031,12 +2018,7 @@ sfnd_abort:
gn->suffix->refCount--;
gn->suffix = NULL;
- if ((ptr = strrchr(gn->path, '/')) != NULL)
- ptr++;
- else
- ptr = gn->path;
-
- Var_Set(PREFIX, ptr, gn);
+ Var_Set(PREFIX, gn->path, gn);
}
}
} else {
@@ -2052,9 +2034,9 @@ sfnd_abort:
gn->suffix->refCount++;
if (gn->path != NULL)
free(gn->path);
- gn->path = estrdup(gn->name);
+ gn->path = strdup(gn->name);
}
-
+
goto sfnd_return;
}
@@ -2104,12 +2086,12 @@ sfnd_abort:
* suffix. Note that this causes the commands list of the original
* node, gn, to be replaced by the commands of the final
* transformation rule. Also, the unmade field of gn is incremented.
- * Etc.
+ * Etc.
*/
if (bottom->node == NILGNODE) {
bottom->node = Targ_FindNode(bottom->file, TARG_CREATE);
}
-
+
for (src = bottom; src->parent != (Src *)NULL; src = src->parent) {
targ = src->parent;
@@ -2138,7 +2120,7 @@ sfnd_abort:
targ->node->type |= OP_DEPS_FOUND;
Var_Set(PREFIX, targ->pref, targ->node);
-
+
Var_Set(TARGET, targ->node->name, targ->node);
}
}
@@ -2153,7 +2135,7 @@ sfnd_abort:
*/
if (gn->path)
free(gn->path);
- gn->path = estrdup(gn->name);
+ gn->path = strdup(gn->name);
/*
* Nuke the transformation path and the Src structures left over in the
@@ -2170,8 +2152,8 @@ sfnd_return:
Lst_Concat(slst, srcs, LST_CONCLINK);
Lst_Concat(slst, targs, LST_CONCLINK);
}
-
-
+
+
/*-
*-----------------------------------------------------------------------
* Suff_FindDeps --
@@ -2204,7 +2186,7 @@ void
Suff_FindDeps(gn)
GNode *gn;
{
-
+
SuffFindDeps(gn, srclist);
while (SuffRemoveSrc(srclist))
continue;
@@ -2224,11 +2206,11 @@ SuffFindDeps (gn, slst)
} else {
gn->type |= OP_DEPS_FOUND;
}
-
+
if (DEBUG(SUFF)) {
printf ("SuffFindDeps (%s)\n", gn->name);
}
-
+
if (gn->type & OP_ARCHV) {
SuffFindArchiveDeps(gn, slst);
} else if (gn->type & OP_LIB) {
@@ -2242,7 +2224,7 @@ SuffFindDeps (gn, slst)
*/
LstNode ln;
Suff *s;
-
+
ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP);
if (gn->suffix)
gn->suffix->refCount--;
@@ -2334,7 +2316,7 @@ Suff_Init ()
*/
emptySuff = suffNull = (Suff *) emalloc (sizeof (Suff));
- suffNull->name = estrdup ("");
+ suffNull->name = strdup ("");
suffNull->nameLen = 0;
suffNull->searchPath = Lst_Init (FALSE);
Dir_Concat(suffNull->searchPath, dirSearchPath);
@@ -2393,7 +2375,7 @@ SuffPrintSuff (sp, dummy)
int flag;
printf ("# `%s' [%d] ", s->name, s->refCount);
-
+
flags = s->flags;
if (flags) {
fputs (" (", stdout);
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index 0fe96509f9fe..49aedbd5d218 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -1,5 +1,3 @@
-/* $NetBSD: targ.c,v 1.9 1996/08/30 17:59:43 thorpej Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
-#else
-static char *rcsid = "$NetBSD: targ.c,v 1.9 1996/08/30 17:59:43 thorpej Exp $";
-#endif
+static char sccsid[] = "@(#)targ.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -164,7 +158,7 @@ Targ_NewGN (name)
register GNode *gn;
gn = (GNode *) emalloc (sizeof (GNode));
- gn->name = estrdup (name);
+ gn->name = strdup (name);
gn->path = (char *) 0;
if (name[0] == '-' && name[1] == 'l') {
gn->type = OP_LIB;
@@ -175,7 +169,6 @@ Targ_NewGN (name)
gn->make = FALSE;
gn->made = UNMADE;
gn->childMade = FALSE;
- gn->order = 0;
gn->mtime = gn->cmtime = 0;
gn->iParents = Lst_Init (FALSE);
gn->cohorts = Lst_Init (FALSE);
@@ -276,11 +269,11 @@ Targ_FindNode (name, flags)
/*-
*-----------------------------------------------------------------------
* Targ_FindList --
- * Make a complete list of GNodes from the given list of names
+ * Make a complete list of GNodes from the given list of names
*
* Results:
* A complete list of graph nodes corresponding to all instances of all
- * the names in names.
+ * the names in names.
*
* Side Effects:
* If flags is TARG_CREATE, nodes will be created for all names in
@@ -397,7 +390,7 @@ Targ_Precious (gn)
/******************* DEBUG INFO PRINTING ****************/
static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
-/*-
+/*-
*-----------------------------------------------------------------------
* Targ_SetMain --
* Set our idea of the main target we'll be creating. Used for
@@ -474,12 +467,12 @@ Targ_FmtTime (time)
parts = localtime(&time);
- sprintf (buf, "%d:%02d:%02d %s %d, %d",
+ sprintf (buf, "%d:%02d:%02d %s %d, 19%d",
parts->tm_hour, parts->tm_min, parts->tm_sec,
- months[parts->tm_mon], parts->tm_mday, 1900 + parts->tm_year);
+ months[parts->tm_mon], parts->tm_mday, parts->tm_year);
return(buf);
}
-
+
/*-
*-----------------------------------------------------------------------
* Targ_PrintType --
@@ -497,7 +490,7 @@ Targ_PrintType (type)
register int type;
{
register int tbit;
-
+
#ifdef __STDC__
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
@@ -584,7 +577,7 @@ TargPrintNode (gnp, passp)
Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
fputc ('\n', stdout);
}
-
+
printf("%-16s", gn->name);
switch (gn->type & OP_OPMASK) {
case OP_DEPENDS:
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index bc57634f1ac8..4d7b2e956878 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,5 +1,3 @@
-/* $NetBSD: var.c,v 1.14 1996/08/13 16:42:25 christos Exp $ */
-
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,11 +37,7 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
-#else
-static char rcsid[] = "$NetBSD: var.c,v 1.14 1996/08/13 16:42:25 christos Exp $";
-#endif
+static char sccsid[] = "@(#)var.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@@ -153,6 +147,7 @@ typedef struct {
#define VAR_SUB_GLOBAL 1 /* Apply substitution globally */
#define VAR_MATCH_START 2 /* Match at start of word */
#define VAR_MATCH_END 4 /* Match at end of word */
+#define VAR_NO_SUB 8 /* Substitution is non-global and already done */
} VarPattern;
static int VarCmp __P((ClientData, ClientData));
@@ -164,9 +159,7 @@ static Boolean VarTail __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
-#ifdef SYSVVARSUB
static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData));
-#endif
static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
@@ -278,15 +271,15 @@ VarFind (name, ctxt, flags)
if ((env = getenv (name)) != NULL) {
int len;
-
+
v = (Var *) emalloc(sizeof(Var));
- v->name = estrdup(name);
+ v->name = strdup(name);
len = strlen(env);
-
+
v->val = Buf_Init(len);
Buf_AddBytes(v->val, len, (Byte *)env);
-
+
v->flags = VAR_FROM_ENV;
return (v);
} else if (checkEnvFirst && (flags & FIND_GLOBAL) &&
@@ -333,7 +326,7 @@ VarAdd (name, val, ctxt)
v = (Var *) emalloc (sizeof (Var));
- v->name = estrdup (name);
+ v->name = strdup (name);
len = val ? strlen(val) : 0;
v->val = Buf_Init(len+1);
@@ -754,7 +747,7 @@ VarRoot (word, addSpace, buf, dummy)
* VarMatch --
* Place the word in the buffer if it matches the given pattern.
* Callback function for VarModify to implement the :M modifier.
- *
+ *
* Results:
* TRUE if a space should be placed in the buffer before the next
* word.
@@ -783,14 +776,15 @@ VarMatch (word, addSpace, buf, pattern)
return(addSpace);
}
-#ifdef SYSVVARSUB
+
+
/*-
*-----------------------------------------------------------------------
* VarSYSVMatch --
* Place the word in the buffer if it matches the given pattern.
* Callback function for VarModify to implement the System V %
* modifiers.
- *
+ *
* Results:
* TRUE if a space should be placed in the buffer before the next
* word.
@@ -825,7 +819,6 @@ VarSYSVMatch (word, addSpace, buf, patp)
return(addSpace);
}
-#endif
/*-
@@ -833,7 +826,7 @@ VarSYSVMatch (word, addSpace, buf, patp)
* VarNoMatch --
* Place the word in the buffer if it doesn't match the given pattern.
* Callback function for VarModify to implement the :N modifier.
- *
+ *
* Results:
* TRUE if a space should be placed in the buffer before the next
* word.
@@ -890,9 +883,9 @@ VarSubstitute (word, addSpace, buf, patternp)
VarPattern *pattern = (VarPattern *) patternp;
wordLen = strlen(word);
- if (1) { /* substitute in each word of the variable */
+ if ((pattern->flags & VAR_NO_SUB) == 0) {
/*
- * Break substitution down into simple anchored cases
+ * Still substituting -- break it down into simple anchored cases
* and if none of them fits, perform the general substitution case.
*/
if ((pattern->flags & VAR_MATCH_START) &&
@@ -974,7 +967,7 @@ VarSubstitute (word, addSpace, buf, patternp)
* Pattern is unanchored: search for the pattern in the word using
* String_FindSubstring, copying unmatched portions and the
* right-hand-side for each match found, handling non-global
- * substitutions correctly, etc. When the loop is done, any
+ * subsititutions correctly, etc. When the loop is done, any
* remaining part of the word (word and wordLen are adjusted
* accordingly through the loop) is copied straight into the
* buffer.
@@ -997,8 +990,12 @@ VarSubstitute (word, addSpace, buf, patternp)
Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);
wordLen -= (cp - word) + pattern->leftLen;
word = cp + pattern->leftLen;
- if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0){
+ if (wordLen == 0) {
+ done = TRUE;
+ }
+ if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
done = TRUE;
+ pattern->flags |= VAR_NO_SUB;
}
} else {
done = TRUE;
@@ -1018,9 +1015,14 @@ VarSubstitute (word, addSpace, buf, patternp)
return ((Buf_Size(buf) != origSize) || addSpace);
}
/*
- * Common code for anchored substitutions:
- * addSpace was set TRUE if characters were added to the buffer.
+ * Common code for anchored substitutions: if performed a substitution
+ * and it's not supposed to be global, mark the pattern as requiring
+ * no more substitutions. addSpace was set TRUE if characters were
+ * added to the buffer.
*/
+ if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
+ pattern->flags |= VAR_NO_SUB;
+ }
return (addSpace);
}
nosub:
@@ -1066,7 +1068,7 @@ VarModify (str, modProc, datum)
for (i = 1; i < ac; i++)
addSpace = (*modProc)(av[i], addSpace, buf, datum);
-
+
Buf_AddByte (buf, '\0');
str = (char *)Buf_GetAll (buf, (int *)NULL);
Buf_Destroy (buf, FALSE);
@@ -1108,7 +1110,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
Boolean haveModifier;/* TRUE if have modifiers for the variable */
register char endc; /* Ending character when variable in parens
* or braces */
- register char startc=0; /* Starting character when variable in parens
+ register char startc; /* Starting character when variable in parens
* or braces */
int cnt; /* Used to count brace pairs when variable in
* in parens or braces */
@@ -1117,11 +1119,11 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* expanding it in a non-local context. This
* is done to support dynamic sources. The
* result is just the invocation, unaltered */
-
+
*freePtr = FALSE;
dynamic = FALSE;
start = str;
-
+
if (str[1] != '(' && str[1] != '{') {
/*
* If it's not bounded by braces of some sort, life is much simpler.
@@ -1136,7 +1138,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
if (v == (Var *)NIL) {
*lengthPtr = 2;
-
+
if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
/*
* If substituting a local variable in a non-local context,
@@ -1194,7 +1196,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
return (var_Error);
}
*tstr = '\0';
-
+
v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D'))
@@ -1220,7 +1222,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
vname[0] = str[2];
vname[1] = '\0';
v = VarFind(vname, ctxt, 0);
-
+
if (v != (Var *)NIL) {
/*
* No need for nested expansion or anything, as we're
@@ -1228,7 +1230,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* but nested invocations in them...
*/
val = (char *)Buf_GetAll(v->val, (int *)NULL);
-
+
if (str[3] == 'D') {
val = VarModify(val, VarHead, (ClientData)0);
} else {
@@ -1247,7 +1249,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
}
}
-
+
if (v == (Var *)NIL) {
if ((((tstr-str) == 3) ||
((((tstr-str) == 4) && (str[3] == 'F' ||
@@ -1276,7 +1278,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
{
int len;
-
+
len = (tstr-str) - 3;
if ((strncmp(str+2, ".TARGET", len) == 0) ||
(strncmp(str+2, ".ARCHIVE", len) == 0) ||
@@ -1286,7 +1288,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
dynamic = TRUE;
}
}
-
+
if (!haveModifier) {
/*
* No modifiers -- have specification length so we can return
@@ -1336,9 +1338,9 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
str = Var_Subst(NULL, str, ctxt, err);
*freePtr = TRUE;
}
-
+
v->flags &= ~VAR_IN_USE;
-
+
/*
* Now we need to apply any modifiers the user wants applied.
* These are:
@@ -1364,7 +1366,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
while (*tstr != endc) {
char *newStr; /* New value to return */
char termc; /* Character which terminated scan */
-
+
if (DEBUG(VAR)) {
printf("Applying :%c to \"%s\"\n", *tstr, str);
}
@@ -1441,7 +1443,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
buf = Buf_Init(0);
-
+
/*
* Pass through the lhs looking for 1) escaped delimiters,
* '$'s and backslashes (place the escaped character in
@@ -1467,7 +1469,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
char *cp2;
int len;
Boolean freeIt;
-
+
cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
if (freeIt) {
@@ -1487,7 +1489,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
Buf_AddByte(buf, (Byte)'\0');
-
+
/*
* If lhs didn't end with the delimiter, complain and
* return NULL
@@ -1522,7 +1524,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* it right here) and 3) expand any variable substitutions.
*/
buf = Buf_Init(0);
-
+
tstr = cp + 1;
for (cp = tstr; *cp != '\0' && *cp != delim; cp++) {
if ((*cp == '\\') &&
@@ -1553,7 +1555,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
Buf_AddByte(buf, (Byte)'\0');
-
+
/*
* If didn't end in delimiter character, complain
*/
@@ -1625,29 +1627,14 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
break;
}
/*FALLTHRU*/
-#ifdef SUNSHCMD
- case 's':
- if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
- char *err;
- newStr = Cmd_Exec (str, &err);
- if (err)
- Error (err, str);
- cp = tstr + 2;
- termc = *cp;
- break;
- }
- /*FALLTHRU*/
-#endif
- default:
- {
-#ifdef SYSVVARSUB
+ default: {
/*
* This can either be a bogus modifier or a System-V
* substitution command.
*/
VarPattern pattern;
Boolean eqFound;
-
+
pattern.flags = 0;
eqFound = FALSE;
/*
@@ -1670,7 +1657,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
cp++;
}
if (*cp == endc && eqFound) {
-
+
/*
* Now we break this sucker into the lhs and
* rhs. We must null terminate them of course.
@@ -1680,7 +1667,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
pattern.lhs = tstr;
pattern.leftLen = cp - tstr;
*cp++ = '\0';
-
+
pattern.rhs = cp;
cnt = 1;
while (cnt) {
@@ -1693,7 +1680,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
pattern.rightLen = cp - pattern.rhs;
*cp = '\0';
-
+
/*
* SYSV modifications happen through the whole
* string. Note the pattern is anchored at the end.
@@ -1707,13 +1694,11 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
pattern.lhs[pattern.leftLen] = '=';
pattern.rhs[pattern.rightLen] = endc;
termc = endc;
- } else
-#endif
- {
+ } else {
Error ("Unknown modifier '%c'\n", *tstr);
for (cp = tstr+1;
*cp != ':' && *cp != endc && *cp != '\0';
- cp++)
+ cp++)
continue;
termc = *cp;
newStr = var_Error;
@@ -1723,7 +1708,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
if (DEBUG(VAR)) {
printf("Result is \"%s\"\n", newStr);
}
-
+
if (*freePtr) {
free (str);
}
@@ -1747,10 +1732,10 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
*lengthPtr = tstr - start + 1;
*tstr = endc;
}
-
+
if (v->flags & VAR_FROM_ENV) {
Boolean destroy = FALSE;
-
+
if (str != (char *)Buf_GetAll(v->val, (int *)NULL)) {
destroy = TRUE;
} else {
@@ -1857,9 +1842,9 @@ Var_Subst (var, str, ctxt, undefErr)
/*
* Scan up to the end of the variable name.
*/
- for (p = &str[2]; *p &&
+ for (p = &str[2]; *p &&
*p != ':' && *p != ')' && *p != '}'; p++)
- if (*p == '$')
+ if (*p == '$')
break;
/*
* A variable inside the variable. We cannot expand
@@ -1871,14 +1856,14 @@ Var_Subst (var, str, ctxt, undefErr)
str = p;
continue;
}
-
- if (strncmp(var, str + 2, p - str - 2) != 0 ||
+
+ if (strncmp(var, str + 2, p - str - 2) != 0 ||
var[p - str - 2] != '\0') {
/*
* Not the variable we want to expand, scan
* until the next variable
*/
- for (;*p != '$' && *p != '\0'; p++)
+ for (;*p != '$' && *p != '\0'; p++)
continue;
Buf_AddBytes(buf, p - str, (Byte *) str);
str = p;
@@ -1892,7 +1877,7 @@ Var_Subst (var, str, ctxt, undefErr)
if (!expand)
continue;
}
-
+
val = Var_Parse (str, ctxt, undefErr, &length, &doFree);
/*
@@ -1932,7 +1917,7 @@ Var_Subst (var, str, ctxt, undefErr)
* advance the string pointer.
*/
str += length;
-
+
/*
* Copy all the characters from the variable value straight
* into the new string.
@@ -1944,7 +1929,7 @@ Var_Subst (var, str, ctxt, undefErr)
}
}
}
-
+
Buf_AddByte (buf, '\0');
str = (char *)Buf_GetAll (buf, (int *)NULL);
Buf_Destroy (buf, FALSE);
@@ -2003,7 +1988,7 @@ Var_GetHead(file)
* None
*
* Side Effects:
- * The VAR_CMD and VAR_GLOBAL contexts are created
+ * The VAR_CMD and VAR_GLOBAL contexts are created
*-----------------------------------------------------------------------
*/
void
@@ -2021,7 +2006,7 @@ Var_End ()
{
Lst_Destroy(allVars, VarDelete);
}
-
+
/****************** PRINT DEBUGGING INFO *****************/
static int