diff options
60 files changed, 1138 insertions, 991 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 9293eb20a1a..94197df72bb 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,9 +1,9 @@ -# $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 \ diff --git a/usr.bin/make/Makefile.boot b/usr.bin/make/Makefile.boot index 66299345ee6..02bb006d454 100644 --- a/usr.bin/make/Makefile.boot +++ b/usr.bin/make/Makefile.boot @@ -1,20 +1,37 @@ -# $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 diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 400cd61fccd..ab0ecf65a38 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,9 +1,9 @@ -/* $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. * @@ -41,10 +41,9 @@ #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 */ @@ -105,6 +104,7 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.8 1996/10/17 19:08:44 niklas Exp $"; #include <utime.h> #include <stdio.h> #include <stdlib.h> +#include <fcntl.h> #include "make.h" #include "hash.h" #include "dir.h" @@ -150,8 +150,8 @@ ArchFree(ap) Arch *a = (Arch *) ap; Hash_Search search; Hash_Entry *entry; - - /* Free memory from hash entries */ + + /* Free memory from hash entries */ for (entry = Hash_EnumFirst(&a->members, &search); entry != (Hash_Entry *)NULL; entry = Hash_EnumNext(&search)) @@ -163,7 +163,7 @@ ArchFree(ap) Hash_DeleteTable(&a->members); free((Address) a); } - + /*- @@ -199,7 +199,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) * variable substitution performed on it */ libName = *linePtr; - + subLibName = FALSE; for (cp = libName; *cp != '(' && *cp != '\0'; cp++) { @@ -211,14 +211,14 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) int length; Boolean freeIt; char *result; - + result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt); if (result == var_Error) { return(FAILURE); } else { subLibName = TRUE; } - + if (freeIt) { free(result); } @@ -230,7 +230,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) if (subLibName) { libName = Var_Subst(NULL, libName, ctxt, TRUE); } - + for (;;) { /* @@ -306,7 +306,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) char *buf; char *sacrifice; char *oldMemName = memName; - + memName = Var_Subst(NULL, memName, ctxt, TRUE); /* @@ -352,7 +352,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) Dir_Expand(memName, dirSearchPath, members); while (!Lst_IsEmpty(members)) { member = (char *)Lst_DeQueue(members); - + sprintf(nameBuf, "%s(%s)", libName, member); free(member); gn = Targ_FindNode (nameBuf, TARG_CREATE); @@ -391,7 +391,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) if (doSubst) { free(memName); } - + *cp = saveChar; } @@ -537,7 +537,7 @@ ArchStatMember (archive, member, hash) if (arch == (FILE *) NULL) { return ((struct ar_hdr *) NULL); } - + /* * We use the ARMAG string to make sure this is an archive we * can handle... @@ -554,7 +554,7 @@ ArchStatMember (archive, member, hash) 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) { /* @@ -796,7 +796,7 @@ ArchFindMember (archive, member, arhPtr, mode) if (arch == (FILE *) NULL) { return ((FILE *) NULL); } - + /* * We use the ARMAG string to make sure this is an archive we * can handle... @@ -821,7 +821,7 @@ ArchFindMember (archive, member, arhPtr, mode) if (len > sizeof (arhPtr->ar_name)) { tlen = sizeof (arhPtr->ar_name); } - + while (fread ((char *)arhPtr, sizeof (struct ar_hdr), 1, arch) == 1) { if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof (arhPtr->ar_fmag) ) != 0) { /* @@ -1086,7 +1086,7 @@ Arch_MemMTime (gn) /*- *----------------------------------------------------------------------- * Arch_FindLib -- - * Search for a library along the given search path. + * Search for a library along the given search path. * * Results: * None. @@ -1150,7 +1150,7 @@ Arch_FindLib (gn, path) * opinion we should not bother with the TOC at all since * this is used by 'ar' rules that affect the data contents * of the archive, not by ranlib rules, which affect the - * TOC. + * TOC. * * Results: * TRUE if the library is out-of-date. FALSE otherwise. @@ -1165,7 +1165,7 @@ Arch_LibOODate (gn) GNode *gn; /* The library's graph node */ { Boolean oodate; - + if (OP_NOP(gn->type) && Lst_IsEmpty(gn->children)) { oodate = FALSE; } else if ((gn->mtime > now) || (gn->mtime < gn->cmtime) || !gn->mtime) { @@ -1239,3 +1239,37 @@ Arch_End () { 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; +} diff --git a/usr.bin/make/bit.h b/usr.bin/make/bit.h index 0e5be5afd99..09fb78fcffe 100644 --- a/usr.bin/make/bit.h +++ b/usr.bin/make/bit.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -99,5 +99,5 @@ extern Boolean Bit_Intersect(); extern Boolean Bit_Union(); extern Boolean Bit_AnySet(); extern int *Bit_Expand(); - + #endif /* _BIT */ diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c index ed7ee422806..7d95b9d86d3 100644 --- a/usr.bin/make/buf.c +++ b/usr.bin/make/buf.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -131,7 +131,7 @@ void Buf_AddBytes (bp, numBytes, bytesPtr) register Buffer bp; int numBytes; - Byte *bytesPtr; + const Byte *bytesPtr; { BufExpand (bp, numBytes); @@ -293,7 +293,7 @@ Buf_GetBytes (bp, numBytes, bytesPtr) int numBytes; Byte *bytesPtr; { - + if (bp->inPtr - bp->outPtr < numBytes) { numBytes = bp->inPtr - bp->outPtr; } @@ -330,7 +330,7 @@ Buf_GetAll (bp, numBytesPtr) if (numBytesPtr != (int *)NULL) { *numBytesPtr = bp->inPtr - bp->outPtr; } - + return (bp->outPtr); } @@ -343,7 +343,7 @@ Buf_GetAll (bp, numBytesPtr) * None. * * Side Effects: - * The bytes are discarded. + * The bytes are discarded. * *----------------------------------------------------------------------- */ @@ -435,9 +435,34 @@ Buf_Destroy (buf, freeData) Buffer buf; /* Buffer to destroy */ Boolean freeData; /* TRUE if the data should be destroyed as well */ { - + if (freeData) { free ((char *)buf->buffer); } free ((char *)buf); } + +/*- + *----------------------------------------------------------------------- + * Buf_ReplaceLastByte -- + * Replace the last byte in a buffer. + * + * Results: + * None. + * + * Side Effects: + * If the buffer was empty intially, then a new byte will be added. + * Otherwise, the last byte is overwritten. + * + *----------------------------------------------------------------------- + */ +void +Buf_ReplaceLastByte (buf, byte) + Buffer buf; /* buffer to augment */ + Byte byte; /* byte to be written */ +{ + if (buf->inPtr == buf->outPtr) + Buf_AddByte(buf, byte); + else + *(buf->inPtr - 1) = byte; +} diff --git a/usr.bin/make/buf.h b/usr.bin/make/buf.h index e345eadf032..52899a37a2c 100644 --- a/usr.bin/make/buf.h +++ b/usr.bin/make/buf.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 */ /*- @@ -69,7 +69,7 @@ typedef struct Buffer { #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)); @@ -79,5 +79,6 @@ void Buf_Discard __P((Buffer, int)); int Buf_Size __P((Buffer)); Buffer Buf_Init __P((int)); void Buf_Destroy __P((Buffer, Boolean)); +void Buf_ReplaceLastByte __P((Buffer, Byte)); #endif /* _BUF_H */ diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 7534cbeea71..8cffa92288c 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -108,7 +108,7 @@ CompatInterrupt (signo) int signo; { GNode *gn; - + if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) { char *p1; char *file = Var_Value (TARGET, curTarg, &p1); @@ -169,7 +169,7 @@ CompatRunCommand (cmdp, gnp) char *cmd = (char *) cmdp; GNode *gn = (GNode *) gnp; - /* + /* * Avoid clobbered variable warnings by forcing the compiler * to ``unregister'' variables */ @@ -189,7 +189,7 @@ CompatRunCommand (cmdp, gnp) * command? In any case, we warn the user that the command expanded to * nothing (is this the right thing to do?). */ - + if (*cmdStart == '\0') { free(cmdStart); Error("%s expands to empty string", cmd); @@ -218,7 +218,7 @@ CompatRunCommand (cmdp, gnp) while (isspace((unsigned char)*cmd)) cmd++; - + /* * Search for meta characters in the command. If there are no meta * characters, there's no need to execute a shell to execute the @@ -244,7 +244,7 @@ CompatRunCommand (cmdp, gnp) if (noExecute) { return (0); } - + if (*cp != '\0') { /* * If *cp isn't the null character, we hit a "meta" character and @@ -269,7 +269,7 @@ CompatRunCommand (cmdp, gnp) av = brk_string(cmd, &argc, TRUE); av += 1; } - + local = TRUE; /* @@ -291,7 +291,7 @@ CompatRunCommand (cmdp, gnp) } free(cmdStart); Lst_Replace (cmdNode, (ClientData) NULL); - + /* * The child is off and running. Now all we can do is wait... */ @@ -302,7 +302,7 @@ CompatRunCommand (cmdp, gnp) break; } } - + if (stat > -1) { if (WIFSTOPPED(reason)) { status = WSTOPSIG(reason); /* stopped */ @@ -314,9 +314,9 @@ CompatRunCommand (cmdp, gnp) } else { status = WTERMSIG(reason); /* signaled */ printf ("*** Signal %d", status); - } + } + - if (!WIFEXITED(reason) || (status != 0)) { if (errCheck) { gn->made = ERROR; @@ -393,7 +393,7 @@ CompatMake (gnp, pgnp) if (p1) free(p1); } - + /* * All the children were made ok. Now cmtime contains the modification * time of the newest child, we need to find out if we exist and when @@ -427,7 +427,7 @@ CompatMake (gnp, pgnp) * Make_DoAllVar(). */ Make_DoAllVar(gn); - + /* * Alter our type to tell if errors should be ignored or things * should not be printed so CompatRunCommand knows what to do. @@ -568,7 +568,7 @@ CompatMake (gnp, pgnp) return (0); } - + /*- *----------------------------------------------------------------------- * Compat_Run -- @@ -620,6 +620,10 @@ Compat_Run(targs) gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); if (gn != NILGNODE) { Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); + if (gn->made == ERROR) { + printf("\n\nStop.\n"); + exit(1); + } } } diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index a9ecacd441d..6842efbf87d 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -101,6 +101,7 @@ typedef enum { * Structures to handle elegantly the different forms of #if's. The * last two fields are stored in condInvert and condDefProc, respectively. */ +static void CondPushBack __P((Token)); static int CondGetArg __P((char **, char **, char *, Boolean)); static Boolean CondDoDefined __P((int, char *)); static int CondStrMatch __P((ClientData, ClientData)); @@ -117,18 +118,19 @@ static struct If { 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 */ @@ -217,7 +219,7 @@ CondGetArg (linePtr, argPtr, func, parens) * long. Why 16? Why not? */ buf = Buf_Init(16); - + while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) { if (*cp == '$') { /* @@ -260,7 +262,7 @@ CondGetArg (linePtr, argPtr, func, parens) */ cp++; } - + *linePtr = cp; return (argLen); } @@ -434,7 +436,7 @@ CondDoTarget (argLen, arg) * * Side Effects: * Can change 'value' even if string is not a valid number. - * + * * *----------------------------------------------------------------------- */ @@ -624,10 +626,10 @@ do_string_compare: buf = Buf_Init(0); qt = *rhs == '"' ? 1 : 0; - - for (cp = &rhs[qt]; - ((qt && (*cp != '"')) || - (!qt && strchr(" \t)", *cp) == NULL)) && + + for (cp = &rhs[qt]; + ((qt && (*cp != '"')) || + (!qt && strchr(" \t)", *cp) == NULL)) && (*cp != '\0'); cp++) { if ((*cp == '\\') && (cp[1] != '\0')) { /* @@ -639,7 +641,7 @@ do_string_compare: } else if (*cp == '$') { int len; Boolean freeIt; - + cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt); if (cp2 != var_Error) { Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); @@ -693,7 +695,7 @@ do_string_compare: if (*rhs == '$') { int len; Boolean freeIt; - + string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt); if (string == var_Error) { right = 0.0; @@ -721,7 +723,7 @@ do_string_compare: } } } - + if (DEBUG(COND)) { printf("left = %f, right = %f, op = %.2s\n", left, right, op); @@ -765,11 +767,11 @@ error: 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 @@ -831,8 +833,8 @@ error: if (val == var_Error) { t = Err; } else { - /* - * A variable is empty when it just contains + /* + * A variable is empty when it just contains * spaces... 4/15/92, christos */ char *p; @@ -1114,7 +1116,7 @@ Cond_Eval (line) } else { isElse = FALSE; } - + /* * Figure out what sort of conditional it is -- what its default * function is, etc. -- by looking in the table of valid "ifs" @@ -1174,16 +1176,16 @@ Cond_Eval (line) */ condDefProc = ifp->defProc; condInvert = ifp->doNot; - + line += ifp->formlen; - + while (*line == ' ' || *line == '\t') { line++; } - + condExpr = line; condPushBack = None; - + switch (CondE(TRUE)) { case True: if (CondToken(TRUE) == EndOfFile) { diff --git a/usr.bin/make/config.h b/usr.bin/make/config.h index e70f7ced11f..f35ab4b4e47 100644 --- a/usr.bin/make/config.h +++ b/usr.bin/make/config.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 */ @@ -95,12 +95,12 @@ #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 /* @@ -118,4 +118,3 @@ # define RANLIBMAG "__.SYMDEF" # endif #endif -/*#define POSIX*/ diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 7e3ae7b0023..79622bcedf1 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -218,7 +218,7 @@ Dir_Init () dirSearchPath = Lst_Init (FALSE); openDirectories = Lst_Init (FALSE); Hash_InitTable(&mtimes, 0); - + /* * Since the Path structure is placed on both openDirectories and * the path we give Dir_AddDir (which in this case is openDirectories), @@ -298,7 +298,7 @@ Dir_HasWildcards (name) char *name; /* name to check */ { register char *cp; - + for (cp = name; *cp; cp++) { switch(*cp) { case '{': @@ -334,12 +334,12 @@ DirMatchFiles (pattern, p, expansions) Path *p; /* Directory to search */ Lst expansions; /* Place to store the results */ { - Hash_Search search; /* Index into the directory's table */ + Hash_Search search; /* Index into the directory's table */ Hash_Entry *entry; /* Current entry in the table */ Boolean isDot; /* TRUE if the directory being searched is . */ - + isDot = (*p->name == '.' && p->name[1] == '\0'); - + for (entry = Hash_EnumFirst(&p->files, &search); entry != (Hash_Entry *)NULL; entry = Hash_EnumNext(&search)) @@ -558,7 +558,7 @@ Dir_Expand (word, path, expansions) if (DEBUG(DIR)) { printf("expanding \"%s\"...", word); } - + cp = strchr(word, '{'); if (cp) { DirExpandCurly(word, cp, path, expansions); @@ -632,7 +632,7 @@ Dir_Expand (word, path, expansions) * First the files in dot */ DirMatchFiles(word, dot, expansions); - + /* * Then the files in every other directory on the path. */ @@ -677,7 +677,7 @@ Dir_FindFile (name, path) Boolean hasSlash; /* true if 'name' contains a / */ struct stat stb; /* Buffer for stat, if necessary */ Hash_Entry *entry; /* Entry for mtimes table */ - + /* * Find the final component of the name and note whether it has a * slash in it (the name, I mean) @@ -690,7 +690,7 @@ Dir_FindFile (name, path) hasSlash = FALSE; cp = name; } - + if (DEBUG(DIR)) { printf("Searching for %s...", name); } @@ -709,7 +709,7 @@ Dir_FindFile (name, path) dot->hits += 1; return (estrdup (name)); } - + if (Lst_Open (path) == FAILURE) { if (DEBUG(DIR)) { printf("couldn't open path, file not found\n"); @@ -717,7 +717,7 @@ Dir_FindFile (name, path) misses += 1; return ((char *) NULL); } - + /* * We look through all the directories on the path seeking one which * contains the final component of the given name and whose final @@ -782,7 +782,7 @@ Dir_FindFile (name, path) } } } - + /* * We didn't find the file on any existing members of the directory. * If the name doesn't contain a slash, that means it doesn't exist. @@ -802,10 +802,10 @@ Dir_FindFile (name, path) misses += 1; return ((char *) NULL); } - + if (*name != '/') { Boolean checkedDot = FALSE; - + if (DEBUG(DIR)) { printf("failed. Trying subdirectories..."); } @@ -824,15 +824,15 @@ Dir_FindFile (name, path) 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 @@ -847,7 +847,7 @@ Dir_FindFile (name, path) *cp = '\0'; Dir_AddDir (path, file); *cp = '/'; - + /* * Save the modification time so if it's needed, we don't have * to fetch it again. @@ -865,7 +865,7 @@ Dir_FindFile (name, path) free (file); } } - + if (DEBUG(DIR)) { printf("failed. "); } @@ -882,7 +882,7 @@ Dir_FindFile (name, path) return(NULL); } } - + /* * Didn't find it that way, either. Sigh. Phase 3. Add its directory * onto the search path in any case, just in case, then look for the @@ -904,7 +904,7 @@ Dir_FindFile (name, path) cp[-1] = '\0'; Dir_AddDir (path, name); cp[-1] = '/'; - + bigmisses += 1; ln = Lst_Last (path); if (ln == NILLNODE) { @@ -912,7 +912,7 @@ Dir_FindFile (name, path) } else { p = (Path *) Lst_Datum (ln); } - + if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { return (estrdup (name)); } else { @@ -922,7 +922,7 @@ Dir_FindFile (name, path) if (DEBUG(DIR)) { printf("Looking for \"%s\"...", name); } - + bigmisses += 1; entry = Hash_FindEntry(&mtimes, name); if (entry != (Hash_Entry *)NULL) { @@ -952,7 +952,7 @@ Dir_FindFile (name, path) * Dir_MTime -- * Find the modification time of the file described by gn along the * search path dirSearchPath. - * + * * Results: * The modification time or 0 if it doesn't exist * @@ -970,7 +970,7 @@ Dir_MTime (gn) char *fullName; /* the full pathname of name */ struct stat stb; /* buffer for finding the mod time */ Hash_Entry *entry; - + if (gn->type & OP_ARCHV) { return Arch_MTime (gn); } else if (gn->path == (char *)NULL) { @@ -978,7 +978,7 @@ Dir_MTime (gn) } else { fullName = gn->path; } - + if (fullName == (char *)NULL) { fullName = estrdup(gn->name); } @@ -1008,7 +1008,7 @@ Dir_MTime (gn) if (fullName && gn->path == (char *)NULL) { gn->path = fullName; } - + gn->mtime = stb.st_mtime; return (gn->mtime); } @@ -1024,7 +1024,7 @@ Dir_MTime (gn) * none * * Side Effects: - * A structure is added to the list and the directory is + * A structure is added to the list and the directory is * read and hashed. *----------------------------------------------------------------------- */ @@ -1038,7 +1038,7 @@ Dir_AddDir (path, name) register Path *p; /* pointer to new Path structure */ DIR *d; /* for reading directory */ register struct dirent *dp; /* entry in directory */ - + ln = Lst_Find (openDirectories, (ClientData)name, DirFindName); if (ln != NILLNODE) { p = (Path *)Lst_Datum (ln); @@ -1051,20 +1051,20 @@ Dir_AddDir (path, name) printf("Caching %s...", name); fflush(stdout); } - + if ((d = opendir (name)) != (DIR *) NULL) { p = (Path *) emalloc (sizeof (Path)); p->name = estrdup (name); p->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 */ /* @@ -1137,9 +1137,9 @@ Dir_MakeFlags (flag, path) char *tstr; /* the current directory preceded by 'flag' */ LstNode ln; /* the node of the current directory */ Path *p; /* the structure describing the current directory */ - + str = estrdup (""); - + if (Lst_Open (path) == SUCCESS) { while ((ln = Lst_Next (path)) != NILLNODE) { p = (Path *) Lst_Datum (ln); @@ -1148,7 +1148,7 @@ Dir_MakeFlags (flag, path) } Lst_Close (path); } - + return (str); } @@ -1210,7 +1210,7 @@ Dir_ClearPath(path) Dir_Destroy((ClientData) p); } } - + /*- *----------------------------------------------------------------------- @@ -1249,7 +1249,7 @@ Dir_PrintDirectories() { LstNode ln; Path *p; - + printf ("#*** Directory Cache:\n"); printf ("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n", hits, misses, nearmisses, bigmisses, @@ -1268,7 +1268,7 @@ Dir_PrintDirectories() static int DirPrintDir (p, dummy) ClientData p; ClientData dummy; -{ +{ printf ("%s ", ((Path *) p)->name); return (dummy ? 0 : 0); } diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h index e0bf9bf2767..3e47c6b64fa 100644 --- a/usr.bin/make/dir.h +++ b/usr.bin/make/dir.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 -- diff --git a/usr.bin/make/extern.h b/usr.bin/make/extern.h index ae704a55127..92903a76439 100644 --- a/usr.bin/make/extern.h +++ b/usr.bin/make/extern.h @@ -1,9 +1,9 @@ -/* $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. * @@ -38,7 +38,7 @@ * 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 */ @@ -51,6 +51,7 @@ void Arch_FindLib __P((GNode *, Lst)); 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)); diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 5c16d2dedc7..bce82a1e381 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,5 +1,5 @@ -/* $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. @@ -36,9 +36,9 @@ #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 */ @@ -68,7 +68,7 @@ static char rcsid[] = "$OpenBSD: for.c,v 1.2 1996/06/26 05:36:30 deraadt Exp $"; * The trick is to look for the matching end inside for for loop * To do that, we count the current nesting level of the for loops. * and the .endfor statements, accumulating all the statements between - * the initial .for loop and the matching .endfor; + * the initial .for loop and the matching .endfor; * then we evaluate the for loop for each variable in the varlist. */ @@ -132,18 +132,18 @@ For_Eval (line) !isspace((unsigned char) ptr[3])) return FALSE; ptr += 3; - + /* * we found a for loop, and now we are going to parse it. */ while (*ptr && isspace((unsigned char) *ptr)) ptr++; - + /* * Grab the variable */ buf = Buf_Init(0); - for (wrd = ptr; *ptr && !isspace((unsigned char) *ptr); ptr++) + for (wrd = ptr; *ptr && !isspace((unsigned char) *ptr); ptr++) continue; Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd); @@ -176,12 +176,12 @@ For_Eval (line) */ forLst = Lst_Init(FALSE); buf = Buf_Init(0); - sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); + sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); #define ADDWORD() \ Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \ Buf_AddByte(buf, (Byte) '\0'), \ - Lst_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++) @@ -197,12 +197,12 @@ For_Eval (line) } if (DEBUG(FOR)) (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub); - if (ptr - wrd > 0) + if (ptr - wrd > 0) ADDWORD(); else Buf_Destroy(buf, TRUE); free((Address) sub); - + forBuf = Buf_Init(0); forLevel++; return 1; @@ -263,7 +263,7 @@ ForExec(namep, argp) Var_Set(arg->var, name, VAR_GLOBAL); if (DEBUG(FOR)) (void) fprintf(stderr, "--- %s = %s\n", arg->var, name); - Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len), + Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len), VAR_GLOBAL, FALSE)); Var_Delete(arg->var, VAR_GLOBAL); diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c index f6b6c0dcfe9..56d49c83d7c 100644 --- a/usr.bin/make/hash.c +++ b/usr.bin/make/hash.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -65,7 +65,7 @@ static char rcsid[] = "$OpenBSD: hash.c,v 1.2 1996/06/26 05:36:31 deraadt Exp $" static void RebuildTable __P((Hash_Table *)); -/* +/* * The following defines the ratio of # entries to # buckets * at which we rebuild the table to make it larger. */ @@ -74,12 +74,12 @@ static void RebuildTable __P((Hash_Table *)); /* *--------------------------------------------------------- - * + * * Hash_InitTable -- * * This routine just sets up the hash table. * - * Results: + * Results: * None. * * Side Effects: @@ -101,7 +101,7 @@ Hash_InitTable(t, numBuckets) register struct Hash_Entry **hp; /* - * Round up the size to a power of two. + * Round up the size to a power of two. */ if (numBuckets <= 0) i = 16; @@ -126,7 +126,7 @@ Hash_InitTable(t, numBuckets) * and frees up the memory space it occupied (except for * the space in the Hash_Table structure). * - * Results: + * Results: * None. * * Side Effects: @@ -152,7 +152,7 @@ Hash_DeleteTable(t) /* * Set up the hash table to cause memory faults on any future access - * attempts until re-initialization. + * attempts until re-initialization. */ t->bucketPtr = NULL; } @@ -244,7 +244,7 @@ Hash_CreateEntry(t, key, newPtr) /* * The desired entry isn't there. Before allocating a new entry, * expand the table if necessary (and this changes the resulting - * bucket chain). + * bucket chain). */ if (t->numEntries >= rebuildLimit * t->size) RebuildTable(t); @@ -308,7 +308,7 @@ Hash_DeleteEntry(t, e) * This procedure sets things up for a complete search * of all entries recorded in the hash table. * - * Results: + * Results: * The return value is the address of the first entry in * the hash table, or NULL if the table is empty. * @@ -323,7 +323,7 @@ Hash_DeleteEntry(t, e) Hash_Entry * Hash_EnumFirst(t, searchPtr) Hash_Table *t; /* Table to be searched. */ - register Hash_Search *searchPtr;/* Area in which to keep state + register Hash_Search *searchPtr;/* Area in which to keep state * about search.*/ { searchPtr->tablePtr = t; @@ -352,7 +352,7 @@ Hash_EnumFirst(t, searchPtr) Hash_Entry * Hash_EnumNext(searchPtr) - register Hash_Search *searchPtr; /* Area used to keep state about + register Hash_Search *searchPtr; /* Area used to keep state about search. */ { register Hash_Entry *e; @@ -386,7 +386,7 @@ Hash_EnumNext(searchPtr) * This local routine makes a new hash table that * is larger than the old one. * - * Results: + * Results: * None. * * Side Effects: diff --git a/usr.bin/make/hash.h b/usr.bin/make/hash.h index b3fd39ebfc7..92111641e2a 100644 --- a/usr.bin/make/hash.h +++ b/usr.bin/make/hash.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 -- @@ -50,7 +50,7 @@ #ifndef _HASH #define _HASH -/* +/* * The following defines one entry in the hash table. */ @@ -72,7 +72,7 @@ typedef struct Hash_Table { int mask; /* Used to select bits for hashing. */ } Hash_Table; -/* +/* * The following structure is used by the searching routines * to record where we are in the search. */ @@ -88,22 +88,22 @@ typedef struct Hash_Search { */ /* - * ClientData Hash_GetValue(h) - * Hash_Entry *h; + * ClientData Hash_GetValue(h) + * Hash_Entry *h; */ #define Hash_GetValue(h) ((h)->clientData) -/* - * Hash_SetValue(h, val); - * Hash_Entry *h; - * char *val; +/* + * Hash_SetValue(h, val); + * Hash_Entry *h; + * char *val; */ #define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val)) -/* - * Hash_Size(n) returns the number of words in an object of n bytes +/* + * Hash_Size(n) returns the number of words in an object of n bytes */ #define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int)) diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index f1e45d28d41..ee5f6b00956 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,5 +1,5 @@ -/* $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. @@ -41,9 +41,9 @@ #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 */ @@ -111,7 +111,6 @@ static char rcsid[] = "$OpenBSD: job.c,v 1.5 1996/09/02 16:04:11 briggs Exp $"; #include <fcntl.h> #include <errno.h> #include <utime.h> -#include <signal.h> #include <stdio.h> #include <string.h> #include <signal.h> @@ -122,7 +121,7 @@ static char rcsid[] = "$OpenBSD: job.c,v 1.5 1996/09/02 16:04:11 briggs Exp $"; #include "pathnames.h" #ifdef REMOTE #include "rmt.h" -# define STATIC +# define STATIC #else # define STATIC static #endif @@ -130,7 +129,7 @@ static char rcsid[] = "$OpenBSD: job.c,v 1.5 1996/09/02 16:04:11 briggs Exp $"; 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? */ @@ -138,7 +137,7 @@ 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! */ @@ -167,7 +166,7 @@ static int numCommands; /* The number of commands actually printed * tfile is the name of a file into which all shell commands are put. It is * used over by removing it before the child shell is executed. The XXXXX in * the string are replaced by the pid of the make process in a 5-character - * field with leading zeroes. + * field with leading zeroes. */ static char tfile[] = TMPPAT; @@ -255,7 +254,7 @@ STATIC char *targFmt; /* Format string to use to head output from a * 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 @@ -272,7 +271,7 @@ STATIC Lst stoppedJobs; /* Lst of Job structures describing # 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 @@ -310,6 +309,7 @@ static void JobExec __P((Job *, char **)); 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)); @@ -348,7 +348,7 @@ JobCondPassSig(jobp, signop) * 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); @@ -369,7 +369,7 @@ JobCondPassSig(jobp, signop) * * Side Effects: * We die by the same signal. - * + * *----------------------------------------------------------------------- */ static void @@ -378,7 +378,7 @@ JobPassSig(signo) { sigset_t nmask, omask; struct sigaction act; - + if (DEBUG(JOB)) { (void) fprintf(stdout, "JobPassSig(%d) called.\n", signo); (void) fflush(stdout); @@ -395,14 +395,14 @@ JobPassSig(signo) } 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. @@ -455,7 +455,7 @@ JobCmpPid(job, pid) ClientData job; /* job to examine */ ClientData pid; /* process id desired */ { - return( *(int *) pid - ((Job *) job)->pid); + return *(int *) pid - ((Job *) job)->pid; } #ifdef REMOTE @@ -463,7 +463,7 @@ JobCmpPid(job, pid) *----------------------------------------------------------------------- * 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 @@ -526,18 +526,18 @@ JobPrintCommand(cmdp, jobp) char *cmdStart; /* Start of expanded command */ LstNode cmdNode; /* Node for replacing the command */ char *cmd = (char *) cmdp; - Job *job = (Job *) jobp; + Job *job = (Job *) jobp; noSpecials = (noExecute && !(job->node->type & OP_MAKE)); 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)) { \ @@ -622,7 +622,7 @@ JobPrintCommand(cmdp, jobp) } 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. */ @@ -634,9 +634,9 @@ JobPrintCommand(cmdp, jobp) errOff = FALSE; } } - + DBPRINTF(cmdTemplate, cmd); - + if (errOff) { /* * If echoing is already off, there's no point in issuing the @@ -731,9 +731,9 @@ JobClose(job) * 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. *----------------------------------------------------------------------- */ @@ -777,7 +777,7 @@ JobFinish(job, status) * 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." @@ -795,14 +795,14 @@ JobFinish(job, status) */ 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 @@ -848,7 +848,8 @@ JobFinish(job, status) 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); @@ -861,7 +862,7 @@ JobFinish(job, status) } 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)) { @@ -949,7 +950,7 @@ JobFinish(job, status) } else { done = TRUE; } - + if (done && (aborting != ABORT_ERROR) && @@ -988,7 +989,7 @@ JobFinish(job, status) */ aborting = ABORT_ERROR; } - + if ((aborting == ABORT_ERROR) && Job_Empty()) { /* * If we are aborting and the job table is now empty, we finish. @@ -1027,7 +1028,7 @@ Job_Touch(gn, silent) */ return; } - + if (!silent) { (void) fprintf(stdout, "touch %s\n", gn->name); (void) fflush(stdout); @@ -1059,7 +1060,7 @@ Job_Touch(gn, silent) (void) lseek(streamID, 0L, L_SET); (void) write(streamID, &c, 1); } - + (void) close(streamID); } else { (void) fprintf(stdout, "*** couldn't touch %s: %s", @@ -1073,7 +1074,7 @@ Job_Touch(gn, silent) /*- *----------------------------------------------------------------------- * Job_CheckCommands -- - * Make sure the given node has all the commands it needs. + * Make sure the given node has all the commands it needs. * * Results: * TRUE if the commands list is/was ok. @@ -1087,14 +1088,14 @@ Boolean 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; @@ -1117,7 +1118,7 @@ Job_CheckCommands(gn, abortProc) * 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"; @@ -1147,13 +1148,13 @@ Job_CheckCommands(gn, abortProc) * * 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); @@ -1181,10 +1182,10 @@ JobExec(job, argv) char **argv; { int cpid; /* ID of new child */ - + if (DEBUG(JOB)) { int i; - + (void) fprintf(stdout, "Running %s %sly\n", job->node->name, job->flags&JOB_REMOTE?"remote":"local"); (void) fprintf(stdout, "\tCommand: "); @@ -1194,10 +1195,10 @@ JobExec(job, argv) (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. */ @@ -1206,7 +1207,7 @@ JobExec(job, argv) MESSAGE(stdout, job->node); lastNode = job->node; } - + #ifdef RMT_NO_EXEC if (job->flags & JOB_REMOTE) { goto jobExecFinish; @@ -1219,14 +1220,14 @@ JobExec(job, argv) /* * 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 @@ -1245,7 +1246,7 @@ JobExec(job, argv) } /* * 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. */ @@ -1269,7 +1270,7 @@ JobExec(job, argv) #ifdef REMOTE if (job->flags & JOB_REMOTE) { Rmt_Exec(shellPath, argv, FALSE); - } else + } else #endif /* REMOTE */ (void) execv(shellPath, argv); @@ -1289,7 +1290,7 @@ JobExec(job, argv) * stream to watch in the outputs mask */ job->curPos = 0; - + #ifdef RMT_WILL_WATCH Rmt_Watch(job->inPipe, JobLocalInput, job); #else @@ -1319,7 +1320,7 @@ JobExec(job, argv) } #ifdef RMT_NO_EXEC -jobExecFinish: +jobExecFinish: #endif /* * Now the job is actually running, add it to the table. @@ -1335,7 +1336,7 @@ jobExecFinish: *----------------------------------------------------------------------- * JobMakeArgv -- * Create the argv needed to execute the shell for a given job. - * + * * * Results: * @@ -1350,7 +1351,7 @@ JobMakeArgv(job, argv) { int argc; static char args[10]; /* For merged arguments */ - + argv[0] = shellName; argc = 1; @@ -1389,7 +1390,7 @@ JobMakeArgv(job, argv) /*- *----------------------------------------------------------------------- * JobRestart -- - * Restart a job that stopped for some reason. + * Restart a job that stopped for some reason. * * Results: * None. @@ -1406,7 +1407,7 @@ JobRestart(job) #ifdef REMOTE int host; #endif - + if (job->flags & JOB_REMIGRATE) { if ( #ifdef REMOTE @@ -1480,7 +1481,7 @@ JobRestart(job) job->rmtID = host; } #endif - + (void)Lst_AtEnd(jobs, (ClientData)job); nJobs += 1; if (nJobs == maxJobs) { @@ -1497,10 +1498,10 @@ JobRestart(job) * the 'exit' flag of the commandShell is used to cause it to exit * upon receiving an error. If the JOB_SILENT flag is clear, the * 'echo' flag of the commandShell is used to get it to start echoing - * as soon as it starts processing commands. + * as soon as it starts processing commands. */ char *argv[4]; - + JobMakeArgv(job, argv); if (DEBUG(JOB)) { @@ -1509,7 +1510,7 @@ JobRestart(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 @@ -1581,14 +1582,14 @@ JobRestart(job) /* * 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); @@ -1604,7 +1605,7 @@ JobRestart(job) 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"); @@ -1640,7 +1641,7 @@ JobRestart(job) *----------------------------------------------------------------------- * JobStart -- * Start a target-creation process going for the target described - * by the graph node gn. + * by the graph node gn. * * Results: * JOB_ERROR if there was an error in the commands, JOB_FINISHED @@ -1704,9 +1705,9 @@ JobStart(gn, flags, previous) } 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? @@ -1719,7 +1720,7 @@ JobStart(gn, flags, previous) if (!cmdsOK) { DieHorribly(); } - + job->cmdFILE = fopen(tfile, "w+"); if (job->cmdFILE == NULL) { Punt("Could not open %s", tfile); @@ -1748,7 +1749,7 @@ JobStart(gn, flags, previous) cmdsOK = FALSE; } else { LstNode ln = Lst_Next(gn->commands); - + if ((ln == NILLNODE) || JobPrintCommand((ClientData) Lst_Datum(ln), (ClientData) job)) @@ -1777,7 +1778,7 @@ JobStart(gn, flags, previous) */ 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? @@ -1821,7 +1822,7 @@ JobStart(gn, flags, previous) } /* - * If we're not supposed to execute a shell, don't. + * If we're not supposed to execute a shell, don't. */ if (noExec) { /* @@ -1916,14 +1917,14 @@ JobStart(gn, flags, previous) /* * 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); @@ -1933,7 +1934,7 @@ JobStart(gn, flags, previous) } 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; @@ -1947,7 +1948,7 @@ JobStart(gn, flags, previous) return(JOB_RUNNING); } -static char * +static char * JobOutput(job, cp, endp, msg) register Job *job; register char *cp, *endp; @@ -2010,7 +2011,7 @@ JobOutput(job, cp, endp, msg) * 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: @@ -2030,13 +2031,13 @@ JobDoOutput(job, finish) 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. @@ -2044,7 +2045,7 @@ JobDoOutput(job, finish) end_loop: gotNL = FALSE; fbuf = FALSE; - + nRead = read(job->inPipe, &job->outBuf[job->curPos], JOB_BUFSIZE - job->curPos); if (nRead < 0) { @@ -2057,7 +2058,7 @@ end_loop: } /* - * 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. @@ -2069,11 +2070,11 @@ end_loop: } else if (nr == 0) { finish = FALSE; } - + /* * Look for the last newline in the bytes we just got. If there is * one, break out of the loop with 'i' as its index and gotNL set - * TRUE. + * TRUE. */ max = job->curPos + nr; for (i = job->curPos + nr - 1; i >= job->curPos; i--) { @@ -2087,13 +2088,13 @@ end_loop: job->outBuf[i] = ' '; } } - + if (!gotNL) { job->curPos += nr; if (job->curPos == JOB_BUFSIZE) { /* * If we've run out of buffer space, we have no choice - * but to print the stuff. sigh. + * but to print the stuff. sigh. */ fbuf = TRUE; i = job->curPos; @@ -2103,18 +2104,18 @@ end_loop: /* * 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, @@ -2132,9 +2133,9 @@ end_loop: } 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 @@ -2146,10 +2147,11 @@ end_loop: if (finish) { /* * If the finish flag is true, we must loop until we hit - * end-of-file on the pipe. This is guaranteed to happen eventually - * since the other end of the pipe is now closed(we closed it - * explicitly and the child has exited). When we do get an EOF, - * finish will be set FALSE and we'll fall through and out. + * end-of-file on the pipe. This is guaranteed to happen + * eventually since the other end of the pipe is now closed + * (we closed it explicitly and the child has exited). When + * we do get an EOF, finish will be set FALSE and we'll fall + * through and out. */ goto end_loop; } @@ -2230,7 +2232,7 @@ Job_CatchChildren(block) if (nLocal == 0) { return; } - + while ((pid = waitpid((pid_t) -1, &status, (block?0:WNOHANG)|WUNTRACED)) > 0) { @@ -2238,7 +2240,7 @@ Job_CatchChildren(block) (void) fprintf(stdout, "Process %d exited or stopped.\n", pid); (void) fflush(stdout); } - + jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid); @@ -2246,13 +2248,13 @@ Job_CatchChildren(block) 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 { @@ -2287,12 +2289,12 @@ Job_CatchChildren(block) * 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. @@ -2327,7 +2329,7 @@ Job_CatchOutput() * 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) { @@ -2429,7 +2431,7 @@ Job_Init(maxproc, maxlocal) } else { targFmt = TARG_FMT; } - + if (shellPath == NULL) { /* * The user didn't specify a shell to use, so we are using the @@ -2468,7 +2470,7 @@ Job_Init(maxproc, maxlocal) /* * 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) @@ -2485,7 +2487,7 @@ Job_Init(maxproc, maxlocal) (void) signal(SIGWINCH, JobPassSig); } #endif - + begin = Targ_FindNode(".BEGIN", TARG_NOCREATE); if (begin != NILGNODE) { @@ -2659,7 +2661,7 @@ Job_ParseShell(line) words = brk_string(line, &wordCount, TRUE); memset((Address)&newShell, 0, sizeof(newShell)); - + /* * Parse the specification by keyword */ @@ -2715,7 +2717,7 @@ Job_ParseShell(line) } } 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 @@ -2744,7 +2746,7 @@ Job_ParseShell(line) if (commandShell->echoOn && commandShell->echoOff) { commandShell->hasEchoCtl = TRUE; } - + if (!commandShell->hasErrCtl) { if (commandShell->errCheck == NULL) { commandShell->errCheck = ""; @@ -2753,7 +2755,7 @@ Job_ParseShell(line) commandShell->ignErr = "%s\n"; } } - + /* * Do not free up the words themselves, since they might be in use by the * shell specification... @@ -2784,7 +2786,7 @@ JobInterrupt(runINTERRUPT, signo) 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); @@ -2822,7 +2824,7 @@ JobInterrupt(runINTERRUPT, signo) 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); } @@ -2858,7 +2860,7 @@ JobInterrupt(runINTERRUPT, signo) */ 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); } @@ -2914,13 +2916,13 @@ JobInterrupt(runINTERRUPT, signo) *----------------------------------------------------------------------- * 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. *----------------------------------------------------------------------- */ @@ -2992,9 +2994,9 @@ Job_AbortAll() 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); @@ -3003,7 +3005,7 @@ Job_AbortAll() /* * 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) { @@ -3019,7 +3021,7 @@ Job_AbortAll() #endif /* RMT_WANTS_SIGNALS */ } } - + /* * Catch as many children as want to report in at first, then give up */ diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index bf6ac28e953..bd57cebdd07 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 */ /*- @@ -54,14 +54,14 @@ /* * The SEL_ constants determine the maximum amount of time spent in select * before coming out to see if a child has finished. SEL_SEC is the number of - * seconds and SEL_USEC is the number of micro-seconds + * seconds and SEL_USEC is the number of micro-seconds */ #define SEL_SEC 0 #define SEL_USEC 500000 /*- - * Job Table definitions. + * Job Table definitions. * * Each job has several things associated with it: * 1) The process id of the child shell @@ -82,11 +82,11 @@ * 6) An identifier provided by and for the exclusive use of the * Rmt module. * 7) A word of flags which determine how the module handles errors, - * echoing, etc. for the job + * echoing, etc. for the job * * The job "table" is kept as a linked Lst in 'jobs', with the number of * active jobs maintained in the 'nJobs' variable. At no time will this - * exceed the value of 'maxJobs', initialized by the Job_Init function. + * exceed the value of 'maxJobs', initialized by the Job_Init function. * * When a job is finished, the Make_Update function is called on each of the * parents of the node which was just remade. This takes care of the upward @@ -108,7 +108,7 @@ typedef struct Job { * if we can't export it and maxLocal is 0 */ #define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing * commands */ -#define JOB_REMOTE 0x010 /* Job is running remotely */ +#define JOB_REMOTE 0x010 /* Job is running remotely */ #define JOB_FIRST 0x020 /* Job is first job for the node */ #define JOB_REMIGRATE 0x040 /* Job needs to be remigrated */ #define JOB_RESTART 0x080 /* Job needs to be completely restarted */ @@ -196,7 +196,7 @@ typedef struct Shell { char *errCheck; /* string to turn error checking on */ char *ignErr; /* string to turn off error checking */ /* - * command-line flags + * command-line flags */ char *echo; /* echo commands */ char *exit; /* exit on error */ diff --git a/usr.bin/make/list.h b/usr.bin/make/list.h index e00496aaf08..593e3c8530a 100644 --- a/usr.bin/make/list.h +++ b/usr.bin/make/list.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 */ /* @@ -63,39 +63,39 @@ * to a list as a whole, the user keeps a pointer to the header; that * header is initialized by a call to List_Init(), which creates an empty * list given a pointer to a List_Links structure (described below). - * + * * The links are contained in a two-element structure called List_Links. * A list joins List_Links records (that is, each List_Links structure * points to other List_Links structures), but if the List_Links is the * first field within a larger structure, then the larger structures are * effectively linked together as follows: - * + * * header * (List_Links) first elt. second elt. - * ----------------- ----------------- ----------------- + * ----------------- ----------------- ----------------- * ..-> | nextPtr | ----> | List_Links | ----> | List_Links |----.. - * | - - - - - - - | | | | | + * | - - - - - - - | | | | | * ..-- | prevPtr | <---- | | <---- | |<---.. * ----------------- - --- --- --- - - --- --- --- - - * | rest of | | rest of | - * | structure | | structure | + * | rest of | | rest of | + * | structure | | structure | * | | | | - * | ... | | ... | - * ----------------- ----------------- - * + * | ... | | ... | + * ----------------- ----------------- + * * It is possible to link structures through List_Links fields that are * not at the beginning of the larger structure, but it is then necessary * to perform pointer arithmetic to find the beginning of the larger * structure, given a pointer to some point within it. - * + * * A typical structure might be something like: - * + * * typedef struct { * List_Links links; * char ch; * integer flags; * } EditChar; - * + * * Before an element is inserted in a list for the first time, it must * be initialized by calling the macro List_InitElement(). */ @@ -132,7 +132,7 @@ void List_Move(); /* move an element elsewhere in a list */ #define List_InitElement(elementPtr) \ (elementPtr)->prevPtr = (List_Links *) NIL; \ (elementPtr)->nextPtr = (List_Links *) NIL; - + /* * Macros for stepping through or selecting parts of lists */ @@ -145,10 +145,10 @@ void List_Move(); /* move an element elsewhere in a list */ * Macro to loop through a list and perform an operation on each member. * * Usage: LIST_FORALL(headerPtr, itemPtr) { - * / * + * / * * * operation on itemPtr, which points to successive members * * of the list - * * + * * * * It may be appropriate to first assign * * foobarPtr = (Foobar *) itemPtr; * * to refer to the entire Foobar structure. @@ -282,7 +282,7 @@ void List_Move(); /* move an element elsewhere in a list */ * LIST_ATFRONT(headerPtr) -- insert at front of list * LIST_ATREAR(headerPtr) -- insert at end of list * - * For example, + * For example, * * List_Insert(itemPtr, LIST_AFTER(otherPtr)); * diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index 1c5e48b2972..3f928128f54 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -1,5 +1,5 @@ -/* $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. @@ -38,7 +38,7 @@ * 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 */ /*- @@ -121,12 +121,12 @@ ClientData Lst_Datum __P((LstNode)); * Functions for entire lists */ /* Find an element in a list */ -LstNode Lst_Find __P((Lst, ClientData, +LstNode Lst_Find __P((Lst, ClientData, int (*)(ClientData, ClientData))); /* Find an element starting from somewhere */ LstNode Lst_FindFrom __P((Lst, LstNode, ClientData, int (*cProc)(ClientData, ClientData))); -/* +/* * See if the given datum is on the list. Returns the LstNode containing * the datum */ diff --git a/usr.bin/make/lst.lib/Makefile b/usr.bin/make/lst.lib/Makefile index ce6ae605150..88761d342a9 100644 --- a/usr.bin/make/lst.lib/Makefile +++ b/usr.bin/make/lst.lib/Makefile @@ -1,5 +1,5 @@ -# $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 \ diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c index 7ea02024a8a..bbb45def67b 100644 --- a/usr.bin/make/lst.lib/lstAppend.c +++ b/usr.bin/make/lst.lib/lstAppend.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -77,23 +77,23 @@ Lst_Append (l, ln, d) register List list; register ListNode lNode; register ListNode nLNode; - + if (LstValid (l) && (ln == NILLNODE && LstIsEmpty (l))) { goto ok; } - + if (!LstValid (l) || LstIsEmpty (l) || ! LstNodeValid (ln, l)) { return (FAILURE); } ok: - + list = (List)l; lNode = (ListNode)ln; PAlloc (nLNode, ListNode); nLNode->datum = d; nLNode->useCount = nLNode->flags = 0; - + if (lNode == NilListNode) { if (list->isCirc) { nLNode->nextPtr = nLNode->prevPtr = nLNode; @@ -104,17 +104,17 @@ Lst_Append (l, ln, d) } else { nLNode->prevPtr = lNode; nLNode->nextPtr = lNode->nextPtr; - + lNode->nextPtr = nLNode; if (nLNode->nextPtr != NilListNode) { nLNode->nextPtr->prevPtr = nLNode; } - + if (lNode == list->lastPtr) { list->lastPtr = nLNode; } } - + return (SUCCESS); } diff --git a/usr.bin/make/lst.lib/lstAtEnd.c b/usr.bin/make/lst.lib/lstAtEnd.c index 182d563e801..e21edd19e89 100644 --- a/usr.bin/make/lst.lib/lstAtEnd.c +++ b/usr.bin/make/lst.lib/lstAtEnd.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -51,7 +51,7 @@ static char rcsid[] = "$OpenBSD: lstAtEnd.c,v 1.2 1996/06/26 05:36:42 deraadt Ex */ #include "lstInt.h" - + /*- *----------------------------------------------------------------------- * Lst_AtEnd -- @@ -71,7 +71,7 @@ Lst_AtEnd (l, d) ClientData d; /* Datum to add */ { register LstNode end; - + end = Lst_Last (l); return (Lst_Append (l, end, d)); } diff --git a/usr.bin/make/lst.lib/lstAtFront.c b/usr.bin/make/lst.lib/lstAtFront.c index 0f9d84d1b3c..968bb9b8ad3 100644 --- a/usr.bin/make/lst.lib/lstAtFront.c +++ b/usr.bin/make/lst.lib/lstAtFront.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -72,7 +72,7 @@ Lst_AtFront (l, d) ClientData d; { register LstNode front; - + front = Lst_First (l); return (Lst_Insert (l, front, d)); } diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c index 5e60381a63b..19a0dee5abc 100644 --- a/usr.bin/make/lst.lib/lstClose.c +++ b/usr.bin/make/lst.lib/lstClose.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -75,7 +75,7 @@ Lst_Close (l) Lst l; /* The list to close */ { register List list = (List) l; - + if (LstValid(l) == TRUE) { list->isOpen = FALSE; list->atEnd = Unknown; diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c index b2a74476308..2e3d20e9ea3 100644 --- a/usr.bin/make/lst.lib/lstConcat.c +++ b/usr.bin/make/lst.lib/lstConcat.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -156,7 +156,7 @@ Lst_Concat (l1, l2, flags) /* * Finish bookkeeping. The last new element becomes the last element - * of list one. + * of list one. */ list1->lastPtr = last; @@ -180,4 +180,4 @@ Lst_Concat (l1, l2, flags) return (SUCCESS); } - + diff --git a/usr.bin/make/lst.lib/lstDatum.c b/usr.bin/make/lst.lib/lstDatum.c index 93df0beee50..411b8eba670 100644 --- a/usr.bin/make/lst.lib/lstDatum.c +++ b/usr.bin/make/lst.lib/lstDatum.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstDeQueue.c b/usr.bin/make/lst.lib/lstDeQueue.c index 21e0f6f2591..09843863392 100644 --- a/usr.bin/make/lst.lib/lstDeQueue.c +++ b/usr.bin/make/lst.lib/lstDeQueue.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -72,12 +72,12 @@ Lst_DeQueue (l) { ClientData rd; register ListNode tln; - + tln = (ListNode) Lst_First (l); if (tln == NilListNode) { return ((ClientData) NIL); } - + rd = tln->datum; if (Lst_Remove (l, (LstNode)tln) == FAILURE) { return ((ClientData) NIL); diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c index 3f23577f5a5..169d25f35d2 100644 --- a/usr.bin/make/lst.lib/lstDestroy.c +++ b/usr.bin/make/lst.lib/lstDestroy.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -75,7 +75,7 @@ Lst_Destroy (l, freeProc) register ListNode ln; register ListNode tln = NilListNode; register List list = (List)l; - + if (l == NILLST || ! l) { /* * Note the check for l == (Lst)0 to catch uninitialized static Lst's. @@ -104,6 +104,6 @@ Lst_Destroy (l, freeProc) free ((Address)ln); } } - + free ((Address)l); } diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c index d509f7e8421..0d2772df449 100644 --- a/usr.bin/make/lst.lib/lstDupl.c +++ b/usr.bin/make/lst.lib/lstDupl.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -75,7 +75,7 @@ Lst_Duplicate (l, copyProc) register Lst nl; register ListNode ln; register List list = (List)l; - + if (!LstValid (l)) { return (NILLST); } @@ -101,6 +101,6 @@ Lst_Duplicate (l, copyProc) ln = ln->nextPtr; } } - + return (nl); } diff --git a/usr.bin/make/lst.lib/lstEnQueue.c b/usr.bin/make/lst.lib/lstEnQueue.c index 657dfb66c3e..1ba605b9637 100644 --- a/usr.bin/make/lst.lib/lstEnQueue.c +++ b/usr.bin/make/lst.lib/lstEnQueue.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -74,7 +74,7 @@ Lst_EnQueue (l, d) if (LstValid (l) == FALSE) { return (FAILURE); } - + return (Lst_Append (l, Lst_Last(l), d)); } diff --git a/usr.bin/make/lst.lib/lstFind.c b/usr.bin/make/lst.lib/lstFind.c index 76e7ea8e36d..5b8a28b6335 100644 --- a/usr.bin/make/lst.lib/lstFind.c +++ b/usr.bin/make/lst.lib/lstFind.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c index 6a2dcc3bd1f..b96765265c1 100644 --- a/usr.bin/make/lst.lib/lstFindFrom.c +++ b/usr.bin/make/lst.lib/lstFindFrom.c @@ -1,9 +1,9 @@ -/* $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. @@ -38,8 +38,11 @@ */ #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 */ /*- @@ -73,13 +76,13 @@ Lst_FindFrom (l, ln, d, cProc) { register ListNode tln; Boolean found = FALSE; - + if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) { return (NILLNODE); } - + tln = (ListNode)ln; - + do { if ((*cProc) (tln->datum, d) == 0) { found = TRUE; @@ -88,7 +91,7 @@ Lst_FindFrom (l, ln, d, cProc) tln = tln->nextPtr; } } while (tln != (ListNode)ln && tln != NilListNode); - + if (found) { return ((LstNode)tln); } else { diff --git a/usr.bin/make/lst.lib/lstFirst.c b/usr.bin/make/lst.lib/lstFirst.c index 3e50796cfaf..c1991800932 100644 --- a/usr.bin/make/lst.lib/lstFirst.c +++ b/usr.bin/make/lst.lib/lstFirst.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstForEach.c b/usr.bin/make/lst.lib/lstForEach.c index 05c1b0872c3..981b8ca550c 100644 --- a/usr.bin/make/lst.lib/lstForEach.c +++ b/usr.bin/make/lst.lib/lstForEach.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstForEachFrom.c b/usr.bin/make/lst.lib/lstForEachFrom.c index 5b62fab89e1..6e6ffff6d6a 100644 --- a/usr.bin/make/lst.lib/lstForEachFrom.c +++ b/usr.bin/make/lst.lib/lstForEachFrom.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -58,7 +58,7 @@ static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.2 1996/06/26 05:36:50 dera * 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. @@ -73,7 +73,7 @@ void 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; @@ -81,19 +81,19 @@ Lst_ForEachFrom (l, ln, proc, d) register ListNode next; Boolean done; int result; - + if (!LstValid (list) || LstIsEmpty (list)) { return; } - + do { /* * Take care of having the current element deleted out from under * us. */ - + next = tln->nextPtr; - + (void) tln->useCount++; result = (*proc) (tln->datum, d); (void) tln->useCount--; @@ -106,7 +106,7 @@ Lst_ForEachFrom (l, ln, proc, d) */ done = (next == tln->nextPtr && (next == NilListNode || next == list->firstPtr)); - + next = tln->nextPtr; if (tln->flags & LN_DELETED) { @@ -114,6 +114,6 @@ Lst_ForEachFrom (l, ln, proc, d) } tln = next; } while (!result && !LstIsEmpty(list) && !done); - + } diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c index f1ea3687c29..bbead4bf4c6 100644 --- a/usr.bin/make/lst.lib/lstInit.c +++ b/usr.bin/make/lst.lib/lstInit.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -70,14 +70,14 @@ Lst_Init(circ) Boolean circ; /* TRUE if the list should be made circular */ { register List nList; - + PAlloc (nList, List); - + nList->firstPtr = NilListNode; nList->lastPtr = NilListNode; nList->isOpen = FALSE; nList->isCirc = circ; nList->atEnd = Unknown; - + return ((Lst)nList); } diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c index 95e9a0ddc35..194f65b0bb5 100644 --- a/usr.bin/make/lst.lib/lstInsert.c +++ b/usr.bin/make/lst.lib/lstInsert.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -83,17 +83,17 @@ Lst_Insert (l, ln, d) */ if (LstValid (l) && (LstIsEmpty (l) && ln == NILLNODE)) goto ok; - + if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) { return (FAILURE); } - + ok: PAlloc (nLNode, ListNode); - + nLNode->datum = d; nLNode->useCount = nLNode->flags = 0; - + if (ln == NILLNODE) { if (list->isCirc) { nLNode->prevPtr = nLNode->nextPtr = nLNode; @@ -104,17 +104,17 @@ Lst_Insert (l, ln, d) } else { nLNode->prevPtr = lNode->prevPtr; nLNode->nextPtr = lNode; - + if (nLNode->prevPtr != NilListNode) { nLNode->prevPtr->nextPtr = nLNode; } lNode->prevPtr = nLNode; - + if (lNode == list->firstPtr) { list->firstPtr = nLNode; } } - + return (SUCCESS); } - + diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h index d770d6f3711..aa4cba2c419 100644 --- a/usr.bin/make/lst.lib/lstInt.h +++ b/usr.bin/make/lst.lib/lstInt.h @@ -1,9 +1,9 @@ -/* $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. @@ -36,7 +36,7 @@ * 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 */ /*- diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c index 3505bac30c6..296d6ddd505 100644 --- a/usr.bin/make/lst.lib/lstIsAtEnd.c +++ b/usr.bin/make/lst.lib/lstIsAtEnd.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstIsEmpty.c b/usr.bin/make/lst.lib/lstIsEmpty.c index 4d50401c191..907adba101b 100644 --- a/usr.bin/make/lst.lib/lstIsEmpty.c +++ b/usr.bin/make/lst.lib/lstIsEmpty.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstLast.c b/usr.bin/make/lst.lib/lstLast.c index f9012cc14e9..87feb544384 100644 --- a/usr.bin/make/lst.lib/lstLast.c +++ b/usr.bin/make/lst.lib/lstLast.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstMember.c b/usr.bin/make/lst.lib/lstMember.c index 9cf2a98831b..679d04ae417 100644 --- a/usr.bin/make/lst.lib/lstMember.c +++ b/usr.bin/make/lst.lib/lstMember.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -64,7 +64,7 @@ Lst_Member (l, d) if (lNode == NilListNode) { return NILLNODE; } - + do { if (lNode->datum == d) { return (LstNode)lNode; diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c index 90e7e49d7c7..0fc297e4d01 100644 --- a/usr.bin/make/lst.lib/lstNext.c +++ b/usr.bin/make/lst.lib/lstNext.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -78,14 +78,14 @@ Lst_Next (l) { register ListNode tln; register List list = (List)l; - + if ((LstValid (l) == FALSE) || (list->isOpen == FALSE)) { return (NILLNODE); } - + list->prevPtr = list->curPtr; - + if (list->curPtr == NilListNode) { if (list->atEnd == Unknown) { /* @@ -115,7 +115,7 @@ Lst_Next (l) list->atEnd = Middle; } } - + return ((LstNode)tln); } diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c index 532c833d298..ef7d44d764d 100644 --- a/usr.bin/make/lst.lib/lstOpen.c +++ b/usr.bin/make/lst.lib/lstOpen.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c index 4e8ffce1814..3efdbc5760b 100644 --- a/usr.bin/make/lst.lib/lstRemove.c +++ b/usr.bin/make/lst.lib/lstRemove.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ @@ -79,7 +79,7 @@ Lst_Remove (l, ln) !LstNodeValid (ln, l)) { return (FAILURE); } - + /* * unlink it from the list */ @@ -89,7 +89,7 @@ Lst_Remove (l, ln) if (lNode->prevPtr != NilListNode) { lNode->prevPtr->nextPtr = lNode->nextPtr; } - + /* * if either the firstPtr or lastPtr of the list point to this node, * adjust them accordingly @@ -122,7 +122,7 @@ Lst_Remove (l, ln) if (list->firstPtr == lNode) { list->firstPtr = NilListNode; } - + /* * note that the datum is unmolested. The caller must free it as * necessary and as expected. @@ -132,7 +132,7 @@ Lst_Remove (l, ln) } else { lNode->flags |= LN_DELETED; } - + return (SUCCESS); } diff --git a/usr.bin/make/lst.lib/lstReplace.c b/usr.bin/make/lst.lib/lstReplace.c index 8c8ce83741f..122a68c5541 100644 --- a/usr.bin/make/lst.lib/lstReplace.c +++ b/usr.bin/make/lst.lib/lstReplace.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/lst.lib/lstSucc.c b/usr.bin/make/lst.lib/lstSucc.c index be0ceaaa4d7..435720957bf 100644 --- a/usr.bin/make/lst.lib/lstSucc.c +++ b/usr.bin/make/lst.lib/lstSucc.c @@ -1,9 +1,9 @@ -/* $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. @@ -39,9 +39,9 @@ #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 */ diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index b3caf3ee098..f588e7a82f5 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,9 +1,9 @@ -/* $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. * @@ -40,17 +40,16 @@ */ #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 */ @@ -87,7 +86,9 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.8 1996/09/02 16:04:13 briggs Exp $"; #include <sys/resource.h> #include <sys/signal.h> #include <sys/stat.h> +#ifndef MACHINE #include <sys/utsname.h> +#endif #include <sys/wait.h> #include <errno.h> #include <fcntl.h> @@ -116,6 +117,8 @@ Boolean allPrecious; /* .PRECIOUS given on line by itself */ static Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ +static Boolean printVars; /* print value of one or more vars */ +static Lst variables; /* list of variables to print */ int maxJobs; /* -j argument */ static int maxLocal; /* -L argument */ Boolean compatMake; /* -B argument */ @@ -131,8 +134,10 @@ Boolean oldVars; /* variable substitution style */ 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 */ @@ -163,9 +168,9 @@ MainParseArgs(argc, argv) 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) { @@ -179,6 +184,12 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) { Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; + case 'V': + printVars = TRUE; + (void)Lst_AtEnd(variables, (ClientData)optarg); + Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); + Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); + break; case 'B': compatMake = TRUE; break; @@ -324,7 +335,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) { */ 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); @@ -375,6 +386,34 @@ Main_ParseArgLine(line) MainParseArgs(argc, argv); } +char * +chdir_verify_path(path, obpath) + char *path; + char *obpath; +{ + struct stat sb; + + if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) { + if (chdir(path)) { + (void)fprintf(stderr, "make warning: %s: %s.\n", + path, strerror(errno)); + return 0; + } + else { + if (path[0] != '/') { + (void) snprintf(obpath, MAXPATHLEN, "%s/%s", + curdir, path); + return obpath; + } + else + return path; + } + } + + return 0; +} + + /*- * main -- * The main function, for obvious reasons. Initializes variables @@ -400,11 +439,10 @@ main(argc, argv) Lst targs; /* target nodes to create -- passed to Make_Init */ Boolean outOfDate = TRUE; /* FALSE if all targets up to date */ struct stat sb, sa; - char *p, *p1, *path, *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; @@ -443,7 +481,7 @@ main(argc, argv) if ((pwd = getenv("PWD")) != NULL) { if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino && - sa.st_dev == sb.st_dev) + sa.st_dev == sb.st_dev) (void) strcpy(curdir, pwd); } @@ -457,6 +495,8 @@ main(argc, argv) */ if (!machine) { #ifndef MACHINE + struct utsname utsname; + if (uname(&utsname) == -1) { perror("make: uname"); exit(2); @@ -468,54 +508,39 @@ main(argc, argv) } /* - * 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; } @@ -523,6 +548,8 @@ main(argc, argv) create = Lst_Init(FALSE); makefiles = Lst_Init(FALSE); + printVars = FALSE; + variables = Lst_Init(FALSE); beSilent = FALSE; /* Print commands as executed */ ignoreErrors = FALSE; /* Pay attention to non-zero returns */ noExecute = FALSE; /* Execute all commands */ @@ -542,7 +569,7 @@ main(argc, argv) maxJobs = maxLocal; #endif compatMake = FALSE; /* No compat mode */ - + /* * Initialize the parsing, directory and variable modules to prepare @@ -585,7 +612,7 @@ main(argc, argv) #else Main_ParseArgLine(getenv("MAKE")); #endif - + MainParseArgs(argc, argv); /* @@ -624,7 +651,7 @@ main(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); @@ -658,10 +685,10 @@ main(argc, argv) ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile); if (ln != NILLNODE) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); - } else if (!ReadMakefile("makefile")) - (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) @@ -719,6 +746,21 @@ main(argc, argv) if (DEBUG(GRAPH1)) Targ_PrintGraph(1); + /* print the values of any variables requested by the user */ + if (printVars) { + LstNode ln; + + for (ln = Lst_First(variables); ln != NILLNODE; + ln = Lst_Succ(ln)) { + char *value = Var_Value((char *)Lst_Datum(ln), + VAR_GLOBAL, &p1); + + printf("%s\n", value ? value : ""); + if (p1) + free(p1); + } + } + /* * Have now read the entire graph and need to make a list of targets * to create. If none was given on the command line, we consult the @@ -729,7 +771,7 @@ main(argc, argv) 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 @@ -745,14 +787,16 @@ main(argc, argv) /* 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); @@ -785,9 +829,10 @@ main(argc, argv) * 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]; @@ -888,7 +933,7 @@ Cmd_Exec(cmd, err) */ (void) dup2(fds[1], 1); (void) close(fds[1]); - + (void) execv("/bin/sh", args); _exit(1); /*NOTREACHED*/ @@ -902,13 +947,13 @@ Cmd_Exec(cmd, err) * 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)); @@ -927,7 +972,7 @@ Cmd_Exec(cmd, err) 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) @@ -1043,7 +1088,7 @@ Fatal(va_alist) * a message and exits. * * Results: - * None + * None * * Side Effects: * All children are killed indiscriminately and the program Lib_Exits @@ -1099,10 +1144,10 @@ DieHorribly() /* * Finish -- * Called when aborting due to errors in child shell to signal - * abnormal exit. + * abnormal exit. * * Results: - * None + * None * * Side Effects: * The program exits @@ -1130,7 +1175,7 @@ emalloc(len) } /* - * emalloc -- + * estrdup -- * strdup, but die on error. */ char * @@ -1197,8 +1242,9 @@ static void 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); } diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 6a21aad0997..45975a87564 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -1,8 +1,8 @@ -.\" $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 @@ -32,9 +32,9 @@ .\" 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 @@ -42,7 +42,7 @@ .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 @@ -51,6 +51,7 @@ .Op Fl j Ar max_jobs .Op Fl m Ar directory .Ek +.Op Fl V Ar variable .Op Ar variable=value .Op Ar target ... .Sh DESCRIPTION @@ -77,7 +78,7 @@ and makefiles, please refer to .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 @@ -144,7 +145,7 @@ before each command line in the makefile. .It Fl j Ar max_jobs Specify the maximum number of jobs that .Nm make -may have running at any one time. Turns compatibility mode off, unless the +may have running at any one time. Turns compatibility mode off, unless the .Ar B flag is also specified. .It Fl k @@ -174,6 +175,16 @@ before each command line in the makefile. .It Fl t Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to-date. +.It Fl V Ar variable +Print +.Nm make Ns 's +idea of the value of +.Ar variable , +in the global context. +Do not build any targets. +Multiple instances of this option may be specified; +the variables will be printed one per line, +with a blank line for each null or undefined variable. .It Ar variable=value Set the value of the variable .Ar variable @@ -440,6 +451,28 @@ variable which is then entered into the environment for all programs which .Nm make executes. +.It Ev PWD +Alternate path to the current directory. +.Nm make +normally sets +.Ql Va .CURDIR +to the canonical path given by +.Xr getcwd 2 . +However, if the environment variable +.Ql Ev PWD +is set and gives a path to the current directory, then +.Nm make +sets +.Ql Va .CURDIR +to the value of +.Ql Ev PWD +instead. +.Ql Ev PWD +is set to the value of +.Ql Va .OBJDIR +for all programs which +.Nm make +executes. .El .Pp Variable expansion may be modified to select or modify each word of the @@ -527,23 +560,23 @@ This is the .At V style variable substitution. It must be the last modifier specified. -If +If .Ar old_string or .Ar new_string do not contain the pattern matching character .Ar % -then it is assumed that they are +then it is assumed that they are anchored at the end of each word, so only suffixes or entire -words may be replaced. Otherwise +words may be replaced. Otherwise .Ar % -is the substring of -.Ar old_string +is the substring of +.Ar old_string to be replaced in .Ar new_string .El .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS -Makefile inclusion, conditional structures and for loops reminiscent +Makefile inclusion, conditional structures and for loops reminiscent of the C programming language are provided in .Nm make . All such structures are identified by a line beginning with a single @@ -669,7 +702,7 @@ As in C, .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 @@ -745,14 +778,14 @@ In both cases this continues until a or .Ql Ic .endif is found. -.Pp +.Pp For loops are typically used to apply a set of rules to a list of files. The syntax of a for loop is: .Bl -tag -width Ds .It Xo .Ic \&.for -.Ar variable -.Ic in +.Ar variable +.Ic in .Ar expression .Xc .It Xo @@ -763,12 +796,12 @@ The syntax of a for loop is: .Xc .El After the for -.Ic expression -is evaluated, it is split into words. The +.Ic expression +is evaluated, it is split into words. The iteration .Ic variable -is successively set to each word, and substituted in the -.Ic make-rules +is successively set to each word, and substituted in the +.Ic make-rules inside the body of the for loop. .Sh COMMENTS Comments begin with a hash @@ -923,10 +956,12 @@ If no sources are specified, any previous specified suffices are deleted. .Sh ENVIRONMENT .Nm Make utilizes the following environment variables, if they exist: +.Ev MACHINE , .Ev MAKE , -.Ev MAKEFLAGS +.Ev MAKEFLAGS , +.Ev MAKEOBJDIR , and -.Ev MAKEOBJDIR . +.Ev PWD . .Sh FILES .Bl -tag -width /usr/share/mk -compact .It .depend diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 805c96d6f76..11887103adc 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,9 +1,9 @@ -/* $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. * @@ -41,10 +41,9 @@ #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 */ @@ -104,10 +103,10 @@ static int MakePrintStatus __P((ClientData, ClientData)); *----------------------------------------------------------------------- * Make_TimeStamp -- * Set the cmtime field of a parent node based on the mtime stamp in its - * child. Called from MakeOODate via Lst_ForEach. + * child. Called from MakeOODate via Lst_ForEach. * * Results: - * Always returns 0. + * Always returns 0. * * Side Effects: * The cmtime of the parent node will be changed if the mtime @@ -144,7 +143,7 @@ MakeTimeStamp (pgn, cgn) * will have been recreated. * * Results: - * TRUE if the node is out of date. FALSE otherwise. + * TRUE if the node is out of date. FALSE otherwise. * * Side Effects: * The mtime field of the node and the cmtime field of its parents @@ -195,7 +194,7 @@ Make_OODate (gn) 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..."); } @@ -342,7 +341,7 @@ Make_HandleUse (cgn, pgn) */ (void) Lst_Concat (pgn->commands, cgn->commands, LST_CONCNEW); } - + if (Lst_Open (cgn->children) == SUCCESS) { while ((ln = Lst_Next (cgn->children)) != NILLNODE) { gn = (GNode *)Lst_Datum (ln); @@ -355,7 +354,7 @@ Make_HandleUse (cgn, pgn) } Lst_Close (cgn->children); } - + pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM); /* @@ -384,7 +383,7 @@ MakeHandleUse (pgn, cgn) * Make_Update -- * Perform update on the parents of a node. Used by JobFinish once * a node has been dealt with and by MakeStartJobs if it finds an - * up-to-date node. + * up-to-date node. * * Results: * Always returns 0 @@ -483,7 +482,7 @@ Make_Update (cgn) } #endif } - + if (Lst_Open (cgn->parents) == SUCCESS) { while ((ln = Lst_Next (cgn->parents)) != NILLNODE) { pgn = (GNode *)Lst_Datum (ln); @@ -528,7 +527,7 @@ Make_Update (cgn) (void)Lst_EnQueue(toBeMade, (ClientData)succ); } } - + /* * Set the .PREFIX and .IMPSRC variables for all the implied parents * of this node. @@ -685,7 +684,7 @@ static Boolean MakeStartJobs () { register GNode *gn; - + while (!Job_Full() && !Lst_IsEmpty (toBeMade)) { gn = (GNode *) Lst_DeQueue (toBeMade); if (DEBUG(MAKE)) { @@ -718,7 +717,7 @@ MakeStartJobs () continue; } } - + numNodes--; if (Make_OODate (gn)) { if (DEBUG(MAKE)) { @@ -743,7 +742,7 @@ MakeStartJobs () */ Make_DoAllVar (gn); } - + Make_Update (gn); } } @@ -838,22 +837,22 @@ Make_Run (targs) examine = Lst_Duplicate(targs, NOCOPY); numNodes = 0; - + /* * Make an initial downward pass over the graph, marking nodes to be made * as we go down. We call Suff_FindDeps to find where a node is and * to get some children for it if it has none and also has no commands. * If the node is a leaf, we stick it on the toBeMade queue to * be looked at in a minute, otherwise we add its children to our queue - * and go on about our business. + * and go on about our business. */ while (!Lst_IsEmpty (examine)) { gn = (GNode *) Lst_DeQueue (examine); - + if (!gn->make) { gn->make = TRUE; numNodes++; - + /* * Apply any .USE rules before looking for implicit dependencies * to make sure everything has commands that should... @@ -868,7 +867,7 @@ Make_Run (targs) } } } - + Lst_Destroy (examine, NOFREE); if (queryFlag) { @@ -884,7 +883,7 @@ Make_Run (targs) * get started, nothing will happen since the remaining upward * traversal of the graph is performed by the routines in job.c upon * the finishing of a job. So we fill the Job table as much as we can - * before going into our loop. + * before going into our loop. */ (void) MakeStartJobs(); } @@ -913,6 +912,6 @@ Make_Run (targs) */ errors = ((errors == 0) && (numNodes != 0)); Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors); - + return (TRUE); } diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 49ea41fc2ae..aa21d9e6c8b 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,5 +1,5 @@ -/* $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 @@ -38,7 +38,7 @@ * 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 */ /*- @@ -60,7 +60,7 @@ #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 @@ -99,7 +99,7 @@ * 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 */ @@ -156,7 +156,7 @@ typedef struct GNode { } GNode; /* - * Manifest constants + * Manifest constants */ #define NILGNODE ((GNode *) NIL) @@ -167,7 +167,7 @@ typedef struct GNode { * placed in the 'type' field of each node. Any node that has * a 'type' field which satisfies the OP_NOP function was never never on * the lefthand side of an operator, though it may have been on the - * righthand side... + * righthand side... */ #define OP_DEPENDS 0x00000001 /* Execution of commands depends on * kids (:) */ @@ -222,7 +222,7 @@ typedef struct GNode { * do if the desired node(s) is (are) not found. If the TARG_CREATE constant * is given, a new, empty node will be created for the target, placed in the * table of all targets and its address returned. If TARG_NOCREATE is given, - * a NIL pointer will be returned. + * a NIL pointer will be returned. */ #define TARG_CREATE 0x01 /* create node if not found */ #define TARG_NOCREATE 0x00 /* don't create it */ @@ -234,7 +234,7 @@ typedef struct GNode { * If longer, it should be increased. Reducing it will cause more copying to * be done for longer lines, but will save space for shorter ones. In any * case, it ought to be a power of two simply because most storage allocation - * schemes allocate in powers of two. + * schemes allocate in powers of two. */ #define MAKE_BSIZE 256 /* starting size for expandable buffers */ @@ -245,7 +245,7 @@ typedef struct GNode { * be used instead of a space. If neither is given, no intervening characters * will be placed between the two strings in the final output. If the * STR_DOFREE bit is set, the two input strings will be freed before - * Str_Concat returns. + * Str_Concat returns. */ #define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ #define STR_DOFREE 0x02 /* free source strings after concatenation */ @@ -285,7 +285,7 @@ typedef struct GNode { #define DPREFIX "*D" /* directory part of PREFIX */ /* - * Global Variables + * Global Variables */ extern Lst create; /* The list of target names specified on the * command line. used to resolve #if diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index 5646bb15b56..56c4265241f 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -1,9 +1,9 @@ -/* $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. * @@ -38,7 +38,7 @@ * 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 */ @@ -51,6 +51,7 @@ void Arch_FindLib __P((GNode *, Lst)); 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)); diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 92c459231e6..1f354b53daf 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,9 +1,9 @@ -/* $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. * @@ -41,9 +41,9 @@ #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 */ @@ -276,7 +276,7 @@ ParseFindKeyword (str) end, cur; register int diff; - + start = 0; end = (sizeof(parseKeywords)/sizeof(parseKeywords[0])) - 1; @@ -399,7 +399,7 @@ ParseDoOp (gnp, opp) /* * If the dependency mask of the operator and the node don't match and * the node has actually had an operator applied to it before, and - * the operator actually has some dependency information in it, complain. + * the operator actually has some dependency information in it, complain. */ if (((op & OP_OPMASK) != (gn->type & OP_OPMASK)) && !OP_NOP(gn->type) && !OP_NOP(op)) @@ -419,7 +419,7 @@ ParseDoOp (gnp, opp) */ register GNode *cohort; LstNode ln; - + cohort = Targ_NewGN(gn->name); /* * Duplicate links to parents so graph traversal is simple. Perhaps @@ -443,14 +443,14 @@ ParseDoOp (gnp, opp) } /* * We don't want to nuke any previous flags (whatever they were) so we - * just OR the new operator into the old + * just OR the new operator into the old */ gn->type |= op; return (0); } -/*- +/*- *--------------------------------------------------------------------- * ParseAddDep -- * Check if the pair of GNodes given needs to be synchronized. @@ -463,7 +463,7 @@ ParseDoOp (gnp, opp) * * Side Effects: * A dependency can be added between the two nodes. - * + * *--------------------------------------------------------------------- */ int @@ -738,7 +738,7 @@ ParseDoDependency (line) curTargs = Lst_Init(FALSE); curSrcs = Lst_Init(FALSE); - + do { for (cp = line; *cp && !isspace (*cp) && @@ -786,11 +786,11 @@ ParseDoDependency (line) } } savec = *cp; - + if (!*cp) { /* * Ending a dependency line without an operator is a Bozo - * no-no + * no-no */ Parse_Error (PARSE_FATAL, "Need an operator"); return; @@ -803,7 +803,7 @@ ParseDoDependency (line) if (*line == '.' && isupper (line[1])) { /* * See if the target is a special target that must have it - * or its sources handled specially. + * or its sources handled specially. */ int keywd = ParseFindKeyword(line); if (keywd != -1) { @@ -811,7 +811,7 @@ ParseDoDependency (line) Parse_Error(PARSE_FATAL, "Mismatched special targets"); return; } - + specType = parseKeywords[keywd].spec; tOp = parseKeywords[keywd].op; @@ -871,7 +871,7 @@ ParseDoDependency (line) case NotParallel: { extern int maxJobs; - + maxJobs = 1; break; } @@ -891,7 +891,7 @@ ParseDoDependency (line) * modify. */ Lst path; - + specType = ExPath; path = Suff_GetPath (&line[5]); if (path == NILLST) { @@ -907,10 +907,10 @@ ParseDoDependency (line) } } } - + /* * Have word in line. Get or create its node and stick it at - * the end of the targets list + * the end of the targets list */ if ((specType == Not) && (*line != '\0')) { if (Dir_HasWildcards(line)) { @@ -921,9 +921,9 @@ ParseDoDependency (line) * Dir module could have added a directory to the path... */ Lst emptyPath = Lst_Init(FALSE); - + Dir_Expand(line, emptyPath, curTargs); - + Lst_Destroy(emptyPath, Dir_Destroy); } else { /* @@ -932,22 +932,22 @@ ParseDoDependency (line) */ (void)Lst_AtEnd(curTargs, (ClientData)line); } - + while(!Lst_IsEmpty(curTargs)) { char *targName = (char *)Lst_DeQueue(curTargs); - + if (!Suff_IsTransform (targName)) { gn = Targ_FindNode (targName, TARG_CREATE); } else { gn = Suff_AddTransform (targName); } - + (void)Lst_AtEnd (targets, (ClientData)gn); } } else if (specType == ExPath && *line != '.' && *line != '\0') { Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); } - + *cp = savec; /* * If it is a special type and not .PATH, it's the only target we @@ -955,7 +955,7 @@ ParseDoDependency (line) */ if (specType != Not && specType != ExPath) { Boolean warn = FALSE; - + while ((*cp != '!') && (*cp != ':') && *cp) { if (*cp != ' ' && *cp != '\t') { warn = TRUE; @@ -1022,7 +1022,7 @@ ParseDoDependency (line) Lst_ForEach (targets, ParseDoOp, (ClientData)&op); /* - * Get to the first source + * Get to the first source */ while (*cp && isspace (*cp)) { cp++; @@ -1075,9 +1075,9 @@ ParseDoDependency (line) } else if ((specType == NotParallel) || (specType == SingleShell)) { *line = '\0'; } - + /* - * NOW GO FOR THE SOURCES + * NOW GO FOR THE SOURCES */ if ((specType == Suffixes) || (specType == ExPath) || (specType == Includes) || (specType == Libs) || @@ -1196,7 +1196,7 @@ ParseDoDependency (line) line = cp; } } - + if (mainNode == NILGNODE) { /* * If we have yet to decide on a main target to make, in the @@ -1242,7 +1242,7 @@ Parse_IsVar (line) /* * Skip to variable name */ - for (;(*line == ' ') || (*line == '\t'); line++) + for (;(*line == ' ') || (*line == '\t'); line++) continue; for (; *line != '=' || level != 0; line++) @@ -1257,7 +1257,7 @@ Parse_IsVar (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; @@ -1271,7 +1271,7 @@ Parse_IsVar (line) case ')': level--; break; - + default: if (wasSpace && haveName) { if (ISEQOPERATOR(*line)) { @@ -1302,7 +1302,7 @@ Parse_IsVar (line) return FALSE; } else { - haveName = TRUE; + haveName = TRUE; wasSpace = FALSE; } break; @@ -1341,9 +1341,9 @@ Parse_DoVar (line, ctxt) enum { VAR_SUBST, VAR_APPEND, VAR_SHELL, VAR_NORMAL } type; /* Type of assignment */ - char *opc; /* ptr to operator character to + char *opc; /* ptr to operator character to * null-terminate the variable name */ - /* + /* * Avoid clobbered variable warnings by forcing the compiler * to ``unregister'' variables */ @@ -1549,7 +1549,7 @@ Parse_AddIncludeDir (dir) *--------------------------------------------------------------------- * ParseDoInclude -- * Push to another file. - * + * * The input is the line minus the #include. A file spec is a string * enclosed in <> or "". The former is looked for only in sysIncPath. * The latter in . and the directories specified by -I command line @@ -1641,7 +1641,7 @@ ParseDoInclude (file) prefEnd = strrchr (Fname, '/'); if (prefEnd != (char *)NULL) { char *newName; - + *prefEnd = '\0'; if (file[0] == '/') newName = estrdup(file); @@ -1731,7 +1731,7 @@ ParseDoInclude (file) *--------------------------------------------------------------------- * Parse_FromString -- * Start Parsing from the given string - * + * * Results: * None * @@ -1754,7 +1754,7 @@ Parse_FromString(str) oldFile->fname = fname; oldFile->F = curFILE; oldFile->p = curPTR; - + (void) Lst_AtFront (includes, (ClientData)oldFile); curFILE = NULL; @@ -1770,7 +1770,7 @@ Parse_FromString(str) *--------------------------------------------------------------------- * ParseTraditionalInclude -- * Push to another file. - * + * * The input is the line minus the "include". The file name is * the string following the "include". * @@ -1833,7 +1833,7 @@ ParseTraditionalInclude (file) prefEnd = strrchr (fname, '/'); if (prefEnd != (char *)NULL) { char *newName; - + *prefEnd = '\0'; newName = str_concat (fname, file, STR_ADDSLASH); fullname = Dir_FindFile (newName, parseIncPath); @@ -1953,7 +1953,7 @@ ParseEOF (opened) /*- *--------------------------------------------------------------------- * ParseReadc -- - * Read a character from the current file + * Read a character from the current file * * Results: * The character that was read @@ -1966,7 +1966,7 @@ ParseReadc() { if (curFILE) return fgetc(curFILE); - + if (curPTR && *curPTR->ptr) return *curPTR->ptr++; return EOF; @@ -1976,7 +1976,7 @@ ParseReadc() /*- *--------------------------------------------------------------------- * ParseUnreadc -- - * Put back a character to the current file + * Put back a character to the current file * * Results: * None. @@ -2007,61 +2007,43 @@ ParseSkipLine(skip) 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; } @@ -2127,11 +2109,11 @@ ParseReadLine () break; } } - + if (c != EOF) { lastc = c; buf = Buf_Init(MAKE_BSIZE); - + while (((c = ParseReadc ()) != '\n' || (lastc == '\\')) && (c != EOF)) { @@ -2179,7 +2161,7 @@ test_char: */ ParseUnreadc('\t'); goto line_read; - } + } break; case '=': if (!semiNL) { @@ -2246,11 +2228,11 @@ test_char: */ Buf_AddByte (buf, (Byte)lastc); lastc = c; - + } line_read: lineno++; - + if (lastc != '\0') { Buf_AddByte (buf, (Byte)lastc); } @@ -2266,13 +2248,13 @@ test_char: 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 @@ -2304,7 +2286,7 @@ test_char: */ line = ParseSkipLine(0); if (line == NULL) { - Parse_Error (PARSE_FATAL, + Parse_Error (PARSE_FATAL, "Unexpected end of file in for loop.\n"); break; } @@ -2352,7 +2334,7 @@ ParseFinishLine() inLine = FALSE; } } - + /*- *--------------------------------------------------------------------- @@ -2413,12 +2395,11 @@ Parse_File(name, stream) 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 @@ -2435,7 +2416,7 @@ Parse_File(name, stream) /* * So long as it's not a blank line and we're actually * in a dependency spec, add the command to the list of - * commands of all targets in the dependency spec + * commands of all targets in the dependency spec */ Lst_ForEach (targets, ParseAddCmd, cp); Lst_AtEnd(targCmds, (ClientData) line); @@ -2447,7 +2428,7 @@ Parse_File(name, stream) } } #ifdef SYSVINCLUDE - } else if (strncmp (line, "include", 7) == 0 && + } else if (strncmp (line, "include", 7) == 0 && isspace((unsigned char) line[7]) && strchr(line, ':') == NULL) { /* @@ -2473,7 +2454,7 @@ Parse_File(name, stream) #ifndef POSIX Boolean nonSpace = FALSE; #endif - + cp = line; if (isspace((unsigned char) line[0])) { while ((*cp != '\0') && isspace((unsigned char) *cp)) { @@ -2489,7 +2470,7 @@ Parse_File(name, stream) } #endif } - + #ifndef POSIX if (*cp == '\0') { if (inLine) { @@ -2506,16 +2487,16 @@ Parse_File(name, stream) cp = Var_Subst (NULL, line, VAR_CMD, TRUE); free (line); line = cp; - + /* - * Need a non-circular list for the target nodes + * Need a non-circular list for the target nodes */ if (targets) Lst_Destroy(targets, NOFREE); targets = Lst_Init (FALSE); inLine = TRUE; - + ParseDoDependency (line); #ifndef POSIX } @@ -2527,7 +2508,7 @@ Parse_File(name, stream) free (line); } /* - * Reached EOF, but it may be just EOF of an include file... + * Reached EOF, but it may be just EOF of an include file... */ } while (ParseEOF(1) == CONTINUE); @@ -2574,7 +2555,7 @@ Parse_End() Lst_Destroy(parseIncPath, Dir_Destroy); Lst_Destroy(includes, NOFREE); /* Should be empty now */ } - + /*- *----------------------------------------------------------------------- diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h index 300ad24ee94..e97ea94b00b 100644 --- a/usr.bin/make/pathnames.h +++ b/usr.bin/make/pathnames.h @@ -1,9 +1,9 @@ -/* $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 @@ -39,6 +39,9 @@ #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 */ diff --git a/usr.bin/make/sprite.h b/usr.bin/make/sprite.h index b746de933c8..bcd620ed594 100644 --- a/usr.bin/make/sprite.h +++ b/usr.bin/make/sprite.h @@ -1,9 +1,9 @@ -/* $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. * @@ -38,7 +38,7 @@ * 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 */ /* @@ -72,7 +72,7 @@ typedef int Boolean; typedef int ReturnStatus; /* - * The following statuses overlap with the first 2 generic statuses + * The following statuses overlap with the first 2 generic statuses * defined in status.h: * * SUCCESS There was no error. @@ -84,7 +84,7 @@ typedef int ReturnStatus; /* - * A nil pointer must be something that will cause an exception if + * A nil pointer must be something that will cause an exception if * referenced. There are two nils: the kernels nil and the nil used * by user processes. */ diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index a4e19c1a4e4..9bb6d61a0a3 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,9 +1,9 @@ -/* $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. * @@ -43,7 +43,7 @@ #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 */ @@ -74,8 +74,9 @@ str_init() void str_end() { - if (argv[0]) { - free(argv[0]); + if (argv) { + if (argv[0]) + free(argv[0]); free((Address) argv); } if (buffer) @@ -223,7 +224,7 @@ brk_string(str, store_argc, expand) ch = *++p; break; } - + switch (ch = *++p) { case '\0': case '\n': @@ -260,12 +261,12 @@ done: argv[argc] = (char *)NULL; /* * Str_FindSubstring -- See if a string contains a particular substring. - * + * * Results: If string contains substring, the return value is the location of * the first matching instance of substring in string. If string doesn't * contain substring, the return value is NULL. Matching is done on an exact * character-for-character basis with no wildcards or special characters. - * + * * Side effects: None. */ char * @@ -298,13 +299,13 @@ Str_FindSubstring(string, substring) /* * Str_Match -- - * + * * See if a particular string matches a particular pattern. - * + * * Results: Non-zero is returned if string matches pattern, 0 otherwise. The * matching operation permits the following special characters in the * pattern: *?\[] (see the man page for details on what these mean). - * + * * Side effects: None. */ int @@ -401,8 +402,8 @@ thisCharOK: ++pattern; /*- *----------------------------------------------------------------------- * Str_SYSVMatch -- - * Check word against pattern for a match (% is wild), - * + * Check word against pattern for a match (% is wild), + * * Results: * Returns the beginning position of a match or null. The number * of characters matched is returned in len. @@ -452,7 +453,7 @@ Str_SYSVMatch(word, pattern, len) return m; } while (*w++ != '\0'); - + return NULL; } @@ -463,7 +464,7 @@ Str_SYSVMatch(word, pattern, len) * Substitute '%' on the pattern with len characters from src. * If the pattern does not contain a '%' prepend len characters * from src. - * + * * Results: * None * diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 96b3db7053d..dba321716ca 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,9 +1,9 @@ -/* $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. * @@ -41,9 +41,9 @@ #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 */ @@ -102,7 +102,6 @@ static char rcsid[] = "$OpenBSD: suff.c,v 1.4 1996/09/02 16:04:19 briggs Exp $"; #include "make.h" #include "hash.h" #include "dir.h" -#include "bit.h" static Lst sufflist; /* Lst of suffixes */ static Lst suffClean; /* Lst of suffixes to be cleaned */ @@ -166,6 +165,7 @@ static int SuffSuffIsSuffixP __P((ClientData, ClientData)); static int SuffSuffHasNameP __P((ClientData, ClientData)); static int SuffSuffIsPrefix __P((ClientData, ClientData)); static int SuffGNHasNameP __P((ClientData, ClientData)); +static void SuffUnRef __P((ClientData, ClientData)); static void SuffFree __P((ClientData)); static void SuffInsert __P((Lst, Suff *)); static void SuffRemove __P((Lst, Suff *)); @@ -512,7 +512,7 @@ SuffParseTransform(str, srcPtr, targPtr) srcLn = NILLNODE; singleLn = NILLNODE; - + /* * Loop looking first for a suffix that matches the start of the * string and then for one that exactly matches the rest of it. If @@ -612,7 +612,7 @@ Suff_AddTransform (line) if (ln == NILLNODE) { /* * Make a new graph node for the transformation. It will be filled in - * by the Parse module. + * by the Parse module. */ gn = Targ_NewGN (line); (void)Lst_AtEnd (transforms, (ClientData)gn); @@ -635,7 +635,7 @@ Suff_AddTransform (line) (void)SuffParseTransform(line, &s, &t); /* - * link the two together in the proper relationship and order + * link the two together in the proper relationship and order */ if (DEBUG(SUFF)) { printf("defining transformation from `%s' to `%s'\n", @@ -670,7 +670,7 @@ Suff_EndTransform(gnp, dummy) ClientData dummy; /* Node for transformation */ { GNode *gn = (GNode *) gnp; - + if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children)) { @@ -819,7 +819,7 @@ Suff_AddSuffix (str) * XXX: Only do this after a Suff_ClearSuffixes? */ Lst_ForEach (transforms, SuffRebuildGraph, (ClientData)s); - } + } } /*- @@ -1002,7 +1002,7 @@ SuffAddSrc (sp, lsp) Src *targ; /* Target structure */ targ = ls->s; - + if ((s->flags & SUFF_NULL) && (*s->name != '\0')) { /* * If the suffix has been marked as the NULL suffix, also create a Src @@ -1332,7 +1332,7 @@ SuffExpandChildren(cgnp, pgnp) * after the child */ prevLN = Lst_Member(pgn->children, (ClientData)cgn); - + /* * First do variable expansion -- this takes precedence over * wildcard expansion. If the result contains wildcards, they'll be gotten @@ -1347,7 +1347,7 @@ SuffExpandChildren(cgnp, pgnp) if (cp != (char *)NULL) { Lst members = Lst_Init(FALSE); - + if (cgn->type & OP_ARCHV) { /* * Node was an archive(member) target, so we want to call @@ -1368,7 +1368,7 @@ SuffExpandChildren(cgnp, pgnp) char *start; char *initcp = cp; /* For freeing... */ - for (start = cp; *start == ' ' || *start == '\t'; start++) + for (start = cp; *start == ' ' || *start == '\t'; start++) continue; for (cp = start; *cp != '\0'; cp++) { if (*cp == ' ' || *cp == '\t') { @@ -1475,7 +1475,7 @@ SuffExpandChildren(cgnp, pgnp) if (DEBUG(SUFF)) { printf("Wildcard expanding \"%s\"...", cgn->name); } - + if (ln != NILLNODE) { Suff *s = (Suff *)Lst_Datum(ln); @@ -1523,7 +1523,7 @@ SuffExpandChildren(cgnp, pgnp) * Nuke what's left of the list */ Lst_Destroy(exp, NOFREE); - + /* * Now the source is expanded, remove it from the list of children to * keep it from being processed. @@ -1616,7 +1616,7 @@ SuffApplyTransform(tGn, sGn, t, s) } gn = (GNode *)Lst_Datum(ln); - + if (DEBUG(SUFF)) { printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name); } @@ -1625,7 +1625,7 @@ SuffApplyTransform(tGn, sGn, t, s) * Record last child for expansion purposes */ ln = Lst_Last(tGn->children); - + /* * Pass the buck to Make_HandleUse to apply the rule */ @@ -1678,7 +1678,7 @@ SuffFindArchiveDeps(gn, slst) int i; /* Index into copy and vals */ Suff *ms; /* Suffix descriptor for member */ char *name; /* Start of member's name */ - + /* * The node is an archive(member) pair. so we must find a * suffix for both of them. @@ -1690,7 +1690,7 @@ SuffFindArchiveDeps(gn, slst) *eoarch = '\0'; /* So a suffix can be found */ name = eoarch + 1; - + /* * To simplify things, call Suff_FindDeps recursively on the member now, * so we can simply compare the member's .PREFIX and .TARGET variables @@ -1709,7 +1709,7 @@ SuffFindArchiveDeps(gn, slst) (void)Lst_AtEnd(mem->parents, (ClientData)gn); gn->unmade += 1; } - + /* * Copy in the variables from the member node to this one. */ @@ -1822,7 +1822,7 @@ SuffFindNormalDeps(gn, slst) eoname = gn->name + strlen(gn->name); sopref = gn->name; - + /* * Begin at the beginning... */ @@ -1858,7 +1858,7 @@ SuffFindNormalDeps(gn, slst) if (ln != NILLNODE) { int prefLen; /* Length of the prefix */ Src *targ; - + /* * Allocate a Src structure to which things can be transformed */ @@ -1872,7 +1872,7 @@ SuffFindNormalDeps(gn, slst) #ifdef DEBUG_SRC targ->cp = Lst_Init(FALSE); #endif - + /* * Allocate room for the prefix, whose end is found by subtracting * the length of the suffix from the end of the name. @@ -1904,9 +1904,9 @@ SuffFindNormalDeps(gn, slst) */ 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; @@ -1926,16 +1926,16 @@ SuffFindNormalDeps(gn, slst) if (Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children)) SuffAddLevel(srcs, targ); else { - if (DEBUG(SUFF)) + if (DEBUG(SUFF)) printf("not "); } - if (DEBUG(SUFF)) + if (DEBUG(SUFF)) printf("adding suffix rules\n"); (void)Lst_AtEnd(targs, (ClientData)targ); } - + /* * Using the list of possible sources built up from the target suffix(es), * try and find an existing file/target that matches. @@ -1977,7 +1977,7 @@ SuffFindNormalDeps(gn, slst) * that still contain variables or wildcards in their names. */ Lst_ForEach(gn->children, SuffExpandChildren, (ClientData)gn); - + if (targ == NULL) { if (DEBUG(SUFF)) { printf("\tNo valid suffix on %s\n", gn->name); @@ -2055,7 +2055,7 @@ sfnd_abort: free(gn->path); gn->path = estrdup(gn->name); } - + goto sfnd_return; } @@ -2105,12 +2105,12 @@ sfnd_abort: * suffix. Note that this causes the commands list of the original * node, gn, to be replaced by the commands of the final * transformation rule. Also, the unmade field of gn is incremented. - * Etc. + * Etc. */ if (bottom->node == NILGNODE) { bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); } - + for (src = bottom; src->parent != (Src *)NULL; src = src->parent) { targ = src->parent; @@ -2139,7 +2139,7 @@ sfnd_abort: targ->node->type |= OP_DEPS_FOUND; Var_Set(PREFIX, targ->pref, targ->node); - + Var_Set(TARGET, targ->node->name, targ->node); } } @@ -2171,8 +2171,8 @@ sfnd_return: Lst_Concat(slst, srcs, LST_CONCLINK); Lst_Concat(slst, targs, LST_CONCLINK); } - - + + /*- *----------------------------------------------------------------------- * Suff_FindDeps -- @@ -2205,7 +2205,7 @@ void Suff_FindDeps(gn) GNode *gn; { - + SuffFindDeps(gn, srclist); while (SuffRemoveSrc(srclist)) continue; @@ -2225,11 +2225,11 @@ SuffFindDeps (gn, slst) } else { gn->type |= OP_DEPS_FOUND; } - + if (DEBUG(SUFF)) { printf ("SuffFindDeps (%s)\n", gn->name); } - + if (gn->type & OP_ARCHV) { SuffFindArchiveDeps(gn, slst); } else if (gn->type & OP_LIB) { @@ -2243,7 +2243,7 @@ SuffFindDeps (gn, slst) */ LstNode ln; Suff *s; - + ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); if (gn->suffix) gn->suffix->refCount--; @@ -2394,7 +2394,7 @@ SuffPrintSuff (sp, dummy) int flag; printf ("# `%s' [%d] ", s->name, s->refCount); - + flags = s->flags; if (flags) { fputs (" (", stdout); diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 198b27d8eb7..48b492350af 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,9 +1,9 @@ -/* $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. * @@ -40,8 +40,11 @@ */ #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 */ /*- @@ -274,11 +277,11 @@ Targ_FindNode (name, flags) /*- *----------------------------------------------------------------------- * Targ_FindList -- - * Make a complete list of GNodes from the given list of names + * Make a complete list of GNodes from the given list of names * * Results: * A complete list of graph nodes corresponding to all instances of all - * the names in names. + * the names in names. * * Side Effects: * If flags is TARG_CREATE, nodes will be created for all names in @@ -395,7 +398,7 @@ Targ_Precious (gn) /******************* DEBUG INFO PRINTING ****************/ static GNode *mainTarg; /* the main target, as set by Targ_SetMain */ -/*- +/*- *----------------------------------------------------------------------- * Targ_SetMain -- * Set our idea of the main target we'll be creating. Used for @@ -477,7 +480,7 @@ Targ_FmtTime (time) months[parts->tm_mon], parts->tm_mday, 1900 + parts->tm_year); return(buf); } - + /*- *----------------------------------------------------------------------- * Targ_PrintType -- @@ -495,7 +498,7 @@ Targ_PrintType (type) register int type; { register int tbit; - + #ifdef __STDC__ #define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break @@ -582,7 +585,7 @@ TargPrintNode (gnp, passp) Lst_ForEach (gn->parents, TargPrintName, (ClientData)0); fputc ('\n', stdout); } - + printf("%-16s", gn->name); switch (gn->type & OP_OPMASK) { case OP_DEPENDS: diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index 302317386bf..4032472dcc6 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -1,13 +1,12 @@ -/* $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> @@ -27,8 +26,8 @@ extern int errno, sys_nerr; extern char *sys_errlist[]; char * -strerror(e) - int e; +strerror(e) + int e; { static char buf[100]; if (e < 0 || e >= sys_nerr) { @@ -53,6 +52,7 @@ strdup(str) const char *str; { size_t len; + char *p; if (str == NULL) return NULL; @@ -69,7 +69,7 @@ strdup(str) int setenv(name, value, dum) - const char *name; + const char *name; const char *value; int dum; { @@ -81,15 +81,15 @@ setenv(name, value, dum) if (ptr == NULL) return -1; - + p = ptr; - while (*name) + while (*name) *p++ = *name++; *p++ = '='; - while (*value) + while (*value) *p++ = *value++; *p = '\0'; @@ -238,14 +238,14 @@ getwd(pathname) /* 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)) @@ -259,7 +259,7 @@ getwd(pathname) } /* 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; } } diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 06cc5ae0690..642c07c0be2 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,9 +1,9 @@ -/* $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. * @@ -41,9 +41,9 @@ #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 */ @@ -154,7 +154,6 @@ typedef struct { #define VAR_SUB_GLOBAL 1 /* Apply substitution globally */ #define VAR_MATCH_START 2 /* Match at start of word */ #define VAR_MATCH_END 4 /* Match at end of word */ -#define VAR_NO_SUB 8 /* Substitution is non-global and already done */ } VarPattern; static int VarCmp __P((ClientData, ClientData)); @@ -280,15 +279,15 @@ VarFind (name, ctxt, flags) 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) && @@ -756,7 +755,7 @@ VarRoot (word, addSpace, buf, dummy) * VarMatch -- * Place the word in the buffer if it matches the given pattern. * Callback function for VarModify to implement the :M modifier. - * + * * Results: * TRUE if a space should be placed in the buffer before the next * word. @@ -792,7 +791,7 @@ VarMatch (word, addSpace, buf, pattern) * 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. @@ -835,7 +834,7 @@ VarSYSVMatch (word, addSpace, buf, patp) * VarNoMatch -- * Place the word in the buffer if it doesn't match the given pattern. * Callback function for VarModify to implement the :N modifier. - * + * * Results: * TRUE if a space should be placed in the buffer before the next * word. @@ -892,9 +891,9 @@ VarSubstitute (word, addSpace, buf, patternp) 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) && @@ -976,7 +975,7 @@ VarSubstitute (word, addSpace, buf, patternp) * Pattern is unanchored: search for the pattern in the word using * String_FindSubstring, copying unmatched portions and the * right-hand-side for each match found, handling non-global - * 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. @@ -999,12 +998,8 @@ VarSubstitute (word, addSpace, buf, patternp) Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs); wordLen -= (cp - word) + pattern->leftLen; word = cp + pattern->leftLen; - if (wordLen == 0) { - 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; @@ -1024,14 +1019,9 @@ VarSubstitute (word, addSpace, buf, patternp) 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: @@ -1077,7 +1067,7 @@ VarModify (str, modProc, datum) for (i = 1; i < ac; i++) addSpace = (*modProc)(av[i], addSpace, buf, datum); - + Buf_AddByte (buf, '\0'); str = (char *)Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); @@ -1128,11 +1118,11 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * expanding it in a non-local context. This * is done to support dynamic sources. The * result is just the invocation, unaltered */ - + *freePtr = FALSE; dynamic = FALSE; start = str; - + if (str[1] != '(' && str[1] != '{') { /* * If it's not bounded by braces of some sort, life is much simpler. @@ -1147,7 +1137,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); if (v == (Var *)NIL) { *lengthPtr = 2; - + if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { /* * If substituting a local variable in a non-local context, @@ -1205,7 +1195,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) return (var_Error); } *tstr = '\0'; - + v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && ((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')) @@ -1231,7 +1221,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) vname[0] = str[2]; vname[1] = '\0'; v = VarFind(vname, ctxt, 0); - + if (v != (Var *)NIL) { /* * No need for nested expansion or anything, as we're @@ -1239,7 +1229,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * but nested invocations in them... */ val = (char *)Buf_GetAll(v->val, (int *)NULL); - + if (str[3] == 'D') { val = VarModify(val, VarHead, (ClientData)0); } else { @@ -1258,7 +1248,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } } } - + if (v == (Var *)NIL) { if ((((tstr-str) == 3) || ((((tstr-str) == 4) && (str[3] == 'F' || @@ -1287,7 +1277,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL))) { int len; - + len = (tstr-str) - 3; if ((strncmp(str+2, ".TARGET", len) == 0) || (strncmp(str+2, ".ARCHIVE", len) == 0) || @@ -1297,7 +1287,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) dynamic = TRUE; } } - + if (!haveModifier) { /* * No modifiers -- have specification length so we can return @@ -1347,9 +1337,9 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) str = Var_Subst(NULL, str, ctxt, err); *freePtr = TRUE; } - + v->flags &= ~VAR_IN_USE; - + /* * Now we need to apply any modifiers the user wants applied. * These are: @@ -1375,7 +1365,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) while (*tstr != endc) { char *newStr; /* New value to return */ char termc; /* Character which terminated scan */ - + if (DEBUG(VAR)) { printf("Applying :%c to \"%s\"\n", *tstr, str); } @@ -1452,7 +1442,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } buf = Buf_Init(0); - + /* * Pass through the lhs looking for 1) escaped delimiters, * '$'s and backslashes (place the escaped character in @@ -1478,7 +1468,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) char *cp2; int len; Boolean freeIt; - + cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt); Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); if (freeIt) { @@ -1498,7 +1488,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } Buf_AddByte(buf, (Byte)'\0'); - + /* * If lhs didn't end with the delimiter, complain and * return NULL @@ -1533,7 +1523,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * it right here) and 3) expand any variable substitutions. */ buf = Buf_Init(0); - + tstr = cp + 1; for (cp = tstr; *cp != '\0' && *cp != delim; cp++) { if ((*cp == '\\') && @@ -1564,7 +1554,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } Buf_AddByte(buf, (Byte)'\0'); - + /* * If didn't end in delimiter character, complain */ @@ -1658,7 +1648,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) */ VarPattern pattern; Boolean eqFound; - + pattern.flags = 0; eqFound = FALSE; /* @@ -1681,7 +1671,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) cp++; } if (*cp == endc && eqFound) { - + /* * Now we break this sucker into the lhs and * rhs. We must null terminate them of course. @@ -1691,7 +1681,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) pattern.lhs = tstr; pattern.leftLen = cp - tstr; *cp++ = '\0'; - + pattern.rhs = cp; cnt = 1; while (cnt) { @@ -1704,7 +1694,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } pattern.rightLen = cp - pattern.rhs; *cp = '\0'; - + /* * SYSV modifications happen through the whole * string. Note the pattern is anchored at the end. @@ -1724,7 +1714,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) Error ("Unknown modifier '%c'\n", *tstr); for (cp = tstr+1; *cp != ':' && *cp != endc && *cp != '\0'; - cp++) + cp++) continue; termc = *cp; newStr = var_Error; @@ -1734,7 +1724,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) if (DEBUG(VAR)) { printf("Result is \"%s\"\n", newStr); } - + if (*freePtr) { free (str); } @@ -1758,10 +1748,10 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) *lengthPtr = tstr - start + 1; *tstr = endc; } - + if (v->flags & VAR_FROM_ENV) { Boolean destroy = FALSE; - + if (str != (char *)Buf_GetAll(v->val, (int *)NULL)) { destroy = TRUE; } else { @@ -1868,9 +1858,9 @@ Var_Subst (var, str, ctxt, undefErr) /* * Scan up to the end of the variable name. */ - for (p = &str[2]; *p && + for (p = &str[2]; *p && *p != ':' && *p != ')' && *p != '}'; p++) - if (*p == '$') + if (*p == '$') break; /* * A variable inside the variable. We cannot expand @@ -1882,14 +1872,14 @@ Var_Subst (var, str, ctxt, undefErr) str = p; continue; } - - if (strncmp(var, str + 2, p - str - 2) != 0 || + + if (strncmp(var, str + 2, p - str - 2) != 0 || var[p - str - 2] != '\0') { /* * Not the variable we want to expand, scan * until the next variable */ - for (;*p != '$' && *p != '\0'; p++) + for (;*p != '$' && *p != '\0'; p++) continue; Buf_AddBytes(buf, p - str, (Byte *) str); str = p; @@ -1903,7 +1893,7 @@ Var_Subst (var, str, ctxt, undefErr) if (!expand) continue; } - + val = Var_Parse (str, ctxt, undefErr, &length, &doFree); /* @@ -1943,7 +1933,7 @@ Var_Subst (var, str, ctxt, undefErr) * advance the string pointer. */ str += length; - + /* * Copy all the characters from the variable value straight * into the new string. @@ -1955,7 +1945,7 @@ Var_Subst (var, str, ctxt, undefErr) } } } - + Buf_AddByte (buf, '\0'); str = (char *)Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); @@ -2014,7 +2004,7 @@ Var_GetHead(file) * None * * Side Effects: - * The VAR_CMD and VAR_GLOBAL contexts are created + * The VAR_CMD and VAR_GLOBAL contexts are created *----------------------------------------------------------------------- */ void @@ -2032,7 +2022,7 @@ Var_End () { Lst_Destroy(allVars, VarDelete); } - + /****************** PRINT DEBUGGING INFO *****************/ static int |