- Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
be considered to be out of date, since it does not have a TOC.
- Fix NetBSD PR #2930: declare missing variable.
-# $OpenBSD: Makefile,v 1.4 1996/09/02 16:04:06 briggs Exp $
-# $NetBSD: Makefile,v 1.11 1996/05/28 23:34:35 christos Exp $
+# $OpenBSD: Makefile,v 1.5 1996/11/30 21:08:48 millert Exp $
+# $NetBSD: Makefile,v 1.12 1996/11/06 17:58:58 christos Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
PROG= make
-CFLAGS+= -I${.CURDIR} -Wall -Wno-unused
+CFLAGS+= -I${.CURDIR} -Wall -Wno-unused #-Wmissing-prototypes -Wstrict-prototypes
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
SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
-# $OpenBSD: Makefile.boot,v 1.2 1996/06/26 05:36:24 deraadt Exp $
-# $NetBSD: Makefile.boot,v 1.5 1995/06/14 15:18:43 christos Exp $
+# $OpenBSD: Makefile.boot,v 1.3 1996/11/30 21:08:48 millert Exp $
+# $NetBSD: Makefile.boot,v 1.7 1996/08/30 17:59:37 thorpej Exp $
+#
# a very simple makefile...
#
-# You only want to use this if you aren't running NetBSD.
+# You only want to use this if you aren't running OpenBSD.
#
# modify MACHINE and MACHINE_ARCH as appropriate for your target architecture
#
-CFLAGS= -I. -DMACHINE=\"sparc\" -DMACHINE_ARCH=\"sparc\" \
+MACHINE=sun
+MACHINE_ARCH=sparc
+CFLAGS= -I. -DMACHINE=\"${MACHINE}\" -DMACHINE_ARCH=\"${MACHINE_ARCH}\" \
-DMAKE_BOOTSTRAP
+LIBS=
OBJ=arch.o buf.o compat.o cond.o dir.o for.o hash.o job.o main.o make.o \
parse.o str.o suff.o targ.o var.o util.o
-bmake: ${OBJ}
- @echo 'make of make and make.0 started.'
- (cd lst.lib; make)
- ${CC} *.o lst.lib/*.o -o bmake
+LIBOBJ= lst.lib/lstAppend.o lst.lib/lstAtEnd.o lst.lib/lstAtFront.o \
+ lst.lib/lstClose.o lst.lib/lstConcat.o lst.lib/lstDatum.o \
+ lst.lib/lstDeQueue.o lst.lib/lstDestroy.o lst.lib/lstDupl.o \
+ lst.lib/lstEnQueue.o lst.lib/lstFind.o lst.lib/lstFindFrom.o \
+ lst.lib/lstFirst.o lst.lib/lstForEach.o lst.lib/lstForEachFrom.o \
+ lst.lib/lstInit.o lst.lib/lstInsert.o lst.lib/lstIsAtEnd.o \
+ lst.lib/lstIsEmpty.o lst.lib/lstLast.o lst.lib/lstMember.o \
+ lst.lib/lstNext.o lst.lib/lstOpen.o lst.lib/lstRemove.o \
+ lst.lib/lstReplace.o lst.lib/lstSucc.o
+
+bmake: ${OBJ} ${LIBOBJ}
+# @echo 'make of make and make.0 started.'
+ ${CC} ${CFLAGS} ${OBJ} ${LIBOBJ} -o bmake ${LIBS}
+ @ls -l $@
# nroff -h -man make.1 > make.0
# @echo 'make of make and make.0 completed.'
+
+clean:
+ rm -f ${OBJ} ${LIBOBJ} ${PORTOBJ} bmake
-/* $OpenBSD: arch.c,v 1.8 1996/10/17 19:08:44 niklas Exp $ */
-/* $NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $ */
+/* $OpenBSD: arch.c,v 1.9 1996/11/30 21:08:49 millert Exp $ */
+/* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 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.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)arch.c 5.7 (Berkeley) 12/28/90";
-static char rcsid[] = "$NetBSD: arch.c,v 1.14 1996/03/12 18:04:27 christos Exp $";
+static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: arch.c,v 1.8 1996/10/17 19:08:44 niklas Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.9 1996/11/30 21:08:49 millert Exp $";
#endif
#endif /* not lint */
#include <utime.h>
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
#include "make.h"
#include "hash.h"
#include "dir.h"
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))
Hash_DeleteTable(&a->members);
free((Address) a);
}
-
+
/*-
* variable substitution performed on it */
libName = *linePtr;
-
+
subLibName = FALSE;
for (cp = libName; *cp != '(' && *cp != '\0'; cp++) {
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);
}
if (subLibName) {
libName = Var_Subst(NULL, libName, ctxt, TRUE);
}
-
+
for (;;) {
/*
char *buf;
char *sacrifice;
char *oldMemName = memName;
-
+
memName = Var_Subst(NULL, memName, ctxt, TRUE);
/*
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);
if (doSubst) {
free(memName);
}
-
+
*cp = saveChar;
}
if (arch == (FILE *) NULL) {
return ((struct ar_hdr *) NULL);
}
-
+
/*
* We use the ARMAG string to make sure this is an archive we
* can handle...
ar->fnamesize = 0;
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) {
/*
if (arch == (FILE *) NULL) {
return ((FILE *) NULL);
}
-
+
/*
* We use the ARMAG string to make sure this is an archive we
* can handle...
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) {
/*
/*-
*-----------------------------------------------------------------------
* Arch_FindLib --
- * Search for a library along the given search path.
+ * Search for a library along the given search path.
*
* Results:
* None.
* 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.
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) || !gn->mtime) {
{
Lst_Destroy(archives, ArchFree);
}
+
+/*-
+ *-----------------------------------------------------------------------
+ * Arch_IsLib --
+ * Check if the node is a library
+ *
+ * Results:
+ * True or False.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+int
+Arch_IsLib(gn)
+ GNode *gn;
+{
+ static const char armag[] = "!<arch>\n";
+ char buf[sizeof(armag)-1];
+ int fd;
+
+ if ((fd = open(gn->path, O_RDONLY)) == -1)
+ return FALSE;
+
+ if (read(fd, buf, sizeof(buf)) != sizeof(buf)) {
+ (void) close(fd);
+ return FALSE;
+ }
+
+ (void) close(fd);
+
+ return memcmp(buf, armag, sizeof(buf)) == 0;
+}
-/* $OpenBSD: bit.h,v 1.3 1996/06/26 05:36:25 deraadt Exp $ */
+/* $OpenBSD: bit.h,v 1.4 1996/11/30 21:08:50 millert Exp $ */
/* $NetBSD: bit.h,v 1.5 1995/11/08 02:30:53 christos Exp $ */
/*
extern Boolean Bit_Union();
extern Boolean Bit_AnySet();
extern int *Bit_Expand();
-
+
#endif /* _BIT */
-/* $OpenBSD: buf.c,v 1.3 1996/06/26 05:36:25 deraadt Exp $ */
-/* $NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $ */
+/* $OpenBSD: buf.c,v 1.4 1996/11/30 21:08:50 millert Exp $ */
+/* $NetBSD: buf.c,v 1.8 1996/11/06 17:59:00 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)buf.c 5.5 (Berkeley) 12/28/90";
+static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: buf.c,v 1.3 1996/06/26 05:36:25 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: buf.c,v 1.4 1996/11/30 21:08:50 millert Exp $";
#endif
#endif /* not lint */
Buf_AddBytes (bp, numBytes, bytesPtr)
register Buffer bp;
int numBytes;
- Byte *bytesPtr;
+ const Byte *bytesPtr;
{
BufExpand (bp, numBytes);
int numBytes;
Byte *bytesPtr;
{
-
+
if (bp->inPtr - bp->outPtr < numBytes) {
numBytes = bp->inPtr - bp->outPtr;
}
if (numBytesPtr != (int *)NULL) {
*numBytesPtr = bp->inPtr - bp->outPtr;
}
-
+
return (bp->outPtr);
}
\f
* None.
*
* Side Effects:
- * The bytes are discarded.
+ * The bytes are discarded.
*
*-----------------------------------------------------------------------
*/
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);
}
+\f
+/*-
+ *-----------------------------------------------------------------------
+ * 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;
+}
-/* $OpenBSD: buf.h,v 1.2 1996/06/26 05:36:26 deraadt Exp $ */
-/* $NetBSD: buf.h,v 1.5 1995/06/14 15:18:53 christos Exp $ */
+/* $OpenBSD: buf.h,v 1.3 1996/11/30 21:08:51 millert Exp $ */
+/* $NetBSD: buf.h,v 1.6 1996/11/06 17:59:00 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)buf.h 5.4 (Berkeley) 12/28/90
+ * from: @(#)buf.h 8.1 (Berkeley) 6/6/93
*/
/*-
#define BUF_ERROR 256
void Buf_OvAddByte __P((Buffer, int));
-void Buf_AddBytes __P((Buffer, int, Byte *));
+void Buf_AddBytes __P((Buffer, int, const Byte *));
void Buf_UngetByte __P((Buffer, int));
void Buf_UngetBytes __P((Buffer, int, Byte *));
int Buf_GetByte __P((Buffer));
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 */
-/* $OpenBSD: compat.c,v 1.3 1996/06/26 05:36:27 deraadt Exp $ */
-/* $NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $ */
+/* $OpenBSD: compat.c,v 1.4 1996/11/30 21:08:51 millert Exp $ */
+/* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)compat.c 5.7 (Berkeley) 3/1/91";
+static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: compat.c,v 1.3 1996/06/26 05:36:27 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: compat.c,v 1.4 1996/11/30 21:08:51 millert Exp $";
#endif
#endif /* not lint */
int signo;
{
GNode *gn;
-
+
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
char *p1;
char *file = Var_Value (TARGET, curTarg, &p1);
char *cmd = (char *) cmdp;
GNode *gn = (GNode *) gnp;
- /*
+ /*
* Avoid clobbered variable warnings by forcing the compiler
* to ``unregister'' variables
*/
* 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);
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
if (noExecute) {
return (0);
}
-
+
if (*cp != '\0') {
/*
* If *cp isn't the null character, we hit a "meta" character and
av = brk_string(cmd, &argc, TRUE);
av += 1;
}
-
+
local = TRUE;
/*
}
free(cmdStart);
Lst_Replace (cmdNode, (ClientData) NULL);
-
+
/*
* The child is off and running. Now all we can do is wait...
*/
break;
}
}
-
+
if (stat > -1) {
if (WIFSTOPPED(reason)) {
status = WSTOPSIG(reason); /* stopped */
} else {
status = WTERMSIG(reason); /* signaled */
printf ("*** Signal %d", status);
- }
+ }
+
-
if (!WIFEXITED(reason) || (status != 0)) {
if (errCheck) {
gn->made = ERROR;
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
* 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.
return (0);
}
-\f
+\f
/*-
*-----------------------------------------------------------------------
* Compat_Run --
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);
+ }
}
}
-/* $OpenBSD: cond.c,v 1.2 1996/06/26 05:36:28 deraadt Exp $ */
-/* $NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $ */
+/* $OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $ */
+/* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)cond.c 5.6 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: cond.c,v 1.2 1996/06/26 05:36:28 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $";
#endif
#endif /* not lint */
* 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));
char *form; /* Form of if */
int formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
- Boolean (*defProc)(); /* Default function to apply */
+ Boolean (*defProc) __P((int, char *)); /* 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 },
- { (char *)0, 0, FALSE, (Boolean (*)())0 }
+ { NULL, 0, FALSE, NULL }
};
static Boolean condInvert; /* Invert the default function */
-static Boolean (*condDefProc)(); /* Default function to apply */
+static Boolean (*condDefProc) /* Default function to apply */
+ __P((int, char *));
static char *condExpr; /* The expression to parse */
static Token condPushBack=None; /* Single push-back token used in
* parsing */
* long. Why 16? Why not?
*/
buf = Buf_Init(16);
-
+
while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) {
if (*cp == '$') {
/*
*/
cp++;
}
-
+
*linePtr = cp;
return (argLen);
}
*
* Side Effects:
* Can change 'value' even if string is not a valid number.
- *
+ *
*
*-----------------------------------------------------------------------
*/
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')) {
/*
} 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);
if (*rhs == '$') {
int len;
Boolean freeIt;
-
+
string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt);
if (string == var_Error) {
right = 0.0;
}
}
}
-
+
if (DEBUG(COND)) {
printf("left = %f, right = %f, op = %.2s\n", left,
right, op);
break;
}
default: {
- Boolean (*evalProc)();
+ Boolean (*evalProc) __P((int, char *));
Boolean invert = FALSE;
char *arg;
int arglen;
-
+
if (strncmp (condExpr, "defined", 7) == 0) {
/*
* Use CondDoDefined to evaluate the argument and
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;
} 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"
*/
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) {
-/* $OpenBSD: config.h,v 1.6 1996/09/21 19:36:27 niklas Exp $ */
-/* $NetBSD: config.h,v 1.6 1996/05/28 23:34:39 christos Exp $ */
+/* $OpenBSD: config.h,v 1.7 1996/11/30 21:08:53 millert Exp $ */
+/* $NetBSD: config.h,v 1.7 1996/11/06 17:59:03 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)config.h 5.9 (Berkeley) 6/1/90
+ * from: @(#)config.h 8.1 (Berkeley) 6/6/93
*/
#define DEFSHELL 1 /* Bourne shell */
#define POSIX
/*
- * SYSVINCLUDES
+ * SYSVINCLUDE
* Recognize system V like include directives [include "filename"]
* SYSVVARSUB
* Recognize system V like ${VAR:x=y} variable substitutions
*/
-#define SYSVINCLUDES
+#define SYSVINCLUDE
#define SYSVVARSUB
/*
# define RANLIBMAG "__.SYMDEF"
# endif
#endif
-/*#define POSIX*/
-/* $OpenBSD: dir.c,v 1.5 1996/09/02 16:04:09 briggs Exp $ */
-/* $NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $ */
+/* $OpenBSD: dir.c,v 1.6 1996/11/30 21:08:53 millert Exp $ */
+/* $NetBSD: dir.c,v 1.12 1996/11/06 17:59:04 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)dir.c 5.6 (Berkeley) 12/28/90";
+static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: dir.c,v 1.5 1996/09/02 16:04:09 briggs Exp $";
+static char rcsid[] = "$OpenBSD: dir.c,v 1.6 1996/11/30 21:08:53 millert Exp $";
#endif
#endif /* not lint */
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),
char *name; /* name to check */
{
register char *cp;
-
+
for (cp = name; *cp; cp++) {
switch(*cp) {
case '{':
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))
if (DEBUG(DIR)) {
printf("expanding \"%s\"...", word);
}
-
+
cp = strchr(word, '{');
if (cp) {
DirExpandCurly(word, cp, path, expansions);
* First the files in dot
*/
DirMatchFiles(word, dot, expansions);
-
+
/*
* Then the files in every other directory on the 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)
hasSlash = FALSE;
cp = name;
}
-
+
if (DEBUG(DIR)) {
printf("Searching for %s...", name);
}
dot->hits += 1;
return (estrdup (name));
}
-
+
if (Lst_Open (path) == FAILURE) {
if (DEBUG(DIR)) {
printf("couldn't open path, file not found\n");
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
}
}
}
-
+
/*
* 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.
misses += 1;
return ((char *) NULL);
}
-
+
if (*name != '/') {
Boolean checkedDot = FALSE;
-
+
if (DEBUG(DIR)) {
printf("failed. Trying subdirectories...");
}
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
*cp = '\0';
Dir_AddDir (path, file);
*cp = '/';
-
+
/*
* Save the modification time so if it's needed, we don't have
* to fetch it again.
free (file);
}
}
-
+
if (DEBUG(DIR)) {
printf("failed. ");
}
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
cp[-1] = '\0';
Dir_AddDir (path, name);
cp[-1] = '/';
-
+
bigmisses += 1;
ln = Lst_Last (path);
if (ln == NILLNODE) {
} else {
p = (Path *) Lst_Datum (ln);
}
-
+
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
return (estrdup (name));
} else {
if (DEBUG(DIR)) {
printf("Looking for \"%s\"...", name);
}
-
+
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != (Hash_Entry *)NULL) {
* 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
*
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) {
} else {
fullName = gn->path;
}
-
+
if (fullName == (char *)NULL) {
fullName = estrdup(gn->name);
}
if (fullName && gn->path == (char *)NULL) {
gn->path = fullName;
}
-
+
gn->mtime = stb.st_mtime;
return (gn->mtime);
}
* 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.
*-----------------------------------------------------------------------
*/
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);
printf("Caching %s...", name);
fflush(stdout);
}
-
+
if ((d = opendir (name)) != (DIR *) NULL) {
p = (Path *) emalloc (sizeof (Path));
p->name = estrdup (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 */
/*
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 ("");
-
+
if (Lst_Open (path) == SUCCESS) {
while ((ln = Lst_Next (path)) != NILLNODE) {
p = (Path *) Lst_Datum (ln);
}
Lst_Close (path);
}
-
+
return (str);
}
Dir_Destroy((ClientData) p);
}
}
-
+
/*-
*-----------------------------------------------------------------------
{
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,
static int DirPrintDir (p, dummy)
ClientData p;
ClientData dummy;
-{
+{
printf ("%s ", ((Path *) p)->name);
return (dummy ? 0 : 0);
}
-/* $OpenBSD: dir.h,v 1.2 1996/06/26 05:36:30 deraadt Exp $ */
-/* $NetBSD: dir.h,v 1.3 1995/06/14 15:19:11 christos Exp $ */
+/* $OpenBSD: dir.h,v 1.3 1996/11/30 21:08:54 millert Exp $ */
+/* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)dir.h 5.4 (Berkeley) 12/28/90
+ * from: @(#)dir.h 8.1 (Berkeley) 6/6/93
*/
/* dir.h --
-/* $OpenBSD: extern.h,v 1.5 1996/09/02 16:04:16 briggs Exp $ */
-/* $NetBSD: nonints.h,v 1.11 1996/08/13 16:42:11 christos Exp $ */
+/* $OpenBSD: extern.h,v 1.6 1996/11/30 21:09:01 millert Exp $ */
+/* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 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.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)nonints.h 5.6 (Berkeley) 4/18/91
+ * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
*/
/* arch.c */
Boolean Arch_LibOODate __P((GNode *));
void Arch_Init __P((void));
void Arch_End __P((void));
+int Arch_IsLib __P((GNode *));
/* compat.c */
void Compat_Run __P((Lst));
-/* $OpenBSD: for.c,v 1.2 1996/06/26 05:36:30 deraadt Exp $ */
-/* $NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $ */
+/* $OpenBSD: for.c,v 1.3 1996/11/30 21:08:54 millert Exp $ */
+/* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)for.c 5.6 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: for.c,v 1.2 1996/06/26 05:36:30 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: for.c,v 1.3 1996/11/30 21:08:54 millert Exp $";
#endif
#endif /* not lint */
* 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.
*/
!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);
*/
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_AtEnd(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
+ Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
}
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;
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);
-/* $OpenBSD: hash.c,v 1.2 1996/06/26 05:36:31 deraadt Exp $ */
-/* $NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $ */
+/* $OpenBSD: hash.c,v 1.3 1996/11/30 21:08:55 millert Exp $ */
+/* $NetBSD: hash.c,v 1.6 1996/11/06 17:59:06 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)hash.c 5.5 (Berkeley) 12/28/90";
+static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: hash.c,v 1.2 1996/06/26 05:36:31 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: hash.c,v 1.3 1996/11/30 21:08:55 millert Exp $";
#endif
#endif /* not lint */
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.
*/
/*
*---------------------------------------------------------
- *
+ *
* Hash_InitTable --
*
* This routine just sets up the hash table.
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
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;
* and frees up the memory space it occupied (except for
* the space in the Hash_Table structure).
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
/*
* Set up the hash table to cause memory faults on any future access
- * attempts until re-initialization.
+ * attempts until re-initialization.
*/
t->bucketPtr = NULL;
}
/*
* 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);
* 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.
*
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;
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;
* This local routine makes a new hash table that
* is larger than the old one.
*
- * Results:
+ * Results:
* None.
*
* Side Effects:
-/* $OpenBSD: hash.h,v 1.2 1996/06/26 05:36:31 deraadt Exp $ */
-/* $NetBSD: hash.h,v 1.4 1995/06/14 15:19:18 christos Exp $ */
+/* $OpenBSD: hash.h,v 1.3 1996/11/30 21:08:55 millert Exp $ */
+/* $NetBSD: hash.h,v 1.5 1996/11/06 17:59:07 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)hash.h 5.4 (Berkeley) 12/28/90
+ * from: @(#)hash.h 8.1 (Berkeley) 6/6/93
*/
/* hash.h --
#ifndef _HASH
#define _HASH
-/*
+/*
* The following defines one entry in the 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.
*/
*/
/*
- * 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))
-/* $OpenBSD: job.c,v 1.5 1996/09/02 16:04:11 briggs Exp $ */
-/* $NetBSD: job.c,v 1.15 1996/05/29 15:28:05 christos Exp $ */
+/* $OpenBSD: job.c,v 1.6 1996/11/30 21:08:56 millert Exp $ */
+/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)job.c 5.15 (Berkeley) 3/1/91";
+static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: job.c,v 1.5 1996/09/02 16:04:11 briggs Exp $";
+static char rcsid[] = "$OpenBSD: job.c,v 1.6 1996/11/30 21:08:56 millert Exp $";
#endif
#endif /* not lint */
#include <fcntl.h>
#include <errno.h>
#include <utime.h>
-#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "pathnames.h"
#ifdef REMOTE
#include "rmt.h"
-# define STATIC
+# 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? */
#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!
*/
* 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;
* 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
* jobs that were stopped due to concurrency
# 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
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));
* job as well.
*/
if (DEBUG(JOB)) {
- (void) fprintf(stdout,
+ (void) fprintf(stdout,
"JobCondPassSig passing signal %d to child %d.\n",
signo, job->pid);
(void) fflush(stdout);
*
* Side Effects:
* We die by the same signal.
- *
+ *
*-----------------------------------------------------------------------
*/
static void
{
sigset_t nmask, omask;
struct sigaction act;
-
+
if (DEBUG(JOB)) {
(void) fprintf(stdout, "JobPassSig(%d) called.\n", signo);
(void) fflush(stdout);
} else if ((signo == SIGHUP) || (signo == SIGTERM) || (signo == SIGQUIT)) {
JobInterrupt(FALSE, signo);
}
-
+
/*
* 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.
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.
+ * are equal.
*
* Results:
* 0 if the rmtID's match
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));
if (strcmp(cmd, "...") == 0) {
- job->node->type |= OP_SAVE_CMDS;
+ 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);
+ return 1;
}
- return(0);
+ return 0;
}
#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \
}
cmdTemplate = commandShell->ignErr;
/*
- * The error ignoration(hee hee) is already taken care
+ * The error ignoration (hee hee) is already taken care
* of by the ignErr template, so pretend error checking
* is still on.
*/
errOff = FALSE;
}
}
-
+
DBPRINTF(cmdTemplate, cmd);
-
+
if (errOff) {
/*
* If echoing is already off, there's no point in issuing the
* Some nodes may be put on the toBeMade queue.
* Final commands for the job are placed on postCommands.
*
- * If we got an error and are aborting(aborting == ABORT_ERROR) and
+ * If we got an error and are aborting (aborting == ABORT_ERROR) and
* the job list is now empty, we are done for the day.
- * If we recognized an error(errors !=0), we set the aborting flag
+ * If we recognized an error (errors !=0), we set the aborting flag
* to ABORT_ERROR so no more jobs will be started.
*-----------------------------------------------------------------------
*/
* TRUE if in -B mode and the job exited non-zero.
*/
done = WEXITSTATUS(*status) != 0;
- /*
+ /*
* Old comment said: "Note we don't
* want to close down any of the streams until we know we're at the
* end."
*/
done = FALSE;
}
-
+
if (done ||
WIFSTOPPED(*status) ||
(WIFSIGNALED(*status) && (WTERMSIG(*status) == SIGCONT)) ||
DEBUG(JOB))
{
FILE *out;
-
+
if (compatMake && !usePipes && (job->flags & JOB_IGNERR)) {
/*
* If output is going to a file and this job is ignoring
lastNode = job->node;
}
if (!(job->flags & JOB_REMIGRATE)) {
- fprintf(out, "*** Stopped -- signal %d\n", WSTOPSIG(*status));
+ (void) fprintf(out, "*** Stopped -- signal %d\n",
+ WSTOPSIG(*status));
}
job->flags |= JOB_RESUME;
(void)Lst_AtEnd(stoppedJobs, (ClientData)job);
} else if (WTERMSIG(*status) == SIGCONT) {
/*
* If the beastie has continued, shift the Job from the stopped
- * list to the running one(or re-stop it if concurrency is
+ * list to the running one (or re-stop it if concurrency is
* exceeded) and go and get another child.
*/
if (job->flags & (JOB_RESUME|JOB_REMIGRATE|JOB_RESTART)) {
} else {
done = TRUE;
}
-
+
if (done &&
(aborting != ABORT_ERROR) &&
*/
aborting = ABORT_ERROR;
}
-
+
if ((aborting == ABORT_ERROR) && Job_Empty()) {
/*
* If we are aborting and the job table is now empty, we finish.
*/
return;
}
-
+
if (!silent) {
(void) fprintf(stdout, "touch %s\n", gn->name);
(void) fflush(stdout);
(void) lseek(streamID, 0L, L_SET);
(void) write(streamID, &c, 1);
}
-
+
(void) close(streamID);
} else {
(void) fprintf(stdout, "*** couldn't touch %s: %s",
/*-
*-----------------------------------------------------------------------
* 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.
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) &&
(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;
* 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";
*
* Side Effects:
* JobDoOutput is called.
- *
+ *
*-----------------------------------------------------------------------
*/
/*ARGSUSED*/
static void
JobLocalInput(stream, job)
- int stream; /* Stream that's ready(ignored) */
+ int stream; /* Stream that's ready (ignored) */
Job *job; /* Job to which the stream belongs */
{
JobDoOutput(job, FALSE);
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: ");
(void) fprintf(stdout, "\n");
(void) fflush(stdout);
}
-
+
/*
* Some jobs produce no output and it's disconcerting to have
- * no feedback of their running(since they produce no output, the
+ * no feedback of their running (since they produce no output, the
* banner with their name in it never appears). This is an attempt to
* provide that feedback, even if nothing follows it.
*/
MESSAGE(stdout, job->node);
lastNode = job->node;
}
-
+
#ifdef RMT_NO_EXEC
if (job->flags & JOB_REMOTE) {
goto jobExecFinish;
/*
* Must duplicate the input stream down to the child's input and
- * reset it to the beginning(again). Since the stream was marked
+ * 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);
-
+
if (usePipes) {
/*
* Set up the child's output to be routed through the pipe
}
/*
* The output channels are marked close on exec. This bit was
- * duplicated by the dup2(on some systems), so we have to clear
+ * duplicated by the dup2 (on some systems), so we have to clear
* it before routing the shell's error output to the same place as
* its standard output.
*/
#ifdef REMOTE
if (job->flags & JOB_REMOTE) {
Rmt_Exec(shellPath, argv, FALSE);
- } else
+ } else
#endif /* REMOTE */
(void) execv(shellPath, argv);
* stream to watch in the outputs mask
*/
job->curPos = 0;
-
+
#ifdef RMT_WILL_WATCH
Rmt_Watch(job->inPipe, JobLocalInput, job);
#else
}
#ifdef RMT_NO_EXEC
-jobExecFinish:
+jobExecFinish:
#endif
/*
* Now the job is actually running, add it to the table.
*-----------------------------------------------------------------------
* JobMakeArgv --
* Create the argv needed to execute the shell for a given job.
- *
+ *
*
* Results:
*
{
int argc;
static char args[10]; /* For merged arguments */
-
+
argv[0] = shellName;
argc = 1;
/*-
*-----------------------------------------------------------------------
* JobRestart --
- * Restart a job that stopped for some reason.
+ * Restart a job that stopped for some reason.
*
* Results:
* None.
#ifdef REMOTE
int host;
#endif
-
+
if (job->flags & JOB_REMIGRATE) {
if (
#ifdef REMOTE
job->rmtID = host;
}
#endif
-
+
(void)Lst_AtEnd(jobs, (ClientData)job);
nJobs += 1;
if (nJobs == maxJobs) {
* 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)) {
}
#ifdef REMOTE
if ((job->node->type&OP_NOEXPORT) ||
- (nLocal < maxLocal && runLocalFirst)
+ (nLocal < maxLocal && runLocalFirst)
# ifdef RMT_NO_EXEC
|| !Rmt_Export(shellPath, argv, job)
# else
/*
* If the job is remote, it's ok to resume it as long as the
* maximum concurrency won't be exceeded. If it's local and
- * we haven't reached the local concurrency limit already(or the
+ * we haven't reached the local concurrency limit already (or the
* job must be run locally and maxLocal is 0), it's also ok to
* resume it.
*/
Boolean error;
extern int errno;
int status;
-
+
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
error = !Rmt_Signal(job, SIGCONT);
job->flags |= JOB_CONTINUING;
W_SETTERMSIG(&status, SIGCONT);
JobFinish(job, &status);
-
+
job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
if (DEBUG(JOB)) {
(void) fprintf(stdout, "done\n");
*-----------------------------------------------------------------------
* 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
} else {
cmdsOK = TRUE;
}
-
+
/*
- * If the -n flag wasn't given, we open up OUR(not the child's)
+ * 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
* need to reopen it to feed it to the shell. If the -n flag *was* given,
* we just set the file to be stdout. Cute, huh?
if (!cmdsOK) {
DieHorribly();
}
-
+
job->cmdFILE = fopen(tfile, "w+");
if (job->cmdFILE == NULL) {
Punt("Could not open %s", tfile);
cmdsOK = FALSE;
} else {
LstNode ln = Lst_Next(gn->commands);
-
+
if ((ln == NILLNODE) ||
JobPrintCommand((ClientData) Lst_Datum(ln),
(ClientData) job))
*/
numCommands = 0;
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?
}
/*
- * If we're not supposed to execute a shell, don't.
+ * If we're not supposed to execute a shell, don't.
*/
if (noExec) {
/*
/*
* The job can only be run locally, but we've hit the limit of
* local concurrency, so put the job on hold until some other job
- * finishes. Note that the special jobs(.BEGIN, .INTERRUPT and .END)
+ * 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
+ * (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.
*/
jobFull = TRUE;
-
+
if (DEBUG(JOB)) {
(void) fprintf(stdout, "Can only run job locally.\n");
(void) fflush(stdout);
} else {
if ((nLocal >= maxLocal) && local) {
/*
- * If we're running this job locally as a special case(see above),
+ * If we're running this job locally as a special case (see above),
* at least say the table is full.
*/
jobFull = TRUE;
return(JOB_RUNNING);
}
-static char *
+static char *
JobOutput(job, cp, endp, msg)
register Job *job;
register char *cp, *endp;
* In both cases, however, we keep our figurative eye out for the
* 'noPrint' line for the shell from which the output came. If
* we recognize a line, we don't print it. If the command is not
- * alone on the line(the character after it is not \0 or \n), we
+ * alone on the line (the character after it is not \0 or \n), we
* do print whatever follows it.
*
* Results:
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) */
- int nRead; /*(Temporary) number of bytes read */
+ register int max; /* limit for i (end of current data) */
+ int nRead; /* (Temporary) number of bytes read */
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],
JOB_BUFSIZE - job->curPos);
if (nRead < 0) {
}
/*
- * If we hit the end-of-file(the job is dead), we must flush its
+ * If we hit the end-of-file (the job is dead), we must flush its
* remaining output, so pretend we read a newline if there's any
* output remaining in the buffer.
* Also clear the 'finish' flag so we stop looping.
} 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--) {
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;
i = job->curPos;
/*
* Need to send the output to the screen. Null terminate it
* first, overwriting the newline character if there was one.
- * So long as the line isn't one we should filter(according
+ * So long as the line isn't one we should filter (according
* to the shell description), we print the line, preceeded
* 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]);
+
+ cp = JobOutput(job, job->outBuf, &job->outBuf[i], FALSE);
/*
* There's still more in that thar buffer. This time, though,
}
if (i < max - 1) {
/* shift the remaining characters down */
- (void) memcpy(job->outBuf, &job->outBuf[i + 1], max -(i + 1));
- job->curPos = max -(i + 1);
-
+ (void) 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
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;
}
if (nLocal == 0) {
return;
}
-
+
while ((pid = waitpid((pid_t) -1, &status,
(block?0:WNOHANG)|WUNTRACED)) > 0)
{
(void) fprintf(stdout, "Process %d exited or stopped.\n", pid);
(void) fflush(stdout);
}
-
+
jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid);
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
jnode = Lst_Find(stoppedJobs, (ClientData) &pid, JobCmpPid);
if (jnode == NILLNODE) {
- Error("Resumed child(%d) not in table", pid);
+ Error("Resumed child (%d) not in table", pid);
continue;
}
job = (Job *)Lst_Datum(jnode);
(void) Lst_Remove(stoppedJobs, jnode);
} else {
- Error("Child(%d) not in table?", pid);
+ Error("Child (%d) not in table?", pid);
continue;
}
} else {
* Job_CatchOutput --
* Catch the output from our children, if we're using
* pipes do so. Otherwise just block time until we get a
- * signal(most likely a SIGCHLD) since there's no point in
+ * 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.
* NOTE: IT IS THE RESPONSIBILITY OF Rmt_Wait TO CALL Job_CatchChildren
* IN A TIMELY FASHION TO CATCH ANY LOCALLY RUNNING JOBS THAT EXIT.
* It may use the variable nLocal to determine if it needs to call
- * Job_CatchChildren(if nLocal is 0, there's nothing for which to
+ * Job_CatchChildren (if nLocal is 0, there's nothing for which to
* wait...)
*/
while (nJobs != 0 && pnJobs == nJobs) {
} else {
targFmt = TARG_FMT;
}
-
+
if (shellPath == NULL) {
/*
* The user didn't specify a shell to use, so we are using the
/*
* There are additional signals that need to be caught and passed if
* either the export system wants to be told directly of signals or if
- * we're giving each job its own process group(since then it won't get
+ * we're giving each job its own process group (since then it won't get
* signals from the terminal driver as we own the terminal)
*/
#if defined(RMT_WANTS_SIGNALS) || defined(USE_PGRP)
(void) signal(SIGWINCH, JobPassSig);
}
#endif
-
+
begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (begin != NILGNODE) {
words = brk_string(line, &wordCount, TRUE);
memset((Address)&newShell, 0, sizeof(newShell));
-
+
/*
* Parse the specification by keyword
*/
}
} else {
/*
- * The user provided a path. If s/he gave nothing else(fullSpec is
+ * The user provided a path. If s/he gave nothing else (fullSpec is
* FALSE), try and find a matching shell in the ones we know of.
* Else we just take the specification at its word and copy it
* to a new location. In either case, we need to record the
if (commandShell->echoOn && commandShell->echoOff) {
commandShell->hasEchoCtl = TRUE;
}
-
+
if (!commandShell->hasErrCtl) {
if (commandShell->errCheck == NULL) {
commandShell->errCheck = "";
commandShell->ignErr = "%s\n";
}
}
-
+
/*
* Do not free up the words themselves, since they might be in use by the
* shell specification...
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);
if (job->pid) {
if (DEBUG(JOB)) {
(void) fprintf(stdout,
- "JobInterrupt passing signal to child %d.\n",
+ "JobInterrupt passing signal to child %d.\n",
job->pid);
(void) fflush(stdout);
}
*/
if (DEBUG(JOB)) {
(void) fprintf(stdout,
- "JobInterrupt passing CONT to stopped child %d.\n",
+ "JobInterrupt passing CONT to stopped child %d.\n",
job->pid);
(void) fflush(stdout);
}
*-----------------------------------------------------------------------
* 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.
*
* Side Effects:
- * The process' temporary file(tfile) is removed if it still
+ * The process' temporary file (tfile) is removed if it still
* existed.
*-----------------------------------------------------------------------
*/
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);
/*
* 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) {
#endif /* RMT_WANTS_SIGNALS */
}
}
-
+
/*
* Catch as many children as want to report in at first, then give up
*/
-/* $OpenBSD: job.h,v 1.2 1996/06/26 05:36:34 deraadt Exp $ */
-/* $NetBSD: job.h,v 1.4 1995/06/14 15:19:26 christos Exp $ */
+/* $OpenBSD: job.h,v 1.3 1996/11/30 21:08:57 millert Exp $ */
+/* $NetBSD: job.h,v 1.5 1996/11/06 17:59:10 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)job.h 5.3 (Berkeley) 6/1/90
+ * from: @(#)job.h 8.1 (Berkeley) 6/6/93
*/
/*-
/*
* 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
\f
/*-
- * Job Table definitions.
+ * Job Table definitions.
*
* Each job has several things associated with it:
* 1) The process id of the child shell
* 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
* 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 */
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 */
-/* $OpenBSD: list.h,v 1.2 1996/06/26 05:36:34 deraadt Exp $ */
-/* $NetBSD: list.h,v 1.4 1995/06/14 15:19:28 christos Exp $ */
+/* $OpenBSD: list.h,v 1.3 1996/11/30 21:08:58 millert Exp $ */
+/* $NetBSD: list.h,v 1.5 1996/11/06 17:59:11 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)list.h 5.3 (Berkeley) 6/1/90
+ * from: @(#)list.h 8.1 (Berkeley) 6/6/93
*/
/*
* 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().
*/
#define List_InitElement(elementPtr) \
(elementPtr)->prevPtr = (List_Links *) NIL; \
(elementPtr)->nextPtr = (List_Links *) NIL;
-
+
/*
* Macros for stepping through or selecting parts of lists
*/
* 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.
* 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));
*
-/* $OpenBSD: lst.h,v 1.3 1996/06/26 05:36:35 deraadt Exp $ */
-/* $NetBSD: lst.h,v 1.6 1996/02/04 22:20:46 christos Exp $ */
+/* $OpenBSD: lst.h,v 1.4 1996/11/30 21:08:58 millert Exp $ */
+/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)lst.h 5.3 (Berkeley) 6/1/90
+ * from: @(#)lst.h 8.1 (Berkeley) 6/6/93
*/
/*-
* 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
*/
-# $OpenBSD: Makefile,v 1.2 1996/06/26 05:36:41 deraadt Exp $
-# $NetBSD: Makefile,v 1.3 1995/06/14 15:20:42 christos Exp $
+# $OpenBSD: Makefile,v 1.3 1996/11/30 21:09:09 millert Exp $
+# $NetBSD: Makefile,v 1.4 1996/11/06 17:59:31 christos Exp $
OBJ=lstAppend.o lstDupl.o lstInit.o lstOpen.o lstAtEnd.o lstEnQueue.o \
lstInsert.o lstAtFront.o lstIsAtEnd.o lstClose.o lstFind.o lstIsEmpty.o \
-/* $OpenBSD: lstAppend.c,v 1.2 1996/06/26 05:36:42 deraadt Exp $ */
-/* $NetBSD: lstAppend.c,v 1.4 1995/06/14 15:20:44 christos Exp $ */
+/* $OpenBSD: lstAppend.c,v 1.3 1996/11/30 21:09:09 millert Exp $ */
+/* $NetBSD: lstAppend.c,v 1.5 1996/11/06 17:59:31 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstAppend.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.2 1996/06/26 05:36:42 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.3 1996/11/30 21:09:09 millert Exp $";
#endif
#endif /* not lint */
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;
} 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);
}
-/* $OpenBSD: lstAtEnd.c,v 1.2 1996/06/26 05:36:42 deraadt Exp $ */
-/* $NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Exp $ */
+/* $OpenBSD: lstAtEnd.c,v 1.3 1996/11/30 21:09:10 millert Exp $ */
+/* $NetBSD: lstAtEnd.c,v 1.5 1996/11/06 17:59:32 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstAtEnd.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstAtEnd.c,v 1.2 1996/06/26 05:36:42 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstAtEnd.c,v 1.3 1996/11/30 21:09:10 millert Exp $";
#endif
#endif /* not lint */
*/
#include "lstInt.h"
-
+
/*-
*-----------------------------------------------------------------------
* Lst_AtEnd --
ClientData d; /* Datum to add */
{
register LstNode end;
-
+
end = Lst_Last (l);
return (Lst_Append (l, end, d));
}
-/* $OpenBSD: lstAtFront.c,v 1.2 1996/06/26 05:36:43 deraadt Exp $ */
-/* $NetBSD: lstAtFront.c,v 1.4 1995/06/14 15:20:48 christos Exp $ */
+/* $OpenBSD: lstAtFront.c,v 1.3 1996/11/30 21:09:10 millert Exp $ */
+/* $NetBSD: lstAtFront.c,v 1.5 1996/11/06 17:59:33 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstAtFront.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstAtFront.c,v 1.2 1996/06/26 05:36:43 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstAtFront.c,v 1.3 1996/11/30 21:09:10 millert Exp $";
#endif
#endif /* not lint */
ClientData d;
{
register LstNode front;
-
+
front = Lst_First (l);
return (Lst_Insert (l, front, d));
}
-/* $OpenBSD: lstClose.c,v 1.2 1996/06/26 05:36:43 deraadt Exp $ */
-/* $NetBSD: lstClose.c,v 1.4 1995/06/14 15:20:50 christos Exp $ */
+/* $OpenBSD: lstClose.c,v 1.3 1996/11/30 21:09:11 millert Exp $ */
+/* $NetBSD: lstClose.c,v 1.5 1996/11/06 17:59:34 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstClose.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstClose.c,v 1.2 1996/06/26 05:36:43 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstClose.c,v 1.3 1996/11/30 21:09:11 millert Exp $";
#endif
#endif /* not lint */
Lst l; /* The list to close */
{
register List list = (List) l;
-
+
if (LstValid(l) == TRUE) {
list->isOpen = FALSE;
list->atEnd = Unknown;
-/* $OpenBSD: lstConcat.c,v 1.2 1996/06/26 05:36:44 deraadt Exp $ */
-/* $NetBSD: lstConcat.c,v 1.5 1995/06/14 15:20:53 christos Exp $ */
+/* $OpenBSD: lstConcat.c,v 1.3 1996/11/30 21:09:11 millert Exp $ */
+/* $NetBSD: lstConcat.c,v 1.6 1996/11/06 17:59:34 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstConcat.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.2 1996/06/26 05:36:44 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.3 1996/11/30 21:09:11 millert Exp $";
#endif
#endif /* not lint */
/*
* Finish bookkeeping. The last new element becomes the last element
- * of list one.
+ * of list one.
*/
list1->lastPtr = last;
return (SUCCESS);
}
-
+
-/* $OpenBSD: lstDatum.c,v 1.2 1996/06/26 05:36:45 deraadt Exp $ */
-/* $NetBSD: lstDatum.c,v 1.4 1995/06/14 15:20:54 christos Exp $ */
+/* $OpenBSD: lstDatum.c,v 1.3 1996/11/30 21:09:12 millert Exp $ */
+/* $NetBSD: lstDatum.c,v 1.5 1996/11/06 17:59:35 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstDatum.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.2 1996/06/26 05:36:45 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.3 1996/11/30 21:09:12 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstDeQueue.c,v 1.2 1996/06/26 05:36:45 deraadt Exp $ */
-/* $NetBSD: lstDeQueue.c,v 1.4 1995/06/14 15:20:56 christos Exp $ */
+/* $OpenBSD: lstDeQueue.c,v 1.3 1996/11/30 21:09:12 millert Exp $ */
+/* $NetBSD: lstDeQueue.c,v 1.5 1996/11/06 17:59:36 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstDeQueue.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.2 1996/06/26 05:36:45 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.3 1996/11/30 21:09:12 millert Exp $";
#endif
#endif /* not lint */
{
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);
-/* $OpenBSD: lstDestroy.c,v 1.2 1996/06/26 05:36:46 deraadt Exp $ */
-/* $NetBSD: lstDestroy.c,v 1.5 1995/06/14 15:20:58 christos Exp $ */
+/* $OpenBSD: lstDestroy.c,v 1.3 1996/11/30 21:09:13 millert Exp $ */
+/* $NetBSD: lstDestroy.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstDestroy.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.2 1996/06/26 05:36:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.3 1996/11/30 21:09:13 millert Exp $";
#endif
#endif /* not lint */
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.
free ((Address)ln);
}
}
-
+
free ((Address)l);
}
-/* $OpenBSD: lstDupl.c,v 1.2 1996/06/26 05:36:46 deraadt Exp $ */
-/* $NetBSD: lstDupl.c,v 1.5 1995/06/14 15:21:02 christos Exp $ */
+/* $OpenBSD: lstDupl.c,v 1.3 1996/11/30 21:09:13 millert Exp $ */
+/* $NetBSD: lstDupl.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstDupl.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.2 1996/06/26 05:36:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.3 1996/11/30 21:09:13 millert Exp $";
#endif
#endif /* not lint */
register Lst nl;
register ListNode ln;
register List list = (List)l;
-
+
if (!LstValid (l)) {
return (NILLST);
}
ln = ln->nextPtr;
}
}
-
+
return (nl);
}
-/* $OpenBSD: lstEnQueue.c,v 1.2 1996/06/26 05:36:47 deraadt Exp $ */
-/* $NetBSD: lstEnQueue.c,v 1.4 1995/06/14 15:21:04 christos Exp $ */
+/* $OpenBSD: lstEnQueue.c,v 1.3 1996/11/30 21:09:14 millert Exp $ */
+/* $NetBSD: lstEnQueue.c,v 1.5 1996/11/06 17:59:38 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstEnQueue.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.2 1996/06/26 05:36:47 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.3 1996/11/30 21:09:14 millert Exp $";
#endif
#endif /* not lint */
if (LstValid (l) == FALSE) {
return (FAILURE);
}
-
+
return (Lst_Append (l, Lst_Last(l), d));
}
-/* $OpenBSD: lstFind.c,v 1.2 1996/06/26 05:36:47 deraadt Exp $ */
-/* $NetBSD: lstFind.c,v 1.5 1995/06/14 15:21:07 christos Exp $ */
+/* $OpenBSD: lstFind.c,v 1.3 1996/11/30 21:09:14 millert Exp $ */
+/* $NetBSD: lstFind.c,v 1.6 1996/11/06 17:59:39 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstFind.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstFind.c,v 1.2 1996/06/26 05:36:47 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstFind.c,v 1.3 1996/11/30 21:09:14 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstFindFrom.c,v 1.2 1996/06/26 05:36:48 deraadt Exp $ */
-/* $NetBSD: lstFindFrom.c,v 1.5 1995/06/14 15:21:09 christos Exp $ */
+/* $OpenBSD: lstFindFrom.c,v 1.3 1996/11/30 21:09:15 millert Exp $ */
+/* $NetBSD: lstFindFrom.c,v 1.6 1996/11/06 17:59:40 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
*/
#ifndef lint
-/* from: static char sccsid[] = "@(#)lstFindFrom.c 5.3 (Berkeley) 6/1/90"; */
-static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.2 1996/06/26 05:36:48 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
+#else
+static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.3 1996/11/30 21:09:15 millert Exp $";
+#endif
#endif /* not lint */
/*-
{
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;
tln = tln->nextPtr;
}
} while (tln != (ListNode)ln && tln != NilListNode);
-
+
if (found) {
return ((LstNode)tln);
} else {
-/* $OpenBSD: lstFirst.c,v 1.2 1996/06/26 05:36:48 deraadt Exp $ */
-/* $NetBSD: lstFirst.c,v 1.4 1995/06/14 15:21:12 christos Exp $ */
+/* $OpenBSD: lstFirst.c,v 1.3 1996/11/30 21:09:15 millert Exp $ */
+/* $NetBSD: lstFirst.c,v 1.5 1996/11/06 17:59:41 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstFirst.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.2 1996/06/26 05:36:48 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.3 1996/11/30 21:09:15 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstForEach.c,v 1.2 1996/06/26 05:36:49 deraadt Exp $ */
-/* $NetBSD: lstForEach.c,v 1.5 1995/06/14 15:21:14 christos Exp $ */
+/* $OpenBSD: lstForEach.c,v 1.3 1996/11/30 21:09:16 millert Exp $ */
+/* $NetBSD: lstForEach.c,v 1.6 1996/11/06 17:59:41 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstForEach.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstForEach.c,v 1.2 1996/06/26 05:36:49 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstForEach.c,v 1.3 1996/11/30 21:09:16 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstForEachFrom.c,v 1.2 1996/06/26 05:36:50 deraadt Exp $ */
-/* $NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 christos Exp $ */
+/* $OpenBSD: lstForEachFrom.c,v 1.3 1996/11/30 21:09:16 millert Exp $ */
+/* $NetBSD: lstForEachFrom.c,v 1.5 1996/11/06 17:59:42 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstForEachFrom.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.2 1996/06/26 05:36:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.3 1996/11/30 21:09:16 millert Exp $";
#endif
#endif /* not lint */
* 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.
Lst_ForEachFrom (l, ln, proc, d)
Lst l;
LstNode ln;
- register int (*proc)();
+ register int (*proc) __P((ClientData, ClientData));
register ClientData d;
{
register ListNode tln = (ListNode)ln;
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--;
*/
done = (next == tln->nextPtr &&
(next == NilListNode || next == list->firstPtr));
-
+
next = tln->nextPtr;
if (tln->flags & LN_DELETED) {
}
tln = next;
} while (!result && !LstIsEmpty(list) && !done);
-
+
}
-/* $OpenBSD: lstInit.c,v 1.2 1996/06/26 05:36:50 deraadt Exp $ */
-/* $NetBSD: lstInit.c,v 1.4 1995/06/14 15:21:18 christos Exp $ */
+/* $OpenBSD: lstInit.c,v 1.3 1996/11/30 21:09:17 millert Exp $ */
+/* $NetBSD: lstInit.c,v 1.5 1996/11/06 17:59:43 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstInit.c 5.4 (Berkeley) 12/28/90";
+static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstInit.c,v 1.2 1996/06/26 05:36:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstInit.c,v 1.3 1996/11/30 21:09:17 millert Exp $";
#endif
#endif /* not lint */
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);
}
-/* $OpenBSD: lstInsert.c,v 1.2 1996/06/26 05:36:51 deraadt Exp $ */
-/* $NetBSD: lstInsert.c,v 1.4 1995/06/14 15:21:21 christos Exp $ */
+/* $OpenBSD: lstInsert.c,v 1.3 1996/11/30 21:09:17 millert Exp $ */
+/* $NetBSD: lstInsert.c,v 1.5 1996/11/06 17:59:44 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstInsert.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.2 1996/06/26 05:36:51 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.3 1996/11/30 21:09:17 millert Exp $";
#endif
#endif /* not lint */
*/
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;
} 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);
}
-
+
-/* $OpenBSD: lstInt.h,v 1.3 1996/06/26 05:36:51 deraadt Exp $ */
-/* $NetBSD: lstInt.h,v 1.6 1995/11/10 21:27:27 cgd Exp $ */
+/* $OpenBSD: lstInt.h,v 1.4 1996/11/30 21:09:18 millert Exp $ */
+/* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)lstInt.h 5.4 (Berkeley) 12/28/90
+ * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
*/
/*-
-/* $OpenBSD: lstIsAtEnd.c,v 1.2 1996/06/26 05:36:52 deraadt Exp $ */
-/* $NetBSD: lstIsAtEnd.c,v 1.4 1995/06/14 15:21:25 christos Exp $ */
+/* $OpenBSD: lstIsAtEnd.c,v 1.3 1996/11/30 21:09:18 millert Exp $ */
+/* $NetBSD: lstIsAtEnd.c,v 1.5 1996/11/06 17:59:45 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstIsAtEnd.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.2 1996/06/26 05:36:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.3 1996/11/30 21:09:18 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstIsEmpty.c,v 1.2 1996/06/26 05:36:52 deraadt Exp $ */
-/* $NetBSD: lstIsEmpty.c,v 1.4 1995/06/14 15:21:27 christos Exp $ */
+/* $OpenBSD: lstIsEmpty.c,v 1.3 1996/11/30 21:09:19 millert Exp $ */
+/* $NetBSD: lstIsEmpty.c,v 1.5 1996/11/06 17:59:47 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstIsEmpty.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.2 1996/06/26 05:36:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.3 1996/11/30 21:09:19 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstLast.c,v 1.2 1996/06/26 05:36:53 deraadt Exp $ */
-/* $NetBSD: lstLast.c,v 1.4 1995/06/14 15:21:29 christos Exp $ */
+/* $OpenBSD: lstLast.c,v 1.3 1996/11/30 21:09:19 millert Exp $ */
+/* $NetBSD: lstLast.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstLast.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstLast.c,v 1.2 1996/06/26 05:36:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstLast.c,v 1.3 1996/11/30 21:09:19 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstMember.c,v 1.2 1996/06/26 05:36:53 deraadt Exp $ */
-/* $NetBSD: lstMember.c,v 1.4 1995/06/14 15:21:32 christos Exp $ */
+/* $OpenBSD: lstMember.c,v 1.3 1996/11/30 21:09:20 millert Exp $ */
+/* $NetBSD: lstMember.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstMember.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstMember.c,v 1.2 1996/06/26 05:36:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstMember.c,v 1.3 1996/11/30 21:09:20 millert Exp $";
#endif
#endif /* not lint */
if (lNode == NilListNode) {
return NILLNODE;
}
-
+
do {
if (lNode->datum == d) {
return (LstNode)lNode;
-/* $OpenBSD: lstNext.c,v 1.2 1996/06/26 05:36:54 deraadt Exp $ */
-/* $NetBSD: lstNext.c,v 1.4 1995/06/14 15:21:35 christos Exp $ */
+/* $OpenBSD: lstNext.c,v 1.3 1996/11/30 21:09:20 millert Exp $ */
+/* $NetBSD: lstNext.c,v 1.5 1996/11/06 17:59:49 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstNext.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstNext.c,v 1.2 1996/06/26 05:36:54 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstNext.c,v 1.3 1996/11/30 21:09:20 millert Exp $";
#endif
#endif /* not lint */
{
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) {
/*
list->atEnd = Middle;
}
}
-
+
return ((LstNode)tln);
}
-/* $OpenBSD: lstOpen.c,v 1.2 1996/06/26 05:36:54 deraadt Exp $ */
-/* $NetBSD: lstOpen.c,v 1.4 1995/06/14 15:21:37 christos Exp $ */
+/* $OpenBSD: lstOpen.c,v 1.3 1996/11/30 21:09:21 millert Exp $ */
+/* $NetBSD: lstOpen.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstOpen.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.2 1996/06/26 05:36:54 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.3 1996/11/30 21:09:21 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstRemove.c,v 1.2 1996/06/26 05:36:55 deraadt Exp $ */
-/* $NetBSD: lstRemove.c,v 1.4 1995/06/14 15:21:39 christos Exp $ */
+/* $OpenBSD: lstRemove.c,v 1.3 1996/11/30 21:09:21 millert Exp $ */
+/* $NetBSD: lstRemove.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstRemove.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.2 1996/06/26 05:36:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.3 1996/11/30 21:09:21 millert Exp $";
#endif
#endif /* not lint */
!LstNodeValid (ln, l)) {
return (FAILURE);
}
-
+
/*
* unlink it from the list
*/
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
if (list->firstPtr == lNode) {
list->firstPtr = NilListNode;
}
-
+
/*
* note that the datum is unmolested. The caller must free it as
* necessary and as expected.
} else {
lNode->flags |= LN_DELETED;
}
-
+
return (SUCCESS);
}
-/* $OpenBSD: lstReplace.c,v 1.2 1996/06/26 05:36:56 deraadt Exp $ */
-/* $NetBSD: lstReplace.c,v 1.4 1995/06/14 15:21:41 christos Exp $ */
+/* $OpenBSD: lstReplace.c,v 1.3 1996/11/30 21:09:22 millert Exp $ */
+/* $NetBSD: lstReplace.c,v 1.5 1996/11/06 17:59:51 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstReplace.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.2 1996/06/26 05:36:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.3 1996/11/30 21:09:22 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: lstSucc.c,v 1.2 1996/06/26 05:36:56 deraadt Exp $ */
-/* $NetBSD: lstSucc.c,v 1.4 1995/06/14 15:21:42 christos Exp $ */
+/* $OpenBSD: lstSucc.c,v 1.3 1996/11/30 21:09:22 millert Exp $ */
+/* $NetBSD: lstSucc.c,v 1.5 1996/11/06 17:59:52 christos Exp $ */
/*
- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1989, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
#ifndef lint
#if 0
-static char sccsid[] = "@(#)lstSucc.c 5.3 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.2 1996/06/26 05:36:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.3 1996/11/30 21:09:22 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: main.c,v 1.8 1996/09/02 16:04:13 briggs Exp $ */
-/* $NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $ */
+/* $OpenBSD: main.c,v 1.9 1996/11/30 21:08:59 millert Exp $ */
+/* $NetBSD: main.c,v 1.31 1996/11/06 17:59:12 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.
*
*/
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
-static char sccsid[] = "@(#)main.c 5.25 (Berkeley) 4/1/91";
-static char rcsid[] = "$NetBSD: main.c,v 1.26 1996/03/11 13:45:33 christos Exp $";
+static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.8 1996/09/02 16:04:13 briggs Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.9 1996/11/30 21:08:59 millert Exp $";
#endif
#endif /* not lint */
#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>
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 */
static int maxLocal; /* -L argument */
Boolean compatMake; /* -B argument */
Boolean checkEnvFirst; /* -e flag */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
-static Boolean ReadMakefile();
-static void usage();
+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 char *curdir; /* startup directory */
static char *objdir; /* where we chdir'ed to */
optind = 1; /* since we're called more than once */
#ifdef REMOTE
-# define OPTFLAGS "BD:I:L:PSd:ef:ij:km:nqrst"
+# define OPTFLAGS "BD:I:L:PSV:d:ef:ij:km:nqrst"
#else
-# define OPTFLAGS "BD:I:PSd:ef:ij:km:nqrst"
+# define OPTFLAGS "BD:I:PSV:d:ef:ij:km:nqrst"
#endif
rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
switch(c) {
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;
case 'B':
compatMake = TRUE;
break;
*/
for (argv += optind, argc -= optind; *argv; ++argv, --argc)
if (Parse_IsVar(*argv)) {
- char *var = strdup(*argv);
+ char *var = estrdup(*argv);
Parse_DoVar(var, VAR_CMD);
free(var);
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
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, *pwd, *getenv(), *getwd();
+ char *p, *p1, *path, *pathp, *pwd;
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;
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);
}
*/
if (!machine) {
#ifndef MACHINE
+ struct utsname utsname;
+
if (uname(&utsname) == -1) {
perror("make: uname");
exit(2);
}
/*
- * 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,
+ * 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,
* and modify the paths for the Makefiles apropriately. The
* current directory is also placed as a variable for make scripts.
*/
- 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;
+ 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)))
+ objdir = curdir;
}
else {
- 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
+ (void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
+ if (!(objdir = chdir_verify_path(mdpath, obpath)))
objdir = curdir;
}
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 */
maxJobs = maxLocal;
#endif
compatMake = FALSE; /* No compat mode */
-
+
/*
* Initialize the parsing, directory and variable modules to prepare
#else
Main_ParseArgLine(getenv("MAKE"));
#endif
-
+
MainParseArgs(argc, argv);
/*
*/
if (Lst_IsEmpty(sysIncPath)) {
for (start = syspath; *start != '\0'; start = cp) {
- for (cp = start; *cp != '\0' && *cp != ':'; cp++)
+ for (cp = start; *cp != '\0' && *cp != ':'; cp++)
continue;
if (*cp == '\0') {
Dir_AddDir(sysIncPath, start);
ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
if (ln != NILLNODE)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- } else if (!ReadMakefile("makefile"))
- (void)ReadMakefile("Makefile");
+ } else if (!ReadMakefile("makefile", NULL))
+ (void)ReadMakefile("Makefile", NULL);
- (void)ReadMakefile(".depend");
+ (void)ReadMakefile(".depend", NULL);
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
if (p1)
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
else
targs = Targ_FindList(create, TARG_CREATE);
- if (!compatMake) {
+ if (!compatMake && !printVars) {
/*
* Initialize job module before traversing the graph, now that
* any .BEGIN and .END targets have been read. This is done
/* Traverse the graph, checking on all the targets */
outOfDate = Make_Run(targs);
- } else
+ } else if (!printVars) {
/*
* 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);
* lots
*/
static Boolean
-ReadMakefile(fname)
- char *fname; /* makefile to read */
+ReadMakefile(p, q)
+ ClientData p, q;
{
+ char *fname = p; /* makefile to read */
extern Lst parseIncPath;
FILE *stream;
char *name, path[MAXPATHLEN + 1];
*/
(void) dup2(fds[1], 1);
(void) close(fds[1]);
-
+
(void) execv("/bin/sh", args);
_exit(1);
/*NOTREACHED*/
* 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)
+ if (cc > 0)
Buf_AddBytes(buf, cc, (Byte *) result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
res = (char *)Buf_GetAll (buf, &cc);
Buf_Destroy (buf, FALSE);
- if (cc == 0)
+ if (cc == 0)
*err = "Couldn't read shell's output for \"%s\"";
if (status)
* a message and exits.
*
* Results:
- * None
+ * None
*
* Side Effects:
* All children are killed indiscriminately and the program Lib_Exits
/*
* Finish --
* Called when aborting due to errors in child shell to signal
- * abnormal exit.
+ * abnormal exit.
*
* Results:
- * None
+ * None
*
* Side Effects:
* The program exits
}
/*
- * emalloc --
+ * estrdup --
* strdup, but die on error.
*/
char *
usage()
{
(void)fprintf(stderr,
-"usage: make [-eiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
- [-I directory] [-j max_jobs] [-m directory] [variable=value]\n");
+"usage: make [-Beiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
+ [-I directory] [-j max_jobs] [-m directory] [-V variable]\n\
+ [variable=value] [target ...]\n");
exit(2);
}
-.\" $OpenBSD: make.1,v 1.8 1996/09/21 10:53:48 deraadt Exp $
-.\" $NetBSD: make.1,v 1.15 1996/08/30 17:59:40 thorpej Exp $
+.\" $OpenBSD: make.1,v 1.9 1996/11/30 21:08:59 millert Exp $
+.\" $NetBSD: make.1,v 1.16 1996/11/06 17:59:13 christos Exp $
.\"
-.\" Copyright (c) 1990 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1990, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)make.1 5.7 (Berkeley) 7/24/91
+.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd July 24, 1991
+.Dd March 19, 1994
.Dt MAKE 1
.Os
.Sh NAME
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm make
-.Op Fl Beiknqrstv
+.Op Fl Beiknqrst
.Op Fl D Ar variable
.Op Fl d Ar flags
.Op Fl f Ar makefile
.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
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl B
+.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
.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
+may have running at any one time. Turns compatibility mode off, unless the
.Ar B
flag is also specified.
.It Fl k
.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
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
.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
.Nm make
will only evaluate a conditional as far as is necessary to determine
its value.
-Parenthesis may be used to change the order of evaluation.
+Parentheses may be used to change the order of evaluation.
The boolean operator
.Ql Ic \&!
may be used to logically negate an entire
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
.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
.Sh ENVIRONMENT
.Nm Make
utilizes the following environment variables, if they exist:
+.Ev MACHINE ,
.Ev MAKE ,
-.Ev MAKEFLAGS
+.Ev MAKEFLAGS ,
+.Ev MAKEOBJDIR ,
and
-.Ev MAKEOBJDIR .
+.Ev PWD .
.Sh FILES
.Bl -tag -width /usr/share/mk -compact
.It .depend
-/* $OpenBSD: make.c,v 1.3 1996/09/02 16:04:14 briggs Exp $ */
-/* $NetBSD: make.c,v 1.9 1996/08/30 23:21:10 christos Exp $ */
+/* $OpenBSD: make.c,v 1.4 1996/11/30 21:09:00 millert Exp $ */
+/* $NetBSD: make.c,v 1.10 1996/11/06 17:59: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.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)make.c 5.3 (Berkeley) 6/1/90";
-static char rcsid[] = "$NetBSD: make.c,v 1.8 1996/03/15 21:52:37 christos Exp $";
+static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: make.c,v 1.3 1996/09/02 16:04:14 briggs Exp $";
+static char rcsid[] = "$OpenBSD: make.c,v 1.4 1996/11/30 21:09:00 millert Exp $";
#endif
#endif /* not lint */
*-----------------------------------------------------------------------
* 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
* 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
printf(".USE node...");
}
oodate = FALSE;
- } else if (gn->type & OP_LIB) {
+ } else if ((gn->type & OP_LIB) && Arch_IsLib(gn)) {
if (DEBUG(MAKE)) {
printf("library...");
}
*/
(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);
}
Lst_Close (cgn->children);
}
-
+
pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM);
/*
* 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
}
#endif
}
-
+
if (Lst_Open (cgn->parents) == SUCCESS) {
while ((ln = Lst_Next (cgn->parents)) != NILLNODE) {
pgn = (GNode *)Lst_Datum (ln);
(void)Lst_EnQueue(toBeMade, (ClientData)succ);
}
}
-
+
/*
* Set the .PREFIX and .IMPSRC variables for all the implied parents
* of this node.
MakeStartJobs ()
{
register GNode *gn;
-
+
while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
gn = (GNode *) Lst_DeQueue (toBeMade);
if (DEBUG(MAKE)) {
continue;
}
}
-
+
numNodes--;
if (Make_OODate (gn)) {
if (DEBUG(MAKE)) {
*/
Make_DoAllVar (gn);
}
-
+
Make_Update (gn);
}
}
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...
}
}
}
-
+
Lst_Destroy (examine, NOFREE);
if (queryFlag) {
* 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();
}
*/
errors = ((errors == 0) && (numNodes != 0));
Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors);
-
+
return (TRUE);
}
-/* $OpenBSD: make.h,v 1.6 1996/09/02 16:04:15 briggs Exp $ */
-/* $NetBSD: make.h,v 1.10 1996/08/13 16:39:30 christos Exp $ */
+/* $OpenBSD: make.h,v 1.7 1996/11/30 21:09:00 millert Exp $ */
+/* $NetBSD: make.h,v 1.11 1996/11/06 17:59:17 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)make.h 8.3 (Berkeley) 6/13/95
+ * from: @(#)make.h 8.3 (Berkeley) 6/13/95
*/
/*-
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else
-#define __P(protos) () /* traditional C preprocessor */
+#define __P(protos) () /* traditional C preprocessor */
#endif
#endif
#endif
* 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 */
} GNode;
/*
- * Manifest constants
+ * Manifest constants
*/
#define NILGNODE ((GNode *) NIL)
* 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 (:) */
* 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 */
* 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 */
* 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 */
#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
-/* $OpenBSD: nonints.h,v 1.5 1996/09/02 16:04:16 briggs Exp $ */
-/* $NetBSD: nonints.h,v 1.11 1996/08/13 16:42:11 christos Exp $ */
+/* $OpenBSD: nonints.h,v 1.6 1996/11/30 21:09:01 millert Exp $ */
+/* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 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.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)nonints.h 5.6 (Berkeley) 4/18/91
+ * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
*/
/* arch.c */
Boolean Arch_LibOODate __P((GNode *));
void Arch_Init __P((void));
void Arch_End __P((void));
+int Arch_IsLib __P((GNode *));
/* compat.c */
void Compat_Run __P((Lst));
-/* $OpenBSD: parse.c,v 1.10 1996/09/21 05:03:37 briggs Exp $ */
-/* $NetBSD: parse.c,v 1.25 1996/09/13 04:22:09 christos Exp $ */
+/* $OpenBSD: parse.c,v 1.11 1996/11/30 21:09:02 millert Exp $ */
+/* $NetBSD: parse.c,v 1.27 1996/11/06 17:59:20 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.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)parse.c 5.18 (Berkeley) 2/19/91";
+static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$NetBSD: parse.c,v 1.25 1996/09/13 04:22:09 christos Exp $";
+static char rcsid[] = "$OpenBSD: parse.c,v 1.11 1996/11/30 21:09:02 millert Exp $";
#endif
#endif /* not lint */
end,
cur;
register int diff;
-
+
start = 0;
end = (sizeof(parseKeywords)/sizeof(parseKeywords[0])) - 1;
/*
* 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))
*/
register GNode *cohort;
LstNode ln;
-
+
cohort = Targ_NewGN(gn->name);
/*
* Duplicate links to parents so graph traversal is simple. Perhaps
}
/*
* 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;
return (0);
}
-/*-
+/*-
*---------------------------------------------------------------------
* ParseAddDep --
* Check if the pair of GNodes given needs to be synchronized.
*
* Side Effects:
* A dependency can be added between the two nodes.
- *
+ *
*---------------------------------------------------------------------
*/
int
curTargs = Lst_Init(FALSE);
curSrcs = Lst_Init(FALSE);
-
+
do {
for (cp = line;
*cp && !isspace (*cp) &&
}
}
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;
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) {
Parse_Error(PARSE_FATAL, "Mismatched special targets");
return;
}
-
+
specType = parseKeywords[keywd].spec;
tOp = parseKeywords[keywd].op;
case NotParallel:
{
extern int maxJobs;
-
+
maxJobs = 1;
break;
}
* modify.
*/
Lst path;
-
+
specType = ExPath;
path = Suff_GetPath (&line[5]);
if (path == NILLST) {
}
}
}
-
+
/*
* 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)) {
* 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 {
/*
*/
(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
*/
if (specType != Not && specType != ExPath) {
Boolean warn = FALSE;
-
+
while ((*cp != '!') && (*cp != ':') && *cp) {
if (*cp != ' ' && *cp != '\t') {
warn = TRUE;
Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
/*
- * Get to the first source
+ * Get to the first source
*/
while (*cp && isspace (*cp)) {
cp++;
} 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) ||
line = cp;
}
}
-
+
if (mainNode == NILGNODE) {
/*
* If we have yet to decide on a main target to make, in the
/*
* Skip to variable name
*/
- for (;(*line == ' ') || (*line == '\t'); line++)
+ for (;(*line == ' ') || (*line == '\t'); line++)
continue;
for (; *line != '=' || level != 0; line++)
case '\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 ')':
level--;
break;
-
+
default:
if (wasSpace && haveName) {
if (ISEQOPERATOR(*line)) {
return FALSE;
}
else {
- haveName = TRUE;
+ haveName = TRUE;
wasSpace = FALSE;
}
break;
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
*/
*---------------------------------------------------------------------
* 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
prefEnd = strrchr (Fname, '/');
if (prefEnd != (char *)NULL) {
char *newName;
-
+
*prefEnd = '\0';
if (file[0] == '/')
newName = estrdup(file);
*---------------------------------------------------------------------
* Parse_FromString --
* Start Parsing from the given string
- *
+ *
* Results:
* None
*
oldFile->fname = fname;
oldFile->F = curFILE;
oldFile->p = curPTR;
-
+
(void) Lst_AtFront (includes, (ClientData)oldFile);
curFILE = NULL;
*---------------------------------------------------------------------
* ParseTraditionalInclude --
* Push to another file.
- *
+ *
* The input is the line minus the "include". The file name is
* the string following the "include".
*
prefEnd = strrchr (fname, '/');
if (prefEnd != (char *)NULL) {
char *newName;
-
+
*prefEnd = '\0';
newName = str_concat (fname, file, STR_ADDSLASH);
fullname = Dir_FindFile (newName, parseIncPath);
/*-
*---------------------------------------------------------------------
* ParseReadc --
- * Read a character from the current file
+ * Read a character from the current file
*
* Results:
* The character that was read
{
if (curFILE)
return fgetc(curFILE);
-
+
if (curPTR && *curPTR->ptr)
return *curPTR->ptr++;
return EOF;
/*-
*---------------------------------------------------------------------
* ParseUnreadc --
- * Put back a character to the current file
+ * Put back a character to the current file
*
* Results:
* None.
int skip; /* Skip lines that don't start with . */
{
char *line;
- int c, lastc = '\0', lineLength;
+ int c, lastc, lineLength = 0;
Buffer buf;
- c = ParseReadc();
+ buf = Buf_Init(MAKE_BSIZE);
- 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') {
- lastc = '\0';
- do {
- if (lastc != '\0' && lastc != '\n')
- Buf_AddByte (buf, (Byte) lastc);
- if ((lastc = c) == '\n')
- lineno++;
- c = ParseReadc();
- if (c == '\n' && lastc == '\\')
- lastc = '\0';
- } while (((c != '\n') || (lastc == '\0')) && (c != EOF));
- if (lastc != '\0' && lastc != '\n')
- Buf_AddByte (buf, (Byte) lastc);
- }
- lineno++;
-
- Buf_AddByte (buf, (Byte)'\0');
- line = (char *)Buf_GetAll (buf, &lineLength);
- Buf_Destroy (buf, FALSE);
+ 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;
+ }
+
+ 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);
return line;
}
break;
}
}
-
+
if (c != EOF) {
lastc = c;
buf = Buf_Init(MAKE_BSIZE);
-
+
while (((c = ParseReadc ()) != '\n' || (lastc == '\\')) &&
(c != EOF))
{
*/
ParseUnreadc('\t');
goto line_read;
- }
+ }
break;
case '=':
if (!semiNL) {
*/
Buf_AddByte (buf, (Byte)lastc);
lastc = c;
-
+
}
line_read:
lineno++;
-
+
if (lastc != '\0') {
Buf_AddByte (buf, (Byte)lastc);
}
ep = line;
while (*ep)
++ep;
- while (ep > line && (ep[-1] == ' ' || ep[-1] == '\t')) {
+ while (ep > line + 1 && (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
*/
line = ParseSkipLine(0);
if (line == NULL) {
- Parse_Error (PARSE_FATAL,
+ Parse_Error (PARSE_FATAL,
"Unexpected end of file in for loop.\n");
break;
}
inLine = FALSE;
}
}
-
+
/*-
*---------------------------------------------------------------------
goto nextLine;
}
}
- if (*line == '#' || *line == '\0') {
- /* If we're this far, the line must be a comment.
- (Empty lines are ignored as well) */
+ if (*line == '#') {
+ /* If we're this far, the line must be a comment. */
goto nextLine;
}
-
+
if (*line == '\t') {
/*
* If a line starts with a tab, it can only hope to be
/*
* 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);
}
}
#ifdef SYSVINCLUDE
- } else if (strncmp (line, "include", 7) == 0 &&
+ } else if (strncmp (line, "include", 7) == 0 &&
isspace((unsigned char) line[7]) &&
strchr(line, ':') == NULL) {
/*
#ifndef POSIX
Boolean nonSpace = FALSE;
#endif
-
+
cp = line;
if (isspace((unsigned char) line[0])) {
while ((*cp != '\0') && isspace((unsigned char) *cp)) {
}
#endif
}
-
+
#ifndef POSIX
if (*cp == '\0') {
if (inLine) {
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
}
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);
Lst_Destroy(parseIncPath, Dir_Destroy);
Lst_Destroy(includes, NOFREE); /* Should be empty now */
}
-
+
/*-
*-----------------------------------------------------------------------
-/* $OpenBSD: pathnames.h,v 1.5 1996/09/02 16:04:18 briggs Exp $ */
-/* $NetBSD: pathnames.h,v 1.5 1996/08/30 17:59:41 thorpej Exp $ */
+/* $OpenBSD: pathnames.h,v 1.6 1996/11/30 21:09:03 millert Exp $ */
+/* $NetBSD: pathnames.h,v 1.6 1996/11/06 17:59:21 christos Exp $ */
/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef _PATH_OBJDIR
#define _PATH_OBJDIR "obj"
#endif /* !_PATH_OBJDIR */
+#ifndef _PATH_OBJDIRPREFIX
+#define _PATH_OBJDIRPREFIX "/usr/obj"
+#endif /* !_PATH_OBJDIRPREFIX */
#ifndef _PATH_DEFSHELLDIR
#define _PATH_DEFSHELLDIR "/bin"
#endif /* !_PATH_DEFSHELLDIR */
-/* $OpenBSD: sprite.h,v 1.2 1996/06/26 05:36:36 deraadt Exp $ */
-/* $NetBSD: sprite.h,v 1.5 1995/06/14 15:19:54 christos Exp $ */
+/* $OpenBSD: sprite.h,v 1.3 1996/11/30 21:09:03 millert Exp $ */
+/* $NetBSD: sprite.h,v 1.6 1996/11/06 17:59:22 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.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)sprite.h 5.3 (Berkeley) 6/1/90
+ * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93
*/
/*
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.
/*
- * 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.
*/
-/* $OpenBSD: str.c,v 1.4 1996/06/26 05:36:37 deraadt Exp $ */
-/* $NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $ */
+/* $OpenBSD: str.c,v 1.5 1996/11/30 21:09:04 millert Exp $ */
+/* $NetBSD: str.c,v 1.13 1996/11/06 17:59:23 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.
*
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
-static char rcsid[] = "$OpenBSD: str.c,v 1.4 1996/06/26 05:36:37 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: str.c,v 1.5 1996/11/30 21:09:04 millert Exp $";
#endif
#endif /* not lint */
void
str_end()
{
- if (argv[0]) {
- free(argv[0]);
+ if (argv) {
+ if (argv[0])
+ free(argv[0]);
free((Address) argv);
}
if (buffer)
ch = *++p;
break;
}
-
+
switch (ch = *++p) {
case '\0':
case '\n':
/*
* 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 *
/*
* 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
/*-
*-----------------------------------------------------------------------
* 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.
return m;
}
while (*w++ != '\0');
-
+
return NULL;
}
* Substitute '%' on the pattern with len characters from src.
* If the pattern does not contain a '%' prepend len characters
* from src.
- *
+ *
* Results:
* None
*
-/* $OpenBSD: suff.c,v 1.4 1996/09/02 16:04:19 briggs Exp $ */
-/* $NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $ */
+/* $OpenBSD: suff.c,v 1.5 1996/11/30 21:09:04 millert Exp $ */
+/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 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.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)suff.c 5.6 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-static char rcsid[] = "$OpenBSD: suff.c,v 1.4 1996/09/02 16:04:19 briggs Exp $";
+static char rcsid[] = "$OpenBSD: suff.c,v 1.5 1996/11/30 21:09:04 millert Exp $";
#endif
#endif /* not lint */
#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 */
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 *));
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
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);
(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",
ClientData dummy; /* Node for transformation */
{
GNode *gn = (GNode *) gnp;
-
+
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
Lst_IsEmpty(gn->children))
{
* XXX: Only do this after a Suff_ClearSuffixes?
*/
Lst_ForEach (transforms, SuffRebuildGraph, (ClientData)s);
- }
+ }
}
/*-
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
* 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
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
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') {
if (DEBUG(SUFF)) {
printf("Wildcard expanding \"%s\"...", cgn->name);
}
-
+
if (ln != NILLNODE) {
Suff *s = (Suff *)Lst_Datum(ln);
* 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.
}
gn = (GNode *)Lst_Datum(ln);
-
+
if (DEBUG(SUFF)) {
printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
}
* Record last child for expansion purposes
*/
ln = Lst_Last(tGn->children);
-
+
/*
* Pass the buck to Make_HandleUse to apply the rule
*/
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.
*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
(void)Lst_AtEnd(mem->parents, (ClientData)gn);
gn->unmade += 1;
}
-
+
/*
* Copy in the variables from the member node to this one.
*/
eoname = gn->name + strlen(gn->name);
sopref = gn->name;
-
+
/*
* Begin at the beginning...
*/
if (ln != NILLNODE) {
int prefLen; /* Length of the prefix */
Src *targ;
-
+
/*
* Allocate a Src structure to which things can be transformed
*/
#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.
*/
if (Lst_IsEmpty(targs) && suffNull != NULL) {
if (DEBUG(SUFF)) {
- printf("\tNo known suffix on %s. Using .NULL suffix: ", gn->name);
+ printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
}
-
+
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
targ->suff = suffNull;
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.
* 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);
free(gn->path);
gn->path = estrdup(gn->name);
}
-
+
goto sfnd_return;
}
* 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;
targ->node->type |= OP_DEPS_FOUND;
Var_Set(PREFIX, targ->pref, targ->node);
-
+
Var_Set(TARGET, targ->node->name, targ->node);
}
}
Lst_Concat(slst, srcs, LST_CONCLINK);
Lst_Concat(slst, targs, LST_CONCLINK);
}
-
-
+
+
/*-
*-----------------------------------------------------------------------
* Suff_FindDeps --
Suff_FindDeps(gn)
GNode *gn;
{
-
+
SuffFindDeps(gn, srclist);
while (SuffRemoveSrc(srclist))
continue;
} 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) {
*/
LstNode ln;
Suff *s;
-
+
ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP);
if (gn->suffix)
gn->suffix->refCount--;
int flag;
printf ("# `%s' [%d] ", s->name, s->refCount);
-
+
flags = s->flags;
if (flags) {
fputs (" (", stdout);
-/* $OpenBSD: targ.c,v 1.4 1996/09/02 16:04:20 briggs Exp $ */
-/* $NetBSD: targ.c,v 1.9 1996/08/30 17:59:43 thorpej Exp $ */
+/* $OpenBSD: targ.c,v 1.5 1996/11/30 21:09:05 millert Exp $ */
+/* $NetBSD: targ.c,v 1.10 1996/11/06 17:59:27 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.
*
*/
#ifndef lint
-/* from: static char sccsid[] = "@(#)targ.c 5.9 (Berkeley) 3/1/91"; */
-static char *rcsid = "$Id: targ.c,v 1.4 1996/09/02 16:04:20 briggs Exp $";
+#if 0
+static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
+#else
+static char *rcsid = "$OpenBSD: targ.c,v 1.5 1996/11/30 21:09:05 millert Exp $";
+#endif
#endif /* not lint */
/*-
/*-
*-----------------------------------------------------------------------
* 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
/******************* 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
months[parts->tm_mon], parts->tm_mday, 1900 + parts->tm_year);
return(buf);
}
-
+
/*-
*-----------------------------------------------------------------------
* Targ_PrintType --
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
Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
fputc ('\n', stdout);
}
-
+
printf("%-16s", gn->name);
switch (gn->type & OP_OPMASK) {
case OP_DEPENDS:
-/* $OpenBSD: util.c,v 1.4 1996/09/02 16:04:21 briggs Exp $ */
-/* $NetBSD: util.c,v 1.5 1995/11/22 17:40:17 christos Exp $ */
+/* $OpenBSD: util.c,v 1.5 1996/11/30 21:09:06 millert Exp $ */
+/* $NetBSD: util.c,v 1.9 1996/11/11 15:16:10 christos Exp $ */
/*
* Missing stuff from OS's
- *
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: util.c,v 1.4 1996/09/02 16:04:21 briggs Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.5 1996/11/30 21:09:06 millert Exp $";
#endif
#include <stdio.h>
extern char *sys_errlist[];
char *
-strerror(e)
- int e;
+strerror(e)
+ int e;
{
static char buf[100];
if (e < 0 || e >= sys_nerr) {
const char *str;
{
size_t len;
+ char *p;
if (str == NULL)
return NULL;
int
setenv(name, value, dum)
- const char *name;
+ const char *name;
const char *value;
int dum;
{
if (ptr == NULL)
return -1;
-
+
p = ptr;
- while (*name)
+ while (*name)
*p++ = *name++;
*p++ = '=';
- while (*value)
+ while (*value)
*p++ = *value++;
*p = '\0';
/* look in the parent for the entry with the same inode */
if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) {
/* Parent has same device. No need to stat every member */
- for (d = readdir(dp); d != NULL; d = readdir(dp))
+ for (d = readdir(dp); d != NULL; d = readdir(dp))
if (d->d_fileno == st_cur.st_ino)
break;
}
else {
- /*
- * Parent has a different device. This is a mount point so we
- * need to stat every member
+ /*
+ * Parent has a different device. This is a mount point so we
+ * need to stat every member
*/
for (d = readdir(dp); d != NULL; d = readdir(dp)) {
if (ISDOT(d->d_name) || ISDOTDOT(d->d_name))
}
/* check if we found it yet */
if (st_next.st_ino == st_cur.st_ino &&
- DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev))
+ DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev))
break;
}
}
-/* $OpenBSD: var.c,v 1.4 1996/09/02 16:04:22 briggs Exp $ */
-/* $NetBSD: var.c,v 1.14 1996/08/13 16:42:25 christos Exp $ */
+/* $OpenBSD: var.c,v 1.5 1996/11/30 21:09:07 millert Exp $ */
+/* $NetBSD: var.c,v 1.15 1996/11/06 17:59:29 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.
*
#ifndef lint
#if 0
-static char sccsid[] = "@(#)var.c 5.7 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: var.c,v 1.4 1996/09/02 16:04:22 briggs Exp $";
+static char rcsid[] = "$OpenBSD: var.c,v 1.5 1996/11/30 21:09:07 millert Exp $";
#endif
#endif /* not lint */
#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));
if ((env = getenv (name)) != NULL) {
int len;
-
+
v = (Var *) emalloc(sizeof(Var));
v->name = estrdup(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) &&
* 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.
* 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.
* 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.
VarPattern *pattern = (VarPattern *) patternp;
wordLen = strlen(word);
- if ((pattern->flags & VAR_NO_SUB) == 0) {
+ if (1) { /* substitute in each word of the variable */
/*
- * Still substituting -- break it down into simple anchored cases
+ * Break substitution down into simple anchored cases
* and if none of them fits, perform the general substitution case.
*/
if ((pattern->flags & VAR_MATCH_START) &&
* 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
- * subsititutions correctly, etc. When the loop is done, any
+ * substitutions 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.
Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);
wordLen -= (cp - word) + pattern->leftLen;
word = cp + pattern->leftLen;
- if (wordLen == 0) {
- done = TRUE;
- }
- if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
+ if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0){
done = TRUE;
- pattern->flags |= VAR_NO_SUB;
}
} else {
done = TRUE;
return ((Buf_Size(buf) != origSize) || addSpace);
}
/*
- * 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.
+ * Common code for anchored 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:
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);
* 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.
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,
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'))
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
* but nested invocations in them...
*/
val = (char *)Buf_GetAll(v->val, (int *)NULL);
-
+
if (str[3] == 'D') {
val = VarModify(val, VarHead, (ClientData)0);
} else {
}
}
}
-
+
if (v == (Var *)NIL) {
if ((((tstr-str) == 3) ||
((((tstr-str) == 4) && (str[3] == 'F' ||
((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) ||
dynamic = TRUE;
}
}
-
+
if (!haveModifier) {
/*
* No modifiers -- have specification length so we can return
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:
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);
}
}
buf = Buf_Init(0);
-
+
/*
* Pass through the lhs looking for 1) escaped delimiters,
* '$'s and backslashes (place the escaped character in
char *cp2;
int len;
Boolean freeIt;
-
+
cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
if (freeIt) {
}
Buf_AddByte(buf, (Byte)'\0');
-
+
/*
* If lhs didn't end with the delimiter, complain and
* return NULL
* 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 == '\\') &&
}
Buf_AddByte(buf, (Byte)'\0');
-
+
/*
* If didn't end in delimiter character, complain
*/
*/
VarPattern pattern;
Boolean eqFound;
-
+
pattern.flags = 0;
eqFound = FALSE;
/*
cp++;
}
if (*cp == endc && eqFound) {
-
+
/*
* Now we break this sucker into the lhs and
* rhs. We must null terminate them of course.
pattern.lhs = tstr;
pattern.leftLen = cp - tstr;
*cp++ = '\0';
-
+
pattern.rhs = cp;
cnt = 1;
while (cnt) {
}
pattern.rightLen = cp - pattern.rhs;
*cp = '\0';
-
+
/*
* SYSV modifications happen through the whole
* string. Note the pattern is anchored at the end.
Error ("Unknown modifier '%c'\n", *tstr);
for (cp = tstr+1;
*cp != ':' && *cp != endc && *cp != '\0';
- cp++)
+ cp++)
continue;
termc = *cp;
newStr = var_Error;
if (DEBUG(VAR)) {
printf("Result is \"%s\"\n", newStr);
}
-
+
if (*freePtr) {
free (str);
}
*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 {
/*
* 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
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;
if (!expand)
continue;
}
-
+
val = Var_Parse (str, ctxt, undefErr, &length, &doFree);
/*
* advance the string pointer.
*/
str += length;
-
+
/*
* Copy all the characters from the variable value straight
* into the new string.
}
}
}
-
+
Buf_AddByte (buf, '\0');
str = (char *)Buf_GetAll (buf, (int *)NULL);
Buf_Destroy (buf, FALSE);
* None
*
* Side Effects:
- * The VAR_CMD and VAR_GLOBAL contexts are created
+ * The VAR_CMD and VAR_GLOBAL contexts are created
*-----------------------------------------------------------------------
*/
void
{
Lst_Destroy(allVars, VarDelete);
}
-
+
/****************** PRINT DEBUGGING INFO *****************/
static int