Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,

pascal and vmstat.sparc.  All changed files on the vendor branch should
already have been imported.
This commit is contained in:
Bruce Evans 1997-07-06 06:54:14 +00:00
parent ea09f5e44d
commit 3e4da6f5b3
57 changed files with 1631 additions and 2868 deletions

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.11 1996/05/28 23:34:35 christos Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
# from: @(#)Makefile 5.2 (Berkeley) 12/28/90
# $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $
PROG= make
CFLAGS+= -I${.CURDIR} -Wall -Wno-unused #-Wmissing-prototypes -Wstrict-prototypes
CFLAGS+= -I${.CURDIR} -DPOSIX
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
make.c parse.c str.c suff.c targ.c var.c util.c
make.c parse.c str.c suff.c targ.c var.c
SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \
lstFind.c lstFindFrom.c lstFirst.c lstForEach.c lstForEachFrom.c \

View File

@ -1,4 +1,3 @@
# $NetBSD: Makefile,v 1.2 1995/06/14 15:20:23 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 8/14/93
DIR= psd/12.make

View File

@ -1,4 +1,3 @@
.\" $NetBSD: tutorial.ms,v 1.3 1996/03/06 00:15:31 christos Exp $
.\" Copyright (c) 1988, 1989 by Adam de Boor
.\" Copyright (c) 1989 by Berkeley Softworks
.\" Copyright (c) 1988, 1989, 1993
@ -35,7 +34,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)tutorial.ms 8.1 (Berkeley) 8/18/93
.\" @(#)tutorial.ms 8.4 (Berkeley) 4/28/95
.\"
.EH 'PSD:12-%''PMake \*- A Tutorial'
.OH 'PMake \*- A Tutorial''PSD:12-%'
@ -44,6 +43,8 @@
.\" is numeric, it is taken as the depth for numbering (as for .NH), else
.\" the default (1) is assumed.
.\"
.\" $Id: tutorial.ms,v 1.4 89/01/08 20:20:22 adam Exp Locker: adam $
.\"
.\" @P The initial paragraph distance.
.\" @Q The piece of section number to increment (or 0 if none given)
.\" @R Section header.
@ -1271,15 +1272,6 @@ administrator. If locking is on,
will turn it off, and vice versa. Note that this locking will not
prevent \fIyou\fP from invoking PMake twice in the same place \*- if
you own the lock file, PMake will warn you about it but continue to execute.
.IP "\fB\-m\fP \fIdirectory\fP"
.Ix 0 def flags -m
Tells PMake another place to search for included makefiles via the <...>
style. Several
.B \-m
options can be given to form a search path. If this construct is used the
default system makefile search path is completely overridden.
To be explained in chapter 3, section 3.2.
.Rm 2 3.2
.IP \fB\-n\fP
.Ix 0 def flags -n
This flag tells PMake not to execute the commands needed to update the
@ -1920,15 +1912,11 @@ or this
.DE
The difference between the two is where PMake searches for the file:
the first way, PMake will look for
the file only in the system makefile directory (or directories)
(to find out what that directory is, give PMake the
the file only in the system makefile directory (to find out what that
directory is, give PMake the
.B \-h
flag).
.Ix 0 ref flags -h
The system makefile directory search path can be overridden via the
.B \-m
option.
.Ix 0 ref flags -m
For files in double-quotes, the search is more complex:
.RS
.IP 1)

View File

@ -1,5 +1,3 @@
/* $NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
static char rcsid[] = "$NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $";
#endif
static char sccsid[] = "@(#)arch.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -100,7 +94,7 @@ static char rcsid[] = "$NetBSD: arch.c,v 1.16 1996/08/13 16:42:00 christos Exp $
#include <sys/param.h>
#include <ctype.h>
#include <ar.h>
#include <utime.h>
#include <ranlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "make.h"
@ -114,18 +108,12 @@ typedef struct Arch {
char *name; /* Name of archive */
Hash_Table members; /* All the members of the archive described
* by <name, struct ar_hdr *> key/value pairs */
char *fnametab; /* Extended name table strings */
size_t fnamesize; /* Size of the string table */
} Arch;
static int ArchFindArchive __P((ClientData, ClientData));
static void ArchFree __P((ClientData));
static struct ar_hdr *ArchStatMember __P((char *, char *, Boolean));
static FILE *ArchFindMember __P((char *, char *, struct ar_hdr *, char *));
#if defined(__svr4__) || defined(__SVR4)
#define SVR4ARCHIVES
static int ArchSVR4Entry __P((Arch *, char *, size_t, FILE *));
#endif
/*-
*-----------------------------------------------------------------------
@ -155,8 +143,6 @@ ArchFree(ap)
free((Address) Hash_GetValue (entry));
free(a->name);
if (a->fnametab)
free(a->fnametab);
Hash_DeleteTable(&a->members);
free((Address) a);
}
@ -500,7 +486,7 @@ ArchStatMember (archive, member, hash)
strncpy(copy, member, AR_MAX_NAME_LEN);
copy[AR_MAX_NAME_LEN] = '\0';
}
if ((he = Hash_FindEntry (&ar->members, copy)) != NULL)
if (he = Hash_FindEntry (&ar->members, copy))
return ((struct ar_hdr *) Hash_GetValue (he));
return ((struct ar_hdr *) NULL);
}
@ -546,58 +532,27 @@ ArchStatMember (archive, member, hash)
}
ar = (Arch *)emalloc (sizeof (Arch));
ar->name = estrdup (archive);
ar->fnametab = NULL;
ar->fnamesize = 0;
ar->name = strdup (archive);
Hash_InitTable (&ar->members, -1);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread ((char *)&arh, sizeof (struct ar_hdr), 1, arch) == 1) {
if (strncmp ( arh.ar_fmag, ARFMAG, sizeof (arh.ar_fmag)) != 0) {
/*
* The header is bogus, so the archive is bad
* and there's no way we can recover...
*/
goto badarch;
/*
* The header is bogus, so the archive is bad
* and there's no way we can recover...
*/
fclose (arch);
Hash_DeleteTable (&ar->members);
free ((Address)ar);
return ((struct ar_hdr *) NULL);
} else {
/*
* We need to advance the stream's pointer to the start of the
* next header. Files are padded with newlines to an even-byte
* boundary, so we need to extract the size of the file from the
* 'size' field of the header and round it up during the seek.
*/
arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
size = (int) strtol(arh.ar_size, NULL, 10);
(void) strncpy (memName, arh.ar_name, sizeof(arh.ar_name));
for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
continue;
}
cp[1] = '\0';
#ifdef SVR4ARCHIVES
/*
* svr4 names are slash terminated. Also svr4 extended AR format.
*/
if (memName[0] == '/') {
/*
* svr4 magic mode; handle it
*/
switch (ArchSVR4Entry(ar, memName, size, arch)) {
case -1: /* Invalid data */
goto badarch;
case 0: /* List of files entry */
continue;
default: /* Got the entry */
break;
}
}
else {
if (cp[0] == '/')
cp[0] = '\0';
}
#endif
#ifdef AR_EFMT1
/*
* BSD 4.4 extended AR format: #1/<namelen>, with name as the
@ -608,10 +563,18 @@ ArchStatMember (archive, member, hash)
unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
if (elen > MAXPATHLEN)
goto badarch;
if (fread (memName, elen, 1, arch) != 1)
goto badarch;
if (elen > MAXPATHLEN) {
fclose (arch);
Hash_DeleteTable (&ar->members);
free ((Address)ar);
return ((struct ar_hdr *) NULL);
}
if (fread (memName, elen, 1, arch) != 1) {
fclose (arch);
Hash_DeleteTable (&ar->members);
free ((Address)ar);
return ((struct ar_hdr *) NULL);
}
memName[elen] = '\0';
fseek (arch, -elen, 1);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
@ -625,6 +588,14 @@ ArchStatMember (archive, member, hash)
memcpy ((Address)Hash_GetValue (he), (Address)&arh,
sizeof (struct ar_hdr));
}
/*
* We need to advance the stream's pointer to the start of the
* next header. Files are padded with newlines to an even-byte
* boundary, so we need to extract the size of the file from the
* 'size' field of the header and round it up during the seek.
*/
arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
size = (int) strtol(arh.ar_size, NULL, 10);
fseek (arch, (size + 1) & ~1, 1);
}
@ -643,121 +614,8 @@ ArchStatMember (archive, member, hash)
} else {
return ((struct ar_hdr *) NULL);
}
badarch:
fclose (arch);
Hash_DeleteTable (&ar->members);
if (ar->fnametab)
free(ar->fnametab);
free ((Address)ar);
return ((struct ar_hdr *) NULL);
}
#ifdef SVR4ARCHIVES
/*-
*-----------------------------------------------------------------------
* ArchSVR4Entry --
* Parse an SVR4 style entry that begins with a slash.
* If it is "//", then load the table of filenames
* If it is "/<offset>", then try to substitute the long file name
* from offset of a table previously read.
*
* Results:
* -1: Bad data in archive
* 0: A table was loaded from the file
* 1: Name was successfully substituted from table
* 2: Name was not successfully substituted from table
*
* Side Effects:
* If a table is read, the file pointer is moved to the next archive
* member
*
*-----------------------------------------------------------------------
*/
static int
ArchSVR4Entry(ar, name, size, arch)
Arch *ar;
char *name;
size_t size;
FILE *arch;
{
#define ARLONGNAMES1 "//"
#define ARLONGNAMES2 "/ARFILENAMES"
size_t entry;
char *ptr, *eptr;
if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 ||
strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
if (ar->fnametab != NULL) {
if (DEBUG(ARCH)) {
printf("Attempted to redefine an SVR4 name table\n");
}
return -1;
}
/*
* This is a table of archive names, so we build one for
* ourselves
*/
ar->fnametab = emalloc(size);
ar->fnamesize = size;
if (fread(ar->fnametab, size, 1, arch) != 1) {
if (DEBUG(ARCH)) {
printf("Reading an SVR4 name table failed\n");
}
return -1;
}
eptr = ar->fnametab + size;
for (entry = 0, ptr = ar->fnametab; ptr < eptr; ptr++)
switch (*ptr) {
case '/':
entry++;
*ptr = '\0';
break;
case '\n':
break;
default:
break;
}
if (DEBUG(ARCH)) {
printf("Found svr4 archive name table with %d entries\n", entry);
}
return 0;
}
if (name[1] == ' ' || name[1] == '\0')
return 2;
entry = (size_t) strtol(&name[1], &eptr, 0);
if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
if (DEBUG(ARCH)) {
printf("Could not parse SVR4 name %s\n", name);
}
return 2;
}
if (entry >= ar->fnamesize) {
if (DEBUG(ARCH)) {
printf("SVR4 entry offset %s is greater than %d\n",
name, ar->fnamesize);
}
return 2;
}
if (DEBUG(ARCH)) {
printf("Replaced %s with %s\n", name, &ar->fnametab[entry]);
}
(void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
name[MAXPATHLEN] = '\0';
return 1;
}
#endif
/*-
*-----------------------------------------------------------------------
* ArchFindMember --
@ -962,10 +820,9 @@ void
Arch_TouchLib (gn)
GNode *gn; /* The node of the library to touch */
{
#ifdef RANLIBMAG
FILE * arch; /* Stream open to archive */
struct ar_hdr arh; /* Header describing table of contents */
struct utimbuf times; /* Times for utime() call */
struct timeval times[2]; /* Times for utimes() call */
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+");
sprintf(arh.ar_date, "%-12ld", (long) now);
@ -974,10 +831,10 @@ Arch_TouchLib (gn)
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
fclose (arch);
times.actime = times.modtime = now;
utime(gn->path, &times);
times[0].tv_sec = times[1].tv_sec = now;
times[0].tv_usec = times[1].tv_usec = 0;
utimes(gn->path, times);
}
#endif
}
/*-
@ -1118,7 +975,7 @@ Arch_FindLib (gn, path)
Var_Set (TARGET, gn->name, gn);
#else
Var_Set (TARGET, gn->path == (char *) NULL ? gn->name : gn->path, gn);
#endif /* LIBRARIES */
#endif LIBRARIES
}
/*-
@ -1168,7 +1025,6 @@ Arch_LibOODate (gn)
} else if ((gn->mtime > now) || (gn->mtime < gn->cmtime)) {
oodate = TRUE;
} else {
#ifdef RANLIBMAG
struct ar_hdr *arhPtr; /* Header for __.SYMDEF */
int modTimeTOC; /* The table-of-contents's mod time */
@ -1190,9 +1046,6 @@ Arch_LibOODate (gn)
}
oodate = TRUE;
}
#else
oodate = FALSE;
#endif
}
return (oodate);
}

View File

@ -1,8 +1,6 @@
/* $NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $";
#endif
static char sccsid[] = "@(#)buf.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -69,7 +63,7 @@ static char rcsid[] = "$NetBSD: buf.c,v 1.7 1996/03/29 02:17:13 jtc Exp $";
#define BufExpand(bp,nb) \
if (bp->left < (nb)+1) {\
int newSize = (bp)->size + max((nb)+1,BUF_ADD_INC); \
Byte *newBuf = (Byte *) erealloc((bp)->buffer, newSize); \
Byte *newBuf = (Byte *) realloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
(bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\
@ -440,28 +434,3 @@ Buf_Destroy (buf, freeData)
}
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;
}

View File

@ -1,8 +1,6 @@
/* $NetBSD: buf.h,v 1.5 1995/06/14 15:18:53 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)buf.h 8.1 (Berkeley) 6/6/93
* @(#)buf.h 8.2 (Berkeley) 4/28/95
*/
/*-
@ -78,6 +76,5 @@ void Buf_Discard __P((Buffer, int));
int Buf_Size __P((Buffer));
Buffer Buf_Init __P((int));
void Buf_Destroy __P((Buffer, Boolean));
void Buf_ReplaceLastByte __P((Buffer, Byte));
#endif /* _BUF_H */

View File

@ -1,8 +1,6 @@
/* $NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
static char rcsid[] = "$NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $";
#endif
static char sccsid[] = "@(#)compat.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -61,11 +55,11 @@ static char rcsid[] = "$NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include "make.h"
#include "hash.h"
#include "dir.h"
@ -111,8 +105,10 @@ CompatInterrupt (signo)
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
char *p1;
char *file = Var_Value (TARGET, curTarg, &p1);
struct stat st;
if (!noExecute && eunlink(file) != -1) {
if (!noExecute && lstat(file, &st) != -1 && !S_ISDIR(st.st_mode) &&
unlink(file) != -1) {
printf ("*** %s removed\n", file);
}
if (p1)
@ -155,7 +151,7 @@ CompatRunCommand (cmdp, gnp)
register char *cp;
Boolean silent, /* Don't print command */
errCheck; /* Check errors */
int reason; /* Reason for child's death */
union wait reason; /* Reason for child's death */
int status; /* Description of child's death */
int cpid; /* Child actually found */
ReturnStatus stat; /* Status of fork */
@ -296,7 +292,7 @@ CompatRunCommand (cmdp, gnp)
*/
while (1) {
while ((stat = wait(&reason)) != cpid) {
while ((stat = wait((int *)&reason)) != cpid) {
if (stat == -1 && errno != EINTR) {
break;
}
@ -304,14 +300,14 @@ CompatRunCommand (cmdp, gnp)
if (stat > -1) {
if (WIFSTOPPED(reason)) {
status = WSTOPSIG(reason); /* stopped */
status = reason.w_stopval; /* stopped */
} else if (WIFEXITED(reason)) {
status = WEXITSTATUS(reason); /* exited */
status = reason.w_retcode; /* exited */
if (status != 0) {
printf ("*** Error code %d", status);
}
} else {
status = WTERMSIG(reason); /* signaled */
status = reason.w_termsig; /* signaled */
printf ("*** Signal %d", status);
}
@ -619,10 +615,6 @@ Compat_Run(targs)
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (gn != NILGNODE) {
Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
if (gn->made == ERROR) {
printf("\n\nStop.\n");
exit(1);
}
}
}

View File

@ -1,8 +1,6 @@
/* $NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
static char rcsid[] = "$NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $";
#endif
static char sccsid[] = "@(#)cond.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -100,7 +94,6 @@ typedef enum {
* Structures to handle elegantly the different forms of #if's. The
* last two fields are stored in condInvert and condDefProc, respectively.
*/
static void CondPushBack __P((Token));
static int CondGetArg __P((char **, char **, char *, Boolean));
static Boolean CondDoDefined __P((int, char *));
static int CondStrMatch __P((ClientData, ClientData));
@ -117,19 +110,18 @@ static struct If {
char *form; /* Form of if */
int formlen; /* Length of form */
Boolean doNot; /* TRUE if default function should be negated */
Boolean (*defProc) __P((int, char *)); /* Default function to apply */
Boolean (*defProc)(); /* Default function to apply */
} ifs[] = {
{ "ifdef", 5, FALSE, CondDoDefined },
{ "ifndef", 6, TRUE, CondDoDefined },
{ "ifmake", 6, FALSE, CondDoMake },
{ "ifnmake", 7, TRUE, CondDoMake },
{ "if", 2, FALSE, CondDoDefined },
{ NULL, 0, FALSE, NULL }
{ (char *)0, 0, FALSE, (Boolean (*)())0 }
};
static Boolean condInvert; /* Invert the default function */
static Boolean (*condDefProc) /* Default function to apply */
__P((int, char *));
static Boolean (*condDefProc)(); /* Default function to apply */
static char *condExpr; /* The expression to parse */
static Token condPushBack=None; /* Single push-back token used in
* parsing */
@ -766,7 +758,7 @@ error:
break;
}
default: {
Boolean (*evalProc) __P((int, char *));
Boolean (*evalProc)();
Boolean invert = FALSE;
char *arg;
int arglen;

View File

@ -1,8 +1,6 @@
/* $NetBSD: config.h,v 1.6 1996/05/28 23:34:39 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
* @(#)config.h 8.2 (Berkeley) 4/28/95
*/
#define DEFSHELL 1 /* Bourne shell */
@ -80,39 +78,15 @@
* re-made, causing later targets to appear up-to-date. On systems
* that don't have this problem, you should defined this. Under
* NFS you probably should not, unless you aren't exporting jobs.
*
* POSIX
* If the POSIX standard for Make is to be followed. There are
* several areas that I dislike, hence this constant.
*/
#define LIBSUFF ".a"
#define RECHECK
/*
* POSIX
* Adhere to the POSIX 1003.2 draft for the make(1) program.
* - Use MAKEFLAGS instead of MAKE to pick arguments from the
* environment.
* - Allow empty command lines if starting with tab.
*/
#define POSIX
/*
* SYSVINCLUDE
* Recognize system V like include directives [include "filename"]
* SYSVVARSUB
* Recognize system V like ${VAR:x=y} variable substitutions
*/
#define SYSVINCLUDE
#define SYSVVARSUB
/*
* SUNSHCMD
* Recognize SunOS and Solaris:
* VAR :sh= CMD # Assign VAR to the command substitution of CMD
* ${VAR:sh} # Return the command substitution of the value
* # of ${VAR}
*/
#define SUNSHCMD
#if !defined(__svr4__) && !defined(__SVR4)
# ifndef RANLIBMAG
# define RANLIBMAG "__.SYMDEF"
# endif
#ifndef RANLIBMAG
#define RANLIBMAG "__.SYMDEF"
#endif
/*#define POSIX*/

View File

@ -1,8 +1,6 @@
/* $NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
static char rcsid[] = "$NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $";
#endif
static char sccsid[] = "@(#)dir.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -354,7 +348,7 @@ DirMatchFiles (pattern, p, expansions)
(pattern[0] == '.')))
{
(void)Lst_AtEnd(expansions,
(isDot ? estrdup(entry->name) :
(isDot ? strdup(entry->name) :
str_concat(p->name, entry->name,
STR_ADDSLASH)));
}
@ -706,7 +700,7 @@ Dir_FindFile (name, path)
}
hits += 1;
dot->hits += 1;
return (estrdup (name));
return (strdup (name));
}
if (Lst_Open (path) == FAILURE) {
@ -817,7 +811,7 @@ Dir_FindFile (name, path)
/*
* Checking in dot -- DON'T put a leading ./ on the thing.
*/
file = estrdup(name);
file = strdup(name);
checkedDot = TRUE;
}
if (DEBUG(DIR)) {
@ -913,7 +907,7 @@ Dir_FindFile (name, path)
}
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
return (estrdup (name));
return (strdup (name));
} else {
return ((char *) NULL);
}
@ -928,7 +922,7 @@ Dir_FindFile (name, path)
if (DEBUG(DIR)) {
printf("got it (in mtime cache)\n");
}
return(estrdup(name));
return(strdup(name));
} else if (stat (name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
if (DEBUG(DIR)) {
@ -936,7 +930,7 @@ Dir_FindFile (name, path)
name);
}
Hash_SetValue(entry, (long)stb.st_mtime);
return (estrdup (name));
return (strdup (name));
} else {
if (DEBUG(DIR)) {
printf("failed. Returning NULL\n");
@ -979,7 +973,7 @@ Dir_MTime (gn)
}
if (fullName == (char *)NULL) {
fullName = estrdup(gn->name);
fullName = strdup(gn->name);
}
entry = Hash_FindEntry(&mtimes, fullName);
@ -1053,7 +1047,7 @@ Dir_AddDir (path, name)
if ((d = opendir (name)) != (DIR *) NULL) {
p = (Path *) emalloc (sizeof (Path));
p->name = estrdup (name);
p->name = strdup (name);
p->hits = 0;
p->refCount = 1;
Hash_InitTable (&p->files, -1);
@ -1065,7 +1059,7 @@ Dir_AddDir (path, name)
(void)readdir(d);
while ((dp = readdir (d)) != (struct dirent *) NULL) {
#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
#ifdef sun
/*
* The sun directory library doesn't check for a 0 inode
* (0-inode slots just take up space), so we have to do
@ -1074,7 +1068,7 @@ Dir_AddDir (path, name)
if (dp->d_fileno == 0) {
continue;
}
#endif /* sun && d_ino */
#endif /* sun */
(void)Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL);
}
(void) closedir (d);
@ -1137,7 +1131,7 @@ Dir_MakeFlags (flag, path)
LstNode ln; /* the node of the current directory */
Path *p; /* the structure describing the current directory */
str = estrdup ("");
str = strdup ("");
if (Lst_Open (path) == SUCCESS) {
while ((ln = Lst_Next (path)) != NILLNODE) {

View File

@ -1,8 +1,6 @@
/* $NetBSD: dir.h,v 1.3 1995/06/14 15:19:11 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)dir.h 8.1 (Berkeley) 6/6/93
* @(#)dir.h 8.2 (Berkeley) 4/28/95
*/
/* dir.h --

View File

@ -1,8 +1,9 @@
/* $NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
* All rights reserved.
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -34,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: for.c,v 1.3 1995/06/14 15:19:13 christos Exp $";
#endif
static char sccsid[] = "@(#)for.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -180,7 +177,7 @@ For_Eval (line)
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \
Buf_AddByte(buf, (Byte) '\0'), \
Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
Lst_AtEnd(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)

View File

@ -1,8 +1,6 @@
/* $NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: hash.c,v 1.5 1995/06/14 15:19:15 christos Exp $";
#endif
static char sccsid[] = "@(#)hash.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/* hash.c --

View File

@ -1,8 +1,6 @@
/* $NetBSD: hash.h,v 1.4 1995/06/14 15:19:18 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)hash.h 8.1 (Berkeley) 6/6/93
* @(#)hash.h 8.2 (Berkeley) 4/28/95
*/
/* hash.h --

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
/* $NetBSD: job.h,v 1.4 1995/06/14 15:19:26 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)job.h 8.1 (Berkeley) 6/6/93
* @(#)job.h 8.2 (Berkeley) 4/28/95
*/
/*-

View File

@ -1,8 +1,6 @@
/* $NetBSD: list.h,v 1.4 1995/06/14 15:19:28 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)list.h 8.1 (Berkeley) 6/6/93
* @(#)list.h 8.2 (Berkeley) 4/28/95
*/
/*

View File

@ -1,8 +1,6 @@
/* $NetBSD: lst.h,v 1.6 1996/02/04 22:20:46 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)lst.h 8.1 (Berkeley) 6/6/93
* @(#)lst.h 8.2 (Berkeley) 4/28/95
*/
/*-
@ -48,7 +46,6 @@
#define _LST_H_
#include <sprite.h>
#include <sys/param.h>
#if __STDC__
#include <stdlib.h>
#endif

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstAppend.c,v 1.4 1995/06/14 15:20:44 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.4 1995/06/14 15:20:44 christos Exp $";
#endif
static char sccsid[] = "@(#)lstAppend.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.4 1995/06/14 15:20:46 christos Exp $";
#endif
static char sccsid[] = "@(#)lstAtEnd.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstAtFront.c,v 1.4 1995/06/14 15:20:48 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.4 1995/06/14 15:20:48 christos Exp $";
#endif
static char sccsid[] = "@(#)lstAtFront.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstClose.c,v 1.4 1995/06/14 15:20:50 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstClose.c,v 1.4 1995/06/14 15:20:50 christos Exp $";
#endif
static char sccsid[] = "@(#)lstClose.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstConcat.c,v 1.5 1995/06/14 15:20:53 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.5 1995/06/14 15:20:53 christos Exp $";
#endif
static char sccsid[] = "@(#)lstConcat.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstDatum.c,v 1.4 1995/06/14 15:20:54 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.4 1995/06/14 15:20:54 christos Exp $";
#endif
static char sccsid[] = "@(#)lstDatum.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstDeQueue.c,v 1.4 1995/06/14 15:20:56 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.4 1995/06/14 15:20:56 christos Exp $";
#endif
static char sccsid[] = "@(#)lstDeQueue.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstDestroy.c,v 1.5 1995/06/14 15:20:58 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstDestroy.c,v 1.5 1995/06/14 15:20:58 christos Exp $";
#endif
static char sccsid[] = "@(#)lstDestroy.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstDupl.c,v 1.5 1995/06/14 15:21:02 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.5 1995/06/14 15:21:02 christos Exp $";
#endif
static char sccsid[] = "@(#)lstDupl.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstEnQueue.c,v 1.4 1995/06/14 15:21:04 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.4 1995/06/14 15:21:04 christos Exp $";
#endif
static char sccsid[] = "@(#)lstEnQueue.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstFind.c,v 1.5 1995/06/14 15:21:07 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstFind.c,v 1.5 1995/06/14 15:21:07 christos Exp $";
#endif
static char sccsid[] = "@(#)lstFind.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstFindFrom.c,v 1.5 1995/06/14 15:21:09 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.5 1995/06/14 15:21:09 christos Exp $";
#endif
static char sccsid[] = "@(#)lstFindFrom.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstFirst.c,v 1.4 1995/06/14 15:21:12 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.4 1995/06/14 15:21:12 christos Exp $";
#endif
static char sccsid[] = "@(#)lstFirst.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstForEach.c,v 1.5 1995/06/14 15:21:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.5 1995/06/14 15:21:14 christos Exp $";
#endif
static char sccsid[] = "@(#)lstForEach.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.4 1995/06/14 15:21:16 christos Exp $";
#endif
static char sccsid[] = "@(#)lstForEachFrom.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -72,7 +66,7 @@ void
Lst_ForEachFrom (l, ln, proc, d)
Lst l;
LstNode ln;
register int (*proc) __P((ClientData, ClientData));
register int (*proc)();
register ClientData d;
{
register ListNode tln = (ListNode)ln;
@ -115,4 +109,3 @@ Lst_ForEachFrom (l, ln, proc, d)
} while (!result && !LstIsEmpty(list) && !done);
}

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstInit.c,v 1.4 1995/06/14 15:21:18 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstInit.c,v 1.4 1995/06/14 15:21:18 christos Exp $";
#endif
static char sccsid[] = "@(#)lstInit.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstInsert.c,v 1.4 1995/06/14 15:21:21 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.4 1995/06/14 15:21:21 christos Exp $";
#endif
static char sccsid[] = "@(#)lstInsert.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstInt.h,v 1.6 1995/11/10 21:27:27 cgd Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -35,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
* @(#)lstInt.h 8.2 (Berkeley) 4/28/95
*/
/*-
@ -45,7 +43,6 @@
#ifndef _LSTINT_H_
#define _LSTINT_H_
#include "make.h"
#include "lst.h"
typedef struct ListNode {
@ -90,7 +87,7 @@ typedef struct {
* PAlloc (var, ptype) --
* Allocate a pointer-typedef structure 'ptype' into the variable 'var'
*/
#define PAlloc(var,ptype) var = (ptype) emalloc (sizeof (*var))
#define PAlloc(var,ptype) var = (ptype) malloc (sizeof (*var))
/*
* LstValid (l) --

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstIsAtEnd.c,v 1.4 1995/06/14 15:21:25 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.4 1995/06/14 15:21:25 christos Exp $";
#endif
static char sccsid[] = "@(#)lstIsAtEnd.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstIsEmpty.c,v 1.4 1995/06/14 15:21:27 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstIsEmpty.c,v 1.4 1995/06/14 15:21:27 christos Exp $";
#endif
static char sccsid[] = "@(#)lstIsEmpty.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstLast.c,v 1.4 1995/06/14 15:21:29 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstLast.c,v 1.4 1995/06/14 15:21:29 christos Exp $";
#endif
static char sccsid[] = "@(#)lstLast.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstMember.c,v 1.4 1995/06/14 15:21:32 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstMember.c,v 1.4 1995/06/14 15:21:32 christos Exp $";
#endif
static char sccsid[] = "@(#)lstMember.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstNext.c,v 1.4 1995/06/14 15:21:35 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstNext.c,v 1.4 1995/06/14 15:21:35 christos Exp $";
#endif
static char sccsid[] = "@(#)lstNext.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstOpen.c,v 1.4 1995/06/14 15:21:37 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.4 1995/06/14 15:21:37 christos Exp $";
#endif
static char sccsid[] = "@(#)lstOpen.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstRemove.c,v 1.4 1995/06/14 15:21:39 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.4 1995/06/14 15:21:39 christos Exp $";
#endif
static char sccsid[] = "@(#)lstRemove.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstReplace.c,v 1.4 1995/06/14 15:21:41 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.4 1995/06/14 15:21:41 christos Exp $";
#endif
static char sccsid[] = "@(#)lstReplace.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: lstSucc.c,v 1.4 1995/06/14 15:21:42 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,11 +35,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.4 1995/06/14 15:21:42 christos Exp $";
#endif
static char sccsid[] = "@(#)lstSucc.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*-

View File

@ -1,5 +1,3 @@
/* $NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -45,11 +43,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $";
#endif
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -85,10 +79,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $
#include <sys/resource.h>
#include <sys/signal.h>
#include <sys/stat.h>
#ifndef MACHINE
#include <sys/utsname.h>
#endif
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -105,7 +96,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.30 1996/08/13 16:42:08 christos Exp $
#ifndef DEFMAXLOCAL
#define DEFMAXLOCAL DEFMAXJOBS
#endif /* DEFMAXLOCAL */
#endif DEFMAXLOCAL
#define MAKEFLAGS ".MAKEFLAGS"
@ -116,9 +107,7 @@ Boolean allPrecious; /* .PRECIOUS given on line by itself */
static Boolean noBuiltins; /* -r flag */
static Lst makefiles; /* ordered list of makefiles to read */
static Boolean printVars; /* print value of one or more vars */
static Lst variables; /* list of variables to print */
int maxJobs; /* -j argument */
int maxJobs; /* -J argument */
static int maxLocal; /* -L argument */
Boolean compatMake; /* -B argument */
Boolean debug; /* -d flag */
@ -133,10 +122,8 @@ Boolean oldVars; /* variable substitution style */
Boolean checkEnvFirst; /* -e flag */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
static void MainParseArgs __P((int, char **));
char * chdir_verify_path __P((char *, char *));
static int ReadMakefile __P((ClientData, ClientData));
static void usage __P((void));
static Boolean ReadMakefile();
static void usage();
static char *curdir; /* startup directory */
static char *objdir; /* where we chdir'ed to */
@ -163,13 +150,12 @@ MainParseArgs(argc, argv)
extern int optind;
extern char *optarg;
int c;
int forceJobs = 0;
optind = 1; /* since we're called more than once */
#ifdef REMOTE
# define OPTFLAGS "BD:I:L:PSV:d:ef:ij:km:nqrst"
#ifdef notyet
# define OPTFLAGS "BD:I:L:PSd:ef:ij:knqrst"
#else
# define OPTFLAGS "BD:I:PSV:d:ef:ij:km:nqrst"
# define OPTFLAGS "D:I:d:ef:ij:knqrst"
#endif
rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
switch(c) {
@ -183,22 +169,15 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
case 'V':
printVars = TRUE;
(void)Lst_AtEnd(variables, (ClientData)optarg);
Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
#ifdef notyet
case 'B':
compatMake = TRUE;
break;
#ifdef REMOTE
case 'L':
maxLocal = atoi(optarg);
Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
#endif
case 'P':
usePipes = FALSE;
Var_Append(MAKEFLAGS, "-P", VAR_GLOBAL);
@ -207,6 +186,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
keepgoing = FALSE;
Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL);
break;
#endif
case 'd': {
char *modules = optarg;
@ -274,11 +254,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
break;
case 'j':
forceJobs = TRUE;
maxJobs = atoi(optarg);
#ifndef REMOTE
maxLocal = maxJobs;
#endif
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
@ -286,11 +262,6 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
keepgoing = TRUE;
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
break;
case 'm':
Dir_AddDir(sysIncPath, optarg);
Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
case 'n':
noExecute = TRUE;
Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
@ -318,13 +289,6 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
}
}
/*
* Be compatible if user did not specify -j and did not explicitly
* turned compatibility on
*/
if (!compatMake && !forceJobs)
compatMake = TRUE;
oldVars = TRUE;
/*
@ -345,7 +309,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
optind = 1; /* - */
goto rearg;
}
(void)Lst_AtEnd(create, (ClientData)estrdup(*argv));
(void)Lst_AtEnd(create, (ClientData)strdup(*argv));
}
}
@ -382,34 +346,6 @@ Main_ParseArgLine(line)
MainParseArgs(argc, argv);
}
char *
chdir_verify_path(path, obpath)
char *path;
char *obpath;
{
struct stat sb;
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
if (chdir(path)) {
(void)fprintf(stderr, "make warning: %s: %s.\n",
path, strerror(errno));
return 0;
}
else {
if (path[0] != '/') {
(void) snprintf(obpath, MAXPATHLEN, "%s/%s",
curdir, path);
return obpath;
}
else
return path;
}
}
return 0;
}
/*-
* main --
* The main function, for obvious reasons. Initializes variables
@ -435,29 +371,13 @@ main(argc, argv)
Lst targs; /* target nodes to create -- passed to Make_Init */
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
struct stat sb, sa;
char *p, *p1, *path, *pathp, *pwd;
char *p, *p1, *path, *pwd, *getenv(), *getwd();
char mdpath[MAXPATHLEN + 1];
char obpath[MAXPATHLEN + 1];
char cdpath[MAXPATHLEN + 1];
struct utsname utsname;
char *machine = getenv("MACHINE");
Lst sysMkPath; /* Path of sys.mk */
char *cp = NULL, *start;
/* avoid faults on read-only strings */
static char syspath[] = _PATH_DEFSYSPATH;
#ifdef RLIMIT_NOFILE
/*
* get rid of resource limit on file descriptors
*/
{
struct rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&
rl.rlim_cur != rl.rlim_max) {
rl.rlim_cur = rl.rlim_max;
(void) setrlimit(RLIMIT_NOFILE, &rl);
}
}
#endif
/*
* Find where we are and take care of PWD for the automounter...
* All this code is so that we know where we are when we start up
@ -490,53 +410,62 @@ main(argc, argv)
* MACHINE_ARCH is always known at compile time.
*/
if (!machine) {
#ifndef MACHINE
struct utsname utsname;
if (uname(&utsname) == -1) {
if (uname(&utsname)) {
perror("make: uname");
exit(2);
}
machine = utsname.machine;
#else
machine = MACHINE;
#endif
}
/*
* If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
* exists, change into it and build there. (If a .${MACHINE} suffix
* exists, use that directory instead).
* Otherwise check MAKEOBJDIRPREFIX`cwd` (or by default,
* _PATH_OBJDIRPREFIX`cwd`) and build there if it exists.
* If all fails, use the current directory to build.
*
* Once things are initted,
* have to add the original directory to the search path,
* if the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
* exists, change into it and build there. Once things are
* initted, have to add the original directory to the search path,
* and modify the paths for the Makefiles apropriately. The
* current directory is also placed as a variable for make scripts.
*/
if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {
if (!(path = getenv("MAKEOBJDIR"))) {
path = _PATH_OBJDIR;
pathp = _PATH_OBJDIRPREFIX;
(void) snprintf(mdpath, MAXPATHLEN, "%s.%s",
path, machine);
if (!(objdir = chdir_verify_path(mdpath, obpath)))
if (!(objdir=chdir_verify_path(path, obpath))) {
(void) snprintf(mdpath, MAXPATHLEN,
"%s%s", pathp, curdir);
if (!(objdir=chdir_verify_path(mdpath,
obpath)))
objdir = curdir;
}
}
else if (!(objdir = chdir_verify_path(path, obpath)))
if (!(path = getenv("MAKEOBJDIR"))) {
path = _PATH_OBJDIR;
(void) sprintf(mdpath, "%s.%s", path, machine);
}
else
(void) strncpy(mdpath, path, MAXPATHLEN + 1);
if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
if (chdir(mdpath)) {
(void)fprintf(stderr, "make warning: %s: %s.\n",
mdpath, strerror(errno));
objdir = curdir;
}
else {
if (mdpath[0] != '/') {
(void) sprintf(obpath, "%s/%s", curdir, mdpath);
objdir = obpath;
}
else
objdir = mdpath;
}
}
else {
(void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
if (!(objdir = chdir_verify_path(mdpath, obpath)))
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
if (chdir(path)) {
(void)fprintf(stderr, "make warning: %s: %s.\n",
path, strerror(errno));
objdir = curdir;
}
else {
if (path[0] != '/') {
(void) sprintf(obpath, "%s/%s", curdir,
path);
objdir = obpath;
}
else
objdir = obpath;
}
}
else
objdir = curdir;
}
@ -544,8 +473,6 @@ main(argc, argv)
create = Lst_Init(FALSE);
makefiles = Lst_Init(FALSE);
printVars = FALSE;
variables = Lst_Init(FALSE);
beSilent = FALSE; /* Print commands as executed */
ignoreErrors = FALSE; /* Pay attention to non-zero returns */
noExecute = FALSE; /* Execute all commands */
@ -558,13 +485,13 @@ main(argc, argv)
debug = 0; /* No debug verbosity, please. */
jobsRunning = FALSE;
maxLocal = DEFMAXLOCAL; /* Set default local max concurrency */
#ifdef REMOTE
maxJobs = DEFMAXJOBS; /* Set default max concurrency */
#else
maxJobs = maxLocal;
#endif
maxLocal = DEFMAXLOCAL; /* Set default local max concurrency */
#ifdef notyet
compatMake = FALSE; /* No compat mode */
#else
compatMake = TRUE; /* No compat mode */
#endif
/*
@ -639,41 +566,13 @@ main(argc, argv)
} else
Var_Set(".TARGETS", "", VAR_GLOBAL);
/*
* If no user-supplied system path was given (through the -m option)
* add the directories from the DEFSYSPATH (more than one may be given
* as dir1:...:dirn) to the system include path.
* Read in the built-in rules first, followed by the specified makefile,
* if it was (makefile != (char *) NULL), or the default Makefile and
* makefile, in that order, if it wasn't.
*/
if (Lst_IsEmpty(sysIncPath)) {
for (start = syspath; *start != '\0'; start = cp) {
for (cp = start; *cp != '\0' && *cp != ':'; cp++)
continue;
if (*cp == '\0') {
Dir_AddDir(sysIncPath, start);
} else {
*cp++ = '\0';
Dir_AddDir(sysIncPath, start);
}
}
}
/*
* Read in the built-in rules first, followed by the specified
* makefile, if it was (makefile != (char *) NULL), or the default
* Makefile and makefile, in that order, if it wasn't.
*/
if (!noBuiltins) {
LstNode ln;
sysMkPath = Lst_Init (FALSE);
Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
if (Lst_IsEmpty(sysMkPath))
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile);
if (ln != NILLNODE)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
}
if (!noBuiltins && !ReadMakefile(_PATH_DEFSYSMK))
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
@ -681,10 +580,10 @@ main(argc, argv)
ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
if (ln != NILLNODE)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
} else if (!ReadMakefile("makefile", NULL))
(void)ReadMakefile("Makefile", NULL);
} else if (!ReadMakefile("makefile"))
(void)ReadMakefile("Makefile");
(void)ReadMakefile(".depend", NULL);
(void)ReadMakefile(".depend");
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
if (p1)
@ -742,21 +641,6 @@ main(argc, argv)
if (DEBUG(GRAPH1))
Targ_PrintGraph(1);
/* print the values of any variables requested by the user */
if (printVars) {
LstNode ln;
for (ln = Lst_First(variables); ln != NILLNODE;
ln = Lst_Succ(ln)) {
char *value = Var_Value((char *)Lst_Datum(ln),
VAR_GLOBAL, &p1);
printf("%s\n", value ? value : "");
if (p1)
free(p1);
}
}
/*
* Have now read the entire graph and need to make a list of targets
* to create. If none was given on the command line, we consult the
@ -767,7 +651,11 @@ main(argc, argv)
else
targs = Targ_FindList(create, TARG_CREATE);
if (!compatMake && !printVars) {
/*
* this was original amMake -- want to allow parallelism, so put this
* back in, eventually.
*/
if (!compatMake) {
/*
* Initialize job module before traversing the graph, now that
* any .BEGIN and .END targets have been read. This is done
@ -783,16 +671,14 @@ main(argc, argv)
/* Traverse the graph, checking on all the targets */
outOfDate = Make_Run(targs);
} else if (!printVars) {
} else
/*
* Compat_Init will take care of creating all the targets as
* well as initializing the module.
*/
Compat_Run(targs);
}
Lst_Destroy(targs, NOFREE);
Lst_Destroy(variables, NOFREE);
Lst_Destroy(makefiles, NOFREE);
Lst_Destroy(create, (void (*) __P((ClientData))) free);
@ -825,11 +711,10 @@ main(argc, argv)
* lots
*/
static Boolean
ReadMakefile(p, q)
ClientData p, q;
ReadMakefile(fname)
char *fname; /* makefile to read */
{
char *fname = p; /* makefile to read */
extern Lst parseIncPath;
extern Lst parseIncPath, sysIncPath;
FILE *stream;
char *name, path[MAXPATHLEN + 1];
@ -866,142 +751,6 @@ found: Var_Set("MAKEFILE", fname, VAR_GLOBAL);
return(TRUE);
}
/*-
* Cmd_Exec --
* Execute the command in cmd, and return the output of that command
* in a string.
*
* Results:
* A string containing the output of the command, or the empty string
* If err is not NULL, it contains the reason for the command failure
*
* Side Effects:
* The string must be freed by the caller.
*/
char *
Cmd_Exec(cmd, err)
char *cmd;
char **err;
{
char *args[4]; /* Args for invoking the shell */
int fds[2]; /* Pipe streams */
int cpid; /* Child PID */
int pid; /* PID from wait() */
char *res; /* result */
int status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
int cc;
*err = NULL;
/*
* Set up arguments for shell
*/
args[0] = "sh";
args[1] = "-c";
args[2] = cmd;
args[3] = NULL;
/*
* Open a pipe for fetching its output
*/
if (pipe(fds) == -1) {
*err = "Couldn't create pipe for \"%s\"";
goto bad;
}
/*
* Fork
*/
switch (cpid = vfork()) {
case 0:
/*
* Close input side of pipe
*/
(void) close(fds[0]);
/*
* Duplicate the output stream to the shell's output, then
* shut the extra thing down. Note we don't fetch the error
* stream...why not? Why?
*/
(void) dup2(fds[1], 1);
(void) close(fds[1]);
(void) execv("/bin/sh", args);
_exit(1);
/*NOTREACHED*/
case -1:
*err = "Couldn't exec \"%s\"";
goto bad;
default:
/*
* No need for the writing half
*/
(void) close(fds[1]);
buf = Buf_Init (MAKE_BSIZE);
do {
char result[BUFSIZ];
cc = read(fds[0], result, sizeof(result));
if (cc > 0)
Buf_AddBytes(buf, cc, (Byte *) result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
/*
* Close the input side of the pipe.
*/
(void) close(fds[0]);
/*
* Wait for the process to exit.
*/
while(((pid = wait(&status)) != cpid) && (pid >= 0))
continue;
res = (char *)Buf_GetAll (buf, &cc);
Buf_Destroy (buf, FALSE);
if (cc == 0)
*err = "Couldn't read shell's output for \"%s\"";
if (status)
*err = "\"%s\" returned non-zero status";
/*
* Null-terminate the result, convert newlines to spaces and
* install it in the variable.
*/
res[cc] = '\0';
cp = &res[cc] - 1;
if (*cp == '\n') {
/*
* A final newline is just stripped
*/
*cp-- = '\0';
}
while (cp >= res) {
if (*cp == '\n') {
*cp = ' ';
}
cp--;
}
break;
}
return res;
bad:
res = emalloc(1);
*res = '\0';
return res;
}
/*-
* Error --
* Print an error message given its format.
@ -1159,46 +908,17 @@ Finish(errors)
* emalloc --
* malloc, but die on error.
*/
void *
char *
emalloc(len)
size_t len;
{
void *p;
if ((p = malloc(len)) == NULL)
enomem();
return(p);
}
/*
* estrdup --
* strdup, but die on error.
*/
char *
estrdup(str)
const char *str;
{
char *p;
if ((p = strdup(str)) == NULL)
if ((p = (char *) malloc(len)) == NULL)
enomem();
return(p);
}
/*
* erealloc --
* realloc, but die on error.
*/
void *
erealloc(ptr, size)
void *ptr;
size_t size;
{
if ((ptr = realloc(ptr, size)) == NULL)
enomem();
return(ptr);
}
/*
* enomem --
* die when out of memory.
@ -1210,26 +930,6 @@ enomem()
exit(2);
}
/*
* enunlink --
* Remove a file carefully, avoiding directories.
*/
int
eunlink(file)
const char *file;
{
struct stat st;
if (lstat(file, &st) == -1)
return -1;
if (S_ISDIR(st.st_mode)) {
errno = EISDIR;
return -1;
}
return unlink(file);
}
/*
* usage --
* exit with usage message
@ -1238,9 +938,8 @@ static void
usage()
{
(void)fprintf(stderr,
"usage: make [-Beiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
[-I directory] [-j max_jobs] [-m directory] [-V variable]\n\
[variable=value] [target ...]\n");
"usage: make [-eiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
[-I directory] [-j max_jobs] [variable=value]\n");
exit(2);
}

View File

@ -1,5 +1,3 @@
.\" $NetBSD: make.1,v 1.15 1996/08/30 17:59:40 thorpej Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@ -31,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\" @(#)make.1 8.8 (Berkeley) 6/13/95
.\"
.Dd March 19, 1994
.Dd June 13, 1995
.Dt MAKE 1
.Os
.Sh NAME
@ -41,16 +39,14 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm make
.Op Fl Beiknqrst
.Op Fl eiknqrstv
.Op Fl D Ar variable
.Op Fl d Ar flags
.Op Fl f Ar makefile
.Op Fl I Ar directory
.Bk -words
.Op Fl j Ar max_jobs
.Op Fl m Ar directory
.Ek
.Op Fl V Ar variable
.Op Ar variable=value
.Op Ar target ...
.Sh DESCRIPTION
@ -77,9 +73,6 @@ and makefiles, please refer to
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl B
Try to be backwards compatible by executing a single shell per command and
by executing the commands to make the sources of a dependency line in sequence.
.It Fl D Ar variable
Define
.Ar variable
@ -133,9 +126,8 @@ standard input is read.
Multiple makefile's may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
The system makefile directory (or directories, see the
.Fl m
option) is automatically included as part of this list.
The system makefile directory is automatically included as part of this
list.
.It Fl i
Ignore non-zero exit of shell commands in the makefile.
Equivalent to specifying
@ -144,20 +136,10 @@ before each command line in the makefile.
.It Fl j Ar max_jobs
Specify the maximum number of jobs that
.Nm make
may have running at any one time. Turns compatibility mode off, unless the
.Ar B
flag is also specified.
may have running at any one time.
.It Fl k
Continue processing after errors are encountered, but only on those targets
that do not depend on the target whose creation caused the error.
.It Fl m Ar directory
Specify a directory in which to search for sys.mk and makefiles included
via the <...> style. Multiple directories can be added to form a search path.
This path will override the default system include path: /usr/share/mk.
Furthermore the system include path will be appended to the search path used
for "..."-style inclusions (see the
.Fl I
option).
.It Fl n
Display the commands that would have been executed, but do not actually
execute them.
@ -174,16 +156,6 @@ before each command line in the makefile.
.It Fl t
Rather than re-building a target as specified in the makefile, create it
or update its modification time to make it appear up-to-date.
.It Fl V Ar variable
Print
.Nm make Ns 's
idea of the value of
.Ar variable ,
in the global context.
Do not build any targets.
Multiple instances of this option may be specified;
the variables will be printed one per line,
with a blank line for each null or undefined variable.
.It Ar variable=value
Set the value of the variable
.Ar variable
@ -428,28 +400,6 @@ variable which is then
entered into the environment for all programs which
.Nm make
executes.
.It Ev PWD
Alternate path to the current directory.
.Nm make
normally sets
.Ql Va .CURDIR
to the canonical path given by
.Xr getcwd 2 .
However, if the environment variable
.Ql Ev PWD
is set and gives a path to the current directory, then
.Nm make
sets
.Ql Va .CURDIR
to the value of
.Ql Ev PWD
instead.
.Ql Ev PWD
is set to the value of
.Ql Va .OBJDIR
for all programs which
.Nm make
executes.
.El
.Pp
Variable expansion may be modified to select or modify each word of the
@ -679,7 +629,7 @@ As in C,
.Nm make
will only evaluate a conditional as far as is necessary to determine
its value.
Parentheses may be used to change the order of evaluation.
Parenthesis may be used to change the order of evaluation.
The boolean operator
.Ql Ic \&!
may be used to logically negate an entire
@ -810,6 +760,12 @@ If a target is marked with this attribute and
.Nm make
can't figure out how to create it, it will ignore this fact and assume
the file isn't needed or already exists.
.It Ic .PHONY
If this special target is present in a Makefile, all sources for the
target will considered to be `phony' targets. I.e. they don't refer
to real files, and they will always be considered out-of-date. This
is useful in case one wants to create a target called `install', in
a directory where a file `install' already exists.
.It Ic .PRECIOUS
When
.Nm make
@ -832,12 +788,6 @@ If the target already has commands, the
.Ic .USE
target's commands are appended
to them.
.It Ic .WAIT
If special
.Ic .WAIT
source is appears in a dependency line, the sources that precede it are
made before the sources that succeed it in the line. Loops are not being
detected and targets that form loops will be silently ignored.
.El
.Sh "SPECIAL TARGETS"
Special targets may not be included with other targets, i.e. they must be
@ -886,30 +836,11 @@ The flags are as if typed to the shell, though the
.Fl f
option will have
no effect.
.\" XXX: NOT YET!!!!
.\" .It Ic .NOTPARALLEL
.\" The named targets are executed in non parallel mode. If no targets are
.\" specified, then all targets are executed in non parallel mode.
.It Ic .NOTPARALLEL
Disable parallel mode.
.It Ic .NO_PARALLEL
Same as above, for compatibility with other pmake variants.
.It Ic .ORDER
The named targets are made in sequence.
.\" XXX: NOT YET!!!!
.\" .It Ic .PARALLEL
.\" The named targets are executed in parallel mode. If no targets are
.\" specified, then all targets are executed in parallel mode.
.It Ic .PATH
The sources are directories which are to be searched for files not
found in the current directory.
If no sources are specified, any previously specified directories are
deleted.
.It Ic .PHONY
Apply the
.Ic .PHONY
attribute to any specified sources. Targets with this attribute are always
considered to be out of date.
.It Ic .PRECIOUS
Apply the
.Ic .PRECIOUS
@ -933,12 +864,10 @@ If no sources are specified, any previous specified suffices are deleted.
.Sh ENVIRONMENT
.Nm Make
utilizes the following environment variables, if they exist:
.Ev MACHINE ,
.Ev MAKE ,
.Ev MAKEFLAGS ,
.Ev MAKEOBJDIR ,
.Ev MAKEFLAGS
and
.Ev PWD .
.Ev MAKEOBJDIR .
.Sh FILES
.Bl -tag -width /usr/share/mk -compact
.It .depend

View File

@ -1,5 +1,3 @@
/* $NetBSD: make.c,v 1.9 1996/08/30 23:21:10 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$NetBSD: make.c,v 1.9 1996/08/30 23:21:10 christos Exp $";
#endif
static char sccsid[] = "@(#)make.c 8.3 (Berkeley) 6/13/95";
#endif /* not lint */
/*-
@ -159,7 +153,7 @@ Make_OODate (gn)
* Certain types of targets needn't even be sought as their datedness
* doesn't depend on their modification time...
*/
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_PHONY)) == 0) {
(void) Dir_MTime (gn);
if (DEBUG(MAKE)) {
if (gn->mtime != 0) {
@ -184,7 +178,14 @@ Make_OODate (gn)
* These weird rules are brought to you by Backward-Compatability and
* the strange people who wrote 'Make'.
*/
if (gn->type & OP_USE) {
if (gn->type & OP_PHONY) {
/*
* A PHONY node is always out of date
*/
if (DEBUG(MAKE))
printf("phony...");
return TRUE;
} else if (gn->type & OP_USE) {
/*
* If the node is a USE node it is *never* out of date
* no matter *what*.
@ -213,7 +214,7 @@ Make_OODate (gn)
printf(".JOIN node...");
}
oodate = gn->childMade;
} else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
} else if (gn->type & (OP_FORCE|OP_EXEC)) {
/*
* A node which is the object of the force (!) operator or which has
* the .EXEC attribute is always considered out-of-date.
@ -221,8 +222,6 @@ Make_OODate (gn)
if (DEBUG(MAKE)) {
if (gn->type & OP_FORCE) {
printf("! operator...");
} else if (gn->type & OP_PHONY) {
printf(".PHONY node...");
} else {
printf(".EXEC node...");
}
@ -578,16 +577,9 @@ MakeAddAllSrc (cgnp, pgnp)
GNode *pgn = (GNode *) pgnp;
if ((cgn->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) == 0) {
char *child;
char *p1 = NULL;
char *p1;
if (OP_NOP(cgn->type)) {
/*
* this node is only source; use the specific pathname for it
*/
child = cgn->path ? cgn->path : cgn->name;
}
else
child = Var_Value(TARGET, cgn, &p1);
child = Var_Value(TARGET, cgn, &p1);
Var_Append (ALLSRC, child, pgn);
if (pgn->type & OP_JOIN) {
if (cgn->made == MADE) {

View File

@ -1,5 +1,3 @@
/* $NetBSD: make.h,v 1.10 1996/08/13 16:39:30 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)make.h 8.3 (Berkeley) 6/13/95
* @(#)make.h 8.3 (Berkeley) 6/13/95
*/
/*-
@ -52,17 +50,15 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if !defined(MAKE_BOOTSTRAP) && defined(BSD)
#ifndef MAKE_BOOTSTRAP
#include <sys/cdefs.h>
#else
#ifndef __P
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else
#define __P(protos) () /* traditional C preprocessor */
#endif
#endif
#endif
#if __STDC__
#include <stdlib.h>
#include <unistd.h>
@ -104,7 +100,6 @@ typedef struct GNode {
char *name; /* The target's name */
char *path; /* The full pathname of the file */
int type; /* Its type (see the OP flags, below) */
int order; /* Its wait weight */
Boolean make; /* TRUE if this target needs to be remade */
enum {
@ -328,8 +323,6 @@ extern time_t now; /* The time at the start of this whole
extern Boolean oldVars; /* Do old-style variable substitution */
extern Lst sysIncPath; /* The system include path. */
/*
* debug control:
* There is one bit per module. It is up to the module what debug

View File

@ -1,5 +1,3 @@
/* $NetBSD: nonints.h,v 1.11 1996/08/13 16:42:11 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
* @(#)nonints.h 8.4 (Berkeley) 4/28/95
*/
/* arch.c */
@ -65,18 +63,14 @@ void For_Run __P((void));
/* main.c */
void Main_ParseArgLine __P((char *));
int main __P((int, char **));
char *Cmd_Exec __P((char *, char **));
void Error __P((char *, ...));
void Fatal __P((char *, ...));
void Punt __P((char *, ...));
void DieHorribly __P((void));
int PrintAddr __P((ClientData, ClientData));
void Finish __P((int));
char *estrdup __P((const char *));
void *emalloc __P((size_t));
void *erealloc __P((void *, size_t));
char *emalloc __P((size_t));
void enomem __P((void));
int eunlink __P((const char *));
/* parse.c */
void Parse_Error __P((int, char *, ...));

View File

@ -1,5 +1,3 @@
/* $NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
static char rcsid[] = "$NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $";
#endif
static char sccsid[] = "@(#)parse.c 8.6 (Berkeley) 6/13/95";
#endif /* not lint */
/*-
@ -96,6 +90,7 @@ static char rcsid[] = "$NetBSD: parse.c,v 1.26 1996/09/27 02:36:58 thorpej Exp $
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <sys/wait.h>
#include "make.h"
#include "hash.h"
#include "dir.h"
@ -167,20 +162,17 @@ typedef enum {
NotParallel, /* .NOTPARALELL */
Null, /* .NULL */
Order, /* .ORDER */
Parallel, /* .PARALLEL */
ExPath, /* .PATH */
Phony, /* .PHONY */
Precious, /* .PRECIOUS */
Reserved, /* .RESERVED or .[A-Z]* */
ExShell, /* .SHELL */
Silent, /* .SILENT */
SingleShell, /* .SINGLESHELL */
Suffixes, /* .SUFFIXES */
Wait, /* .WAIT */
Attribute /* Generic attribute */
} ParseSpecial;
static ParseSpecial specType;
static int waiting;
/*
* Predecessor node for handling .ORDER. Initialized to NILGNODE when .ORDER
@ -200,44 +192,70 @@ static struct {
ParseSpecial spec; /* Type when used as a target */
int op; /* Operator when used as a source */
} parseKeywords[] = {
#define DOT_BEGIN 0
{ ".BEGIN", Begin, 0 },
#define DOT_DEFAULT 1
{ ".DEFAULT", Default, 0 },
#define DOT_END 2
{ ".END", End, 0 },
#define DOT_EXEC 3
{ ".EXEC", Attribute, OP_EXEC },
#define DOT_IGNORE 4
{ ".IGNORE", Ignore, OP_IGNORE },
#define DOT_INCLUDES 5
{ ".INCLUDES", Includes, 0 },
#define DOT_INTERRUPT 6
{ ".INTERRUPT", Interrupt, 0 },
#define DOT_INVISIBLE 7
{ ".INVISIBLE", Attribute, OP_INVISIBLE },
#define DOT_JOIN 8
{ ".JOIN", Attribute, OP_JOIN },
#define DOT_LIBS 9
{ ".LIBS", Libs, 0 },
#define DOT_MAIN 10
{ ".MAIN", Main, 0 },
#define DOT_MAKE 11
{ ".MAKE", Attribute, OP_MAKE },
#define DOT_MAKEFLAGS 12
{ ".MAKEFLAGS", MFlags, 0 },
#define DOT_MFLAGS 13
{ ".MFLAGS", MFlags, 0 },
#define DOT_NOTMAIN 14
{ ".NOTMAIN", Attribute, OP_NOTMAIN },
#define DOT_NOTPARALLEL 15
{ ".NOTPARALLEL", NotParallel, 0 },
{ ".NO_PARALLEL", NotParallel, 0 },
#define DOT_NULL 16
{ ".NULL", Null, 0 },
#define DOT_OPTIONAL 17
{ ".OPTIONAL", Attribute, OP_OPTIONAL },
#define DOT_ORDER 18
{ ".ORDER", Order, 0 },
{ ".PARALLEL", Parallel, 0 },
#define DOT_PATH 19
{ ".PATH", ExPath, 0 },
{ ".PHONY", Phony, OP_PHONY },
#define DOT_PHONY 20
{ ".PHONY", Attribute, OP_PHONY },
#define DOT_PRECIOUS 21
{ ".PRECIOUS", Precious, OP_PRECIOUS },
#define DOT_RECURSIVE 22
{ ".RECURSIVE", Attribute, OP_MAKE },
#define DOT_RESERVED 23
{ ".RESERVED", Reserved, 0 },
#define DOT_SHELL 24
{ ".SHELL", ExShell, 0 },
#define DOT_SILENT 25
{ ".SILENT", Silent, OP_SILENT },
#define DOT_SINGLESHELL 26
{ ".SINGLESHELL", SingleShell, 0 },
#define DOT_SUFFIXES 27
{ ".SUFFIXES", Suffixes, 0 },
#define DOT_USE 28
{ ".USE", Attribute, OP_USE },
{ ".WAIT", Wait, 0 },
};
static int ParseFindKeyword __P((char *));
static int ParseLinkSrc __P((ClientData, ClientData));
static int ParseDoOp __P((ClientData, ClientData));
static int ParseAddDep __P((ClientData, ClientData));
static void ParseDoSrc __P((int, char *, Lst));
static void ParseDoSrc __P((int, char *));
static int ParseFindMain __P((ClientData, ClientData));
static int ParseAddDir __P((ClientData, ClientData));
static int ParseClearPath __P((ClientData, ClientData));
@ -291,7 +309,12 @@ ParseFindKeyword (str)
start = cur + 1;
}
} while (start <= end);
return (-1);
cur = 0;
for (++str; *str; str++)
if (!isupper((unsigned char) *str))
break;
return *str ? -1 : DOT_RESERVED;
}
/*-
@ -449,45 +472,6 @@ ParseDoOp (gnp, opp)
return (0);
}
/*-
*---------------------------------------------------------------------
* ParseAddDep --
* Check if the pair of GNodes given needs to be synchronized.
* This has to be when two nodes are on different sides of a
* .WAIT directive.
*
* Results:
* Returns 1 if the two targets need to be ordered, 0 otherwise.
* If it returns 1, the search can stop
*
* Side Effects:
* A dependency can be added between the two nodes.
*
*---------------------------------------------------------------------
*/
int
ParseAddDep(pp, sp)
ClientData pp;
ClientData sp;
{
GNode *p = (GNode *) pp;
GNode *s = (GNode *) sp;
if (p->order < s->order) {
/*
* XXX: This can cause loops, and loops can cause unmade targets,
* but checking is tedious, and the debugging output can show the
* problem
*/
(void)Lst_AtEnd(p->successors, (ClientData)s);
(void)Lst_AtEnd(s->preds, (ClientData)p);
return 0;
}
else
return 1;
}
/*-
*---------------------------------------------------------------------
* ParseDoSrc --
@ -506,31 +490,23 @@ ParseAddDep(pp, sp)
*---------------------------------------------------------------------
*/
static void
ParseDoSrc (tOp, src, allsrc)
ParseDoSrc (tOp, src)
int tOp; /* operator (if any) from special targets */
char *src; /* name of the source to handle */
Lst allsrc; /* List of all sources to wait for */
{
GNode *gn = NULL;
int op; /* operator (if any) from special source */
GNode *gn;
op = 0;
if (*src == '.' && isupper (src[1])) {
int keywd = ParseFindKeyword(src);
if (keywd != -1) {
int op = parseKeywords[keywd].op;
if (op != 0) {
Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
return;
}
if (parseKeywords[keywd].spec == Wait) {
waiting++;
return;
}
op = parseKeywords[keywd].op;
}
}
switch (specType) {
case Main:
if (op != 0) {
Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
} else if (specType == Main) {
/*
* If we have noted the existence of a .MAIN, it means we need
* to add the sources of said target to the list of things
@ -539,15 +515,13 @@ ParseDoSrc (tOp, src, allsrc)
* invoked if the user didn't specify a target on the command
* line. This is to allow #ifmake's to succeed, or something...
*/
(void) Lst_AtEnd (create, (ClientData)estrdup(src));
(void) Lst_AtEnd (create, (ClientData)strdup(src));
/*
* Add the name to the .TARGETS variable as well, so the user cna
* employ that, if desired.
*/
Var_Append(".TARGETS", src, VAR_GLOBAL);
return;
case Order:
} else if (specType == Order) {
/*
* Create proper predecessor/successor links between the previous
* source and the current one.
@ -561,9 +535,7 @@ ParseDoSrc (tOp, src, allsrc)
* The current source now becomes the predecessor for the next one.
*/
predecessor = gn;
break;
default:
} else {
/*
* If the source is not an attribute, we need to find/create
* a node for it. After that we can apply any operator to it
@ -594,13 +566,6 @@ ParseDoSrc (tOp, src, allsrc)
}
}
}
break;
}
gn->order = waiting;
(void)Lst_AtEnd(allsrc, (ClientData)gn);
if (waiting) {
Lst_ForEach(allsrc, ParseAddDep, (ClientData)gn);
}
}
@ -723,20 +688,16 @@ ParseDoDependency (line)
Lst paths; /* List of search paths to alter when parsing
* a list of .PATH targets */
int tOp; /* operator from special target */
Lst sources; /* list of archive source names after
* expansion */
Lst sources; /* list of source names after expansion */
Lst curTargs; /* list of target names to be found and added
* to the targets list */
Lst curSrcs; /* list of sources in order */
tOp = 0;
specType = Not;
waiting = 0;
paths = (Lst)NULL;
curTargs = Lst_Init(FALSE);
curSrcs = Lst_Init(FALSE);
do {
for (cp = line;
@ -833,7 +794,6 @@ ParseDoDependency (line)
* life easier later, when we'll
* use Make_HandleUse to actually
* apply the .DEFAULT commands.
* .PHONY The list of targets
* .BEGIN
* .END
* .INTERRUPT Are not to be considered the
@ -880,6 +840,12 @@ ParseDoDependency (line)
case Order:
predecessor = NILGNODE;
break;
case Reserved:
/*
* A posix reserved target that we don't know
* how to deal with.
*/
return;
default:
break;
}
@ -1177,7 +1143,7 @@ ParseDoDependency (line)
while (!Lst_IsEmpty (sources)) {
gn = (GNode *) Lst_DeQueue (sources);
ParseDoSrc (tOp, gn->name, curSrcs);
ParseDoSrc (tOp, gn->name);
}
Lst_Destroy (sources, NOFREE);
cp = line;
@ -1187,7 +1153,7 @@ ParseDoDependency (line)
cp += 1;
}
ParseDoSrc (tOp, line, curSrcs);
ParseDoSrc (tOp, line);
}
while (*cp && isspace (*cp)) {
cp++;
@ -1206,10 +1172,6 @@ ParseDoDependency (line)
Lst_ForEach (targets, ParseFindMain, (ClientData)0);
}
/*
* Finally, destroy the list of sources
*/
Lst_Destroy(curSrcs, NOFREE);
}
/*-
@ -1234,80 +1196,60 @@ Parse_IsVar (line)
{
register Boolean wasSpace = FALSE; /* set TRUE if found a space */
register Boolean haveName = FALSE; /* Set TRUE if have a variable name */
int level = 0;
#define ISEQOPERATOR(c) \
(((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!'))
/*
* Skip to variable name
*/
for (;(*line == ' ') || (*line == '\t'); line++)
continue;
while ((*line == ' ') || (*line == '\t')) {
line++;
}
for (; *line != '=' || level != 0; line++)
switch (*line) {
case '\0':
while (*line != '=') {
if (*line == '\0') {
/*
* end-of-line -- can't be a variable assignment.
*/
return FALSE;
case ' ':
case '\t':
return (FALSE);
} else if ((*line == ' ') || (*line == '\t')) {
/*
* there can be as much white space as desired so long as there is
* only one word before the operator
*/
wasSpace = TRUE;
break;
case '(':
case '{':
level++;
break;
case '}':
case ')':
level--;
break;
default:
if (wasSpace && haveName) {
if (ISEQOPERATOR(*line)) {
/*
* We must have a finished word
*/
if (level != 0)
return FALSE;
/*
* When an = operator [+?!:] is found, the next
* character must be an = or it ain't a valid
* assignment.
*/
if (line[1] == '=')
return haveName;
#ifdef SUNSHCMD
/*
* This is a shell command
*/
if (strncmp(line, ":sh", 3) == 0)
return haveName;
#endif
}
/*
* This is the start of another word, so not assignment.
*/
return FALSE;
} else if (wasSpace && haveName) {
/*
* Stop when an = operator is found.
*/
if ((*line == '+') || (*line == ':') || (*line == '?') ||
(*line == '!')) {
break;
}
else {
haveName = TRUE;
wasSpace = FALSE;
}
break;
/*
* This is the start of another word, so not assignment.
*/
return (FALSE);
} else {
haveName = TRUE;
wasSpace = FALSE;
}
line++;
}
return haveName;
/*
* A final check: if we stopped on a +, ?, ! or :, the next character must
* be an = or it ain't a valid assignment
*/
if (((*line == '+') ||
(*line == '?') ||
(*line == ':') ||
(*line == '!')) &&
(line[1] != '='))
{
return (FALSE);
} else {
return (haveName);
}
}
/*-
@ -1401,17 +1343,6 @@ Parse_DoVar (line, ctxt)
break;
default:
#ifdef SUNSHCMD
while (*opc != ':')
if (--opc < line)
break;
if (strncmp(opc, ":sh", 3) == 0) {
type = VAR_SHELL;
*opc = '\0';
break;
}
#endif
type = VAR_NORMAL;
break;
}
@ -1443,38 +1374,156 @@ Parse_DoVar (line, ctxt)
Var_Set(line, cp, ctxt);
free(cp);
} else if (type == VAR_SHELL) {
Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
* if any variable expansion was performed */
char *res, *err;
char *args[4]; /* Args for invoking the shell */
int fds[2]; /* Pipe streams */
int cpid; /* Child PID */
int pid; /* PID from wait() */
Boolean freeCmd; /* TRUE if the command needs to be freed, i.e.
* if any variable expansion was performed */
if (strchr(cp, '$') != NULL) {
/*
* Avoid clobbered variable warnings by forcing the compiler
* to ``unregister'' variables
*/
#if __GNUC__
(void) &freeCmd;
#endif
/*
* Set up arguments for shell
*/
args[0] = "sh";
args[1] = "-c";
if (strchr(cp, '$') != (char *)NULL) {
/*
* There's a dollar sign in the command, so perform variable
* expansion on the whole thing. The resulting string will need
* freeing when we're done, so set freeCmd to TRUE.
*/
cp = Var_Subst(NULL, cp, VAR_CMD, TRUE);
args[2] = Var_Subst(NULL, cp, VAR_CMD, TRUE);
freeCmd = TRUE;
} else {
args[2] = cp;
freeCmd = FALSE;
}
args[3] = (char *)NULL;
res = Cmd_Exec(cp, &err);
Var_Set(line, res, ctxt);
free(res);
/*
* Open a pipe for fetching its output
*/
pipe(fds);
if (err)
Parse_Error(PARSE_WARNING, err, cp);
/*
* Fork
*/
cpid = vfork();
if (cpid == 0) {
/*
* Close input side of pipe
*/
close(fds[0]);
if (freeCmd)
free(cp);
/*
* Duplicate the output stream to the shell's output, then
* shut the extra thing down. Note we don't fetch the error
* stream...why not? Why?
*/
dup2(fds[1], 1);
close(fds[1]);
execv("/bin/sh", args);
_exit(1);
} else if (cpid < 0) {
/*
* Couldn't fork -- tell the user and make the variable null
*/
Parse_Error(PARSE_WARNING, "Couldn't exec \"%s\"", cp);
Var_Set(line, "", ctxt);
} else {
int status;
int cc;
Buffer buf;
char *res;
/*
* No need for the writing half
*/
close(fds[1]);
buf = Buf_Init (MAKE_BSIZE);
do {
char result[BUFSIZ];
cc = read(fds[0], result, sizeof(result));
if (cc > 0)
Buf_AddBytes(buf, cc, (Byte *) result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
/*
* Close the input side of the pipe.
*/
close(fds[0]);
/*
* Wait for the process to exit.
*/
while(((pid = wait(&status)) != cpid) && (pid >= 0))
continue;
res = (char *)Buf_GetAll (buf, &cc);
Buf_Destroy (buf, FALSE);
if (cc == 0) {
/*
* Couldn't read the child's output -- tell the user and
* set the variable to null
*/
Parse_Error(PARSE_WARNING, "Couldn't read shell's output");
}
if (status) {
/*
* Child returned an error -- tell the user but still use
* the result.
*/
Parse_Error(PARSE_WARNING, "\"%s\" returned non-zero", cp);
}
/*
* Null-terminate the result, convert newlines to spaces and
* install it in the variable.
*/
res[cc] = '\0';
cp = &res[cc] - 1;
if (*cp == '\n') {
/*
* A final newline is just stripped
*/
*cp-- = '\0';
}
while (cp >= res) {
if (*cp == '\n') {
*cp = ' ';
}
cp--;
}
Var_Set(line, res, ctxt);
free(res);
}
if (freeCmd) {
free(args[2]);
}
} else {
/*
* Normal assignment -- just do it.
*/
Var_Set(line, cp, ctxt);
Var_Set (line, cp, ctxt);
}
}
/*-
* ParseAddCmd --
* Lst_ForEach function to add a command line to all targets
@ -1632,20 +1681,17 @@ ParseDoInclude (file)
* leading path components and call Dir_FindFile to see if
* we can locate the beast.
*/
char *prefEnd, *Fname;
char *prefEnd;
/* Make a temporary copy of this, to be safe. */
Fname = estrdup(fname);
prefEnd = strrchr (Fname, '/');
prefEnd = strrchr (fname, '/');
if (prefEnd != (char *)NULL) {
char *newName;
*prefEnd = '\0';
if (file[0] == '/')
newName = estrdup(file);
newName = strdup(file);
else
newName = str_concat (Fname, file, STR_ADDSLASH);
newName = str_concat (fname, file, STR_ADDSLASH);
fullname = Dir_FindFile (newName, parseIncPath);
if (fullname == (char *)NULL) {
fullname = Dir_FindFile(newName, dirSearchPath);
@ -1655,7 +1701,6 @@ ParseDoInclude (file)
} else {
fullname = (char *)NULL;
}
free (Fname);
} else {
fullname = (char *)NULL;
}
@ -1760,7 +1805,7 @@ Parse_FromString(str)
curPTR = (PTR *) emalloc (sizeof (PTR));
curPTR->str = curPTR->ptr = str;
lineno = 0;
fname = estrdup(fname);
fname = strdup(fname);
}
@ -2006,43 +2051,54 @@ ParseSkipLine(skip)
int skip; /* Skip lines that don't start with . */
{
char *line;
int c, lastc, lineLength = 0;
int c, lastc = '\0', lineLength;
Buffer buf;
buf = Buf_Init(MAKE_BSIZE);
c = ParseReadc();
do {
Buf_Discard(buf, lineLength);
lastc = '\0';
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++;
while (((c = ParseReadc()) != '\n' || lastc == '\\')
&& c != EOF) {
if (c == '\n') {
Buf_ReplaceLastByte(buf, (Byte)' ');
lineno++;
lastc = c;
c = ParseReadc ();
}
}
while ((c = ParseReadc()) == ' ' || c == '\t');
if (c == EOF) {
Parse_Error (PARSE_FATAL, "Unclosed conditional/for loop");
return ((char *)NULL);
}
if (c == EOF)
break;
}
/*
* Read the entire line into buf
*/
buf = Buf_Init (MAKE_BSIZE);
if (c != '\n') {
do {
Buf_AddByte (buf, (Byte)c);
c = ParseReadc();
} while ((c != '\n') && (c != EOF));
}
lineno++;
Buf_AddByte(buf, (Byte)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);
Buf_AddByte (buf, (Byte)'\0');
line = (char *)Buf_GetAll (buf, &lineLength);
Buf_Destroy (buf, FALSE);
return line;
}
@ -2186,11 +2242,7 @@ test_char:
break;
case '#':
if (!ignComment) {
if (
#if 0
compatMake &&
#endif
(lastc != '\\')) {
if (compatMake && (lastc != '\\')) {
/*
* If the character is a hash mark and it isn't escaped
* (or we're being compatible), the thing is a comment.
@ -2247,7 +2299,7 @@ test_char:
ep = line;
while (*ep)
++ep;
while (ep > line + 1 && (ep[-1] == ' ' || ep[-1] == '\t')) {
while (ep > line && (ep[-1] == ' ' || ep[-1] == '\t')) {
if (ep > line + 1 && ep[-2] == '\\')
break;
--ep;
@ -2394,8 +2446,9 @@ Parse_File(name, stream)
goto nextLine;
}
}
if (*line == '#') {
/* If we're this far, the line must be a comment. */
if (*line == '#' || *line == '\0') {
/* If we're this far, the line must be a comment.
(Empty lines are ignored as well) */
goto nextLine;
}
@ -2422,13 +2475,12 @@ Parse_File(name, stream)
continue;
} else {
Parse_Error (PARSE_FATAL,
"Unassociated shell command \"%s\"",
"Unassociated shell command \"%.20s\"",
cp);
}
}
#ifdef SYSVINCLUDE
} else if (strncmp (line, "include", 7) == 0 &&
isspace((unsigned char) line[7]) &&
strchr(line, ':') == NULL) {
/*
* It's an S3/S5-style "include".
@ -2537,11 +2589,30 @@ Parse_File(name, stream)
void
Parse_Init ()
{
char *cp = NULL, *start;
/* avoid faults on read-only strings */
static char syspath[] = _PATH_DEFSYSPATH;
mainNode = NILGNODE;
parseIncPath = Lst_Init (FALSE);
sysIncPath = Lst_Init (FALSE);
includes = Lst_Init (FALSE);
targCmds = Lst_Init (FALSE);
/*
* Add the directories from the DEFSYSPATH (more than one may be given
* as dir1:...:dirn) to the system include path.
*/
for (start = syspath; *start != '\0'; start = cp) {
for (cp = start; *cp != '\0' && *cp != ':'; cp++)
continue;
if (*cp == '\0') {
Dir_AddDir(sysIncPath, start);
} else {
*cp++ = '\0';
Dir_AddDir(sysIncPath, start);
}
}
}
void
@ -2578,7 +2649,7 @@ Parse_MainName()
main = Lst_Init (FALSE);
if (mainNode == NILGNODE) {
Punt ("no target to make.");
Punt ("make: no target to make.\n");
/*NOTREACHED*/
} else if (mainNode->type & OP_DOUBLEDEP) {
(void) Lst_AtEnd (main, (ClientData)mainNode);

View File

@ -1,5 +1,3 @@
/* $NetBSD: pathnames.h,v 1.5 1996/08/30 17:59:41 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -32,11 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90
* @(#)pathnames.h 8.2 (Berkeley) 4/28/95
*/
#define _PATH_OBJDIR "obj"
#define _PATH_OBJDIRPREFIX "/usr/obj"
#define _PATH_DEFSHELLDIR "/bin"
#define _PATH_DEFSYSMK "sys.mk"
#define _PATH_DEFSYSPATH "/usr/share/mk"

View File

@ -1,5 +1,3 @@
/* $NetBSD: sprite.h,v 1.5 1995/06/14 15:19:54 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -37,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)sprite.h 8.1 (Berkeley) 6/6/93
* @(#)sprite.h 8.2 (Berkeley) 4/28/95
*/
/*

View File

@ -1,5 +1,3 @@
/* $NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,12 +37,8 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
static char rcsid[] = "$NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $";
#endif
#endif /* not lint */
static char sccsid[] = "@(#)str.c 8.6 (Berkeley) 4/28/95";
#endif /* not lint */
#include "make.h"
@ -60,7 +54,7 @@ void
str_init()
{
char *p1;
argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *));
argv = (char **)emalloc((argmax = 50) * sizeof(char *));
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
}
@ -73,15 +67,15 @@ str_init()
void
str_end()
{
if (argv) {
if (argv[0])
free(argv[0]);
if (argv[0]) {
free(argv[0]);
free((Address) argv);
}
if (buffer)
free(buffer);
}
/*-
* str_concat --
* concatenate the two strings, inserting a space or slash between them,
@ -207,8 +201,9 @@ brk_string(str, store_argc, expand)
*t++ = '\0';
if (argc == argmax) {
argmax *= 2; /* ramp up fast */
argv = (char **)erealloc(argv,
(argmax + 1) * sizeof(char *));
if (!(argv = (char **)realloc(argv,
argmax * sizeof(char *))))
enomem();
}
argv[argc++] = start;
start = (char *)NULL;

View File

@ -1,5 +1,3 @@
/* $NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
static char rcsid[] = "$NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $";
#endif
static char sccsid[] = "@(#)suff.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -101,6 +95,7 @@ static char rcsid[] = "$NetBSD: suff.c,v 1.12 1996/08/13 16:42:16 christos Exp $
#include "make.h"
#include "hash.h"
#include "dir.h"
#include "bit.h"
static Lst sufflist; /* Lst of suffixes */
static Lst suffClean; /* Lst of suffixes to be cleaned */
@ -164,7 +159,6 @@ static int SuffSuffIsSuffixP __P((ClientData, ClientData));
static int SuffSuffHasNameP __P((ClientData, ClientData));
static int SuffSuffIsPrefix __P((ClientData, ClientData));
static int SuffGNHasNameP __P((ClientData, ClientData));
static void SuffUnRef __P((ClientData, ClientData));
static void SuffFree __P((ClientData));
static void SuffInsert __P((Lst, Suff *));
static void SuffRemove __P((Lst, Suff *));
@ -802,7 +796,7 @@ Suff_AddSuffix (str)
if (ln == NILLNODE) {
s = (Suff *) emalloc (sizeof (Suff));
s->name = estrdup (str);
s->name = strdup (str);
s->nameLen = strlen (s->name);
s->searchPath = Lst_Init (FALSE);
s->children = Lst_Init (FALSE);
@ -1009,7 +1003,7 @@ SuffAddSrc (sp, lsp)
* that...
*/
s2 = (Src *) emalloc (sizeof (Src));
s2->file = estrdup(targ->pref);
s2->file = strdup(targ->pref);
s2->pref = targ->pref;
s2->parent = targ;
s2->node = NILGNODE;
@ -1272,7 +1266,7 @@ SuffFindCmds (targ, slst)
* again (ick)), and return the new structure.
*/
ret = (Src *)emalloc (sizeof (Src));
ret->file = estrdup(s->name);
ret->file = strdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
suff->refCount++;
@ -1847,8 +1841,7 @@ SuffFindNormalDeps(gn, slst)
* children, then look for any overriding transformations they imply.
* Should we find one, we discard the one we found before.
*/
while (ln != NILLNODE) {
while(ln != NILLNODE) {
/*
* Look for next possible suffix...
*/
@ -1862,7 +1855,7 @@ SuffFindNormalDeps(gn, slst)
* Allocate a Src structure to which things can be transformed
*/
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
targ->file = strdup(gn->name);
targ->suff = (Suff *)Lst_Datum(ln);
targ->suff->refCount++;
targ->node = gn;
@ -1903,17 +1896,17 @@ SuffFindNormalDeps(gn, slst)
*/
if (Lst_IsEmpty(targs) && suffNull != NULL) {
if (DEBUG(SUFF)) {
printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
printf("\tNo known suffix on %s. Using .NULL suffix: ", gn->name);
}
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
targ->file = strdup(gn->name);
targ->suff = suffNull;
targ->suff->refCount++;
targ->node = gn;
targ->parent = (Src *)NULL;
targ->children = 0;
targ->pref = estrdup(sopref);
targ->pref = strdup(sopref);
#ifdef DEBUG_SRC
targ->cp = Lst_Init(FALSE);
#endif
@ -1995,7 +1988,6 @@ sfnd_abort:
(targ == NULL ? dirSearchPath :
targ->suff->searchPath));
if (gn->path != NULL) {
char *ptr;
Var_Set(TARGET, gn->path, gn);
if (targ != NULL) {
@ -2003,7 +1995,7 @@ sfnd_abort:
* Suffix known for the thing -- trim the suffix off
* the path to form the proper .PREFIX variable.
*/
int savep = strlen(gn->path) - targ->suff->nameLen;
int len = strlen(gn->path);
char savec;
if (gn->suffix)
@ -2011,17 +2003,12 @@ sfnd_abort:
gn->suffix = targ->suff;
gn->suffix->refCount++;
savec = gn->path[savep];
gn->path[savep] = '\0';
savec = gn->path[len-targ->suff->nameLen];
gn->path[len-targ->suff->nameLen] = '\0';
if ((ptr = strrchr(gn->path, '/')) != NULL)
ptr++;
else
ptr = gn->path;
Var_Set(PREFIX, gn->path, gn);
Var_Set(PREFIX, ptr, gn);
gn->path[savep] = savec;
gn->path[len-targ->suff->nameLen] = savec;
} else {
/*
* The .PREFIX gets the full path if the target has
@ -2031,12 +2018,7 @@ sfnd_abort:
gn->suffix->refCount--;
gn->suffix = NULL;
if ((ptr = strrchr(gn->path, '/')) != NULL)
ptr++;
else
ptr = gn->path;
Var_Set(PREFIX, ptr, gn);
Var_Set(PREFIX, gn->path, gn);
}
}
} else {
@ -2052,7 +2034,7 @@ sfnd_abort:
gn->suffix->refCount++;
if (gn->path != NULL)
free(gn->path);
gn->path = estrdup(gn->name);
gn->path = strdup(gn->name);
}
goto sfnd_return;
@ -2153,7 +2135,7 @@ sfnd_abort:
*/
if (gn->path)
free(gn->path);
gn->path = estrdup(gn->name);
gn->path = strdup(gn->name);
/*
* Nuke the transformation path and the Src structures left over in the
@ -2334,7 +2316,7 @@ Suff_Init ()
*/
emptySuff = suffNull = (Suff *) emalloc (sizeof (Suff));
suffNull->name = estrdup ("");
suffNull->name = strdup ("");
suffNull->nameLen = 0;
suffNull->searchPath = Lst_Init (FALSE);
Dir_Concat(suffNull->searchPath, dirSearchPath);

View File

@ -1,5 +1,3 @@
/* $NetBSD: targ.c,v 1.9 1996/08/30 17:59:43 thorpej Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
static char *rcsid = "$NetBSD: targ.c,v 1.9 1996/08/30 17:59:43 thorpej Exp $";
#endif
static char sccsid[] = "@(#)targ.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -164,7 +158,7 @@ Targ_NewGN (name)
register GNode *gn;
gn = (GNode *) emalloc (sizeof (GNode));
gn->name = estrdup (name);
gn->name = strdup (name);
gn->path = (char *) 0;
if (name[0] == '-' && name[1] == 'l') {
gn->type = OP_LIB;
@ -175,7 +169,6 @@ Targ_NewGN (name)
gn->make = FALSE;
gn->made = UNMADE;
gn->childMade = FALSE;
gn->order = 0;
gn->mtime = gn->cmtime = 0;
gn->iParents = Lst_Init (FALSE);
gn->cohorts = Lst_Init (FALSE);
@ -474,9 +467,9 @@ Targ_FmtTime (time)
parts = localtime(&time);
sprintf (buf, "%d:%02d:%02d %s %d, %d",
sprintf (buf, "%d:%02d:%02d %s %d, 19%d",
parts->tm_hour, parts->tm_min, parts->tm_sec,
months[parts->tm_mon], parts->tm_mday, 1900 + parts->tm_year);
months[parts->tm_mon], parts->tm_mday, parts->tm_year);
return(buf);
}

View File

@ -1,5 +1,3 @@
/* $NetBSD: var.c,v 1.14 1996/08/13 16:42:25 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -39,11 +37,7 @@
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
static char rcsid[] = "$NetBSD: var.c,v 1.14 1996/08/13 16:42:25 christos Exp $";
#endif
static char sccsid[] = "@(#)var.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
/*-
@ -153,6 +147,7 @@ typedef struct {
#define VAR_SUB_GLOBAL 1 /* Apply substitution globally */
#define VAR_MATCH_START 2 /* Match at start of word */
#define VAR_MATCH_END 4 /* Match at end of word */
#define VAR_NO_SUB 8 /* Substitution is non-global and already done */
} VarPattern;
static int VarCmp __P((ClientData, ClientData));
@ -164,9 +159,7 @@ static Boolean VarTail __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
#ifdef SYSVVARSUB
static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData));
#endif
static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
@ -280,7 +273,7 @@ VarFind (name, ctxt, flags)
int len;
v = (Var *) emalloc(sizeof(Var));
v->name = estrdup(name);
v->name = strdup(name);
len = strlen(env);
@ -333,7 +326,7 @@ VarAdd (name, val, ctxt)
v = (Var *) emalloc (sizeof (Var));
v->name = estrdup (name);
v->name = strdup (name);
len = val ? strlen(val) : 0;
v->val = Buf_Init(len+1);
@ -783,7 +776,8 @@ VarMatch (word, addSpace, buf, pattern)
return(addSpace);
}
#ifdef SYSVVARSUB
/*-
*-----------------------------------------------------------------------
* VarSYSVMatch --
@ -825,7 +819,6 @@ VarSYSVMatch (word, addSpace, buf, patp)
return(addSpace);
}
#endif
/*-
@ -890,9 +883,9 @@ VarSubstitute (word, addSpace, buf, patternp)
VarPattern *pattern = (VarPattern *) patternp;
wordLen = strlen(word);
if (1) { /* substitute in each word of the variable */
if ((pattern->flags & VAR_NO_SUB) == 0) {
/*
* Break substitution down into simple anchored cases
* Still substituting -- break it down into simple anchored cases
* and if none of them fits, perform the general substitution case.
*/
if ((pattern->flags & VAR_MATCH_START) &&
@ -974,7 +967,7 @@ VarSubstitute (word, addSpace, buf, patternp)
* Pattern is unanchored: search for the pattern in the word using
* String_FindSubstring, copying unmatched portions and the
* right-hand-side for each match found, handling non-global
* substitutions correctly, etc. When the loop is done, any
* subsititutions correctly, etc. When the loop is done, any
* remaining part of the word (word and wordLen are adjusted
* accordingly through the loop) is copied straight into the
* buffer.
@ -997,9 +990,13 @@ VarSubstitute (word, addSpace, buf, patternp)
Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);
wordLen -= (cp - word) + pattern->leftLen;
word = cp + pattern->leftLen;
if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0){
if (wordLen == 0) {
done = TRUE;
}
if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
done = TRUE;
pattern->flags |= VAR_NO_SUB;
}
} else {
done = TRUE;
}
@ -1018,9 +1015,14 @@ VarSubstitute (word, addSpace, buf, patternp)
return ((Buf_Size(buf) != origSize) || addSpace);
}
/*
* Common code for anchored substitutions:
* addSpace was set TRUE if characters were added to the buffer.
* Common code for anchored substitutions: if performed a substitution
* and it's not supposed to be global, mark the pattern as requiring
* no more substitutions. addSpace was set TRUE if characters were
* added to the buffer.
*/
if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
pattern->flags |= VAR_NO_SUB;
}
return (addSpace);
}
nosub:
@ -1108,7 +1110,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
Boolean haveModifier;/* TRUE if have modifiers for the variable */
register char endc; /* Ending character when variable in parens
* or braces */
register char startc=0; /* Starting character when variable in parens
register char startc; /* Starting character when variable in parens
* or braces */
int cnt; /* Used to count brace pairs when variable in
* in parens or braces */
@ -1625,22 +1627,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
break;
}
/*FALLTHRU*/
#ifdef SUNSHCMD
case 's':
if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
char *err;
newStr = Cmd_Exec (str, &err);
if (err)
Error (err, str);
cp = tstr + 2;
termc = *cp;
break;
}
/*FALLTHRU*/
#endif
default:
{
#ifdef SYSVVARSUB
default: {
/*
* This can either be a bogus modifier or a System-V
* substitution command.
@ -1707,9 +1694,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
pattern.lhs[pattern.leftLen] = '=';
pattern.rhs[pattern.rightLen] = endc;
termc = endc;
} else
#endif
{
} else {
Error ("Unknown modifier '%c'\n", *tstr);
for (cp = tstr+1;
*cp != ':' && *cp != endc && *cp != '\0';