Import bmake-20170420
Only use -C arg "as is" if it contains no relative component. Fix Main_SetObjdir() for relative paths (eg obj). Fix a number of coverity complaints.
This commit is contained in:
parent
85813b0c12
commit
f62a02334b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/bmake/dist/; revision=317232 svn path=/vendor/NetBSD/bmake/20170420/; revision=317233; tag=vendor/NetBSD/bmake/20170420
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
2017-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
|
* Makefile (_MAKE_VERSION): 20170420
|
||||||
|
Merge with NetBSD make, pick up
|
||||||
|
o main.c: only use -C arg "as is" if it contains no
|
||||||
|
relative component.
|
||||||
|
|
||||||
|
2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
|
* Makefile (_MAKE_VERSION): 20170418
|
||||||
|
Merge with NetBSD make, pick up
|
||||||
|
o main.c: fix Main_SetObjdir() for relative paths (eg obj).
|
||||||
|
|
||||||
|
2017-04-17 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
|
* Makefile (_MAKE_VERSION): 20170417
|
||||||
|
Merge with NetBSD make, pick up
|
||||||
|
o fixes a number of coverity complaints
|
||||||
|
- check return value of fseek, fcntl
|
||||||
|
- plug memory leak in Dir_FindFile, Var_LoopExpand,
|
||||||
|
JobPrintCommand, ParseTraditionalInclude
|
||||||
|
- use bmake_malloc() where NULL is not tollerated
|
||||||
|
- use MAKE_ATTR_UNUSED rather that kludges like
|
||||||
|
return(unused ? 0 : 0)
|
||||||
|
- use purge_cached_realpaths() rather than abuse cached_realpath()
|
||||||
|
|
||||||
2017-04-13 Simon J. Gerraty <sjg@bad.crufty.net>
|
2017-04-13 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
* Makefile (_MAKE_VERSION): 20170413
|
* Makefile (_MAKE_VERSION): 20170413
|
||||||
|
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
|||||||
# $Id: Makefile,v 1.85 2017/04/13 16:29:40 sjg Exp $
|
# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $
|
||||||
|
|
||||||
# Base version on src date
|
# Base version on src date
|
||||||
_MAKE_VERSION= 20170413
|
_MAKE_VERSION= 20170420
|
||||||
|
|
||||||
PROG= bmake
|
PROG= bmake
|
||||||
|
|
||||||
|
35
arch.c
35
arch.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */
|
/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $";
|
static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
|
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $");
|
__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *member, Boolean hash)
|
|||||||
if (fread(memName, elen, 1, arch) != 1)
|
if (fread(memName, elen, 1, arch) != 1)
|
||||||
goto badarch;
|
goto badarch;
|
||||||
memName[elen] = '\0';
|
memName[elen] = '\0';
|
||||||
fseek(arch, -elen, SEEK_CUR);
|
if (fseek(arch, -elen, SEEK_CUR) != 0)
|
||||||
|
goto badarch;
|
||||||
if (DEBUG(ARCH) || DEBUG(MAKE)) {
|
if (DEBUG(ARCH) || DEBUG(MAKE)) {
|
||||||
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
|
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
|
||||||
}
|
}
|
||||||
@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *member, Boolean hash)
|
|||||||
Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
|
Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
|
||||||
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
|
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
|
||||||
}
|
}
|
||||||
fseek(arch, (size + 1) & ~1, SEEK_CUR);
|
if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0)
|
||||||
|
goto badarch;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(arch);
|
fclose(arch);
|
||||||
@ -956,7 +958,10 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
|
|||||||
* the file at the actual member, rather than its header, but
|
* the file at the actual member, rather than its header, but
|
||||||
* not here...
|
* not here...
|
||||||
*/
|
*/
|
||||||
fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
|
if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) {
|
||||||
|
fclose(arch);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return (arch);
|
return (arch);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -986,10 +991,17 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
|
|||||||
}
|
}
|
||||||
if (strncmp(ename, member, len) == 0) {
|
if (strncmp(ename, member, len) == 0) {
|
||||||
/* Found as extended name */
|
/* Found as extended name */
|
||||||
fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
|
if (fseek(arch, -sizeof(struct ar_hdr) - elen,
|
||||||
|
SEEK_CUR) != 0) {
|
||||||
|
fclose(arch);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return (arch);
|
return (arch);
|
||||||
}
|
}
|
||||||
fseek(arch, -elen, SEEK_CUR);
|
if (fseek(arch, -elen, SEEK_CUR) != 0) {
|
||||||
|
fclose(arch);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
goto skip;
|
goto skip;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@ -1002,9 +1014,12 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
|
|||||||
* extract the size of the file from the 'size' field of the
|
* extract the size of the file from the 'size' field of the
|
||||||
* header and round it up during the seek.
|
* header and round it up during the seek.
|
||||||
*/
|
*/
|
||||||
arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0';
|
arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0';
|
||||||
size = (int)strtol(arhPtr->AR_SIZE, NULL, 10);
|
size = (int)strtol(arhPtr->AR_SIZE, NULL, 10);
|
||||||
fseek(arch, (size + 1) & ~1, SEEK_CUR);
|
if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
|
||||||
|
fclose(arch);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
cond.c
10
cond.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $ */
|
/* $NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||||
@ -70,14 +70,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $";
|
static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
|
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
|
__RCSID("$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h> /* For strtoul() error checking */
|
#include <errno.h> /* For strtoul() error checking */
|
||||||
|
|
||||||
@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprin
|
|||||||
break;
|
break;
|
||||||
dflt_info = info;
|
dflt_info = info;
|
||||||
}
|
}
|
||||||
|
assert(info != NULL);
|
||||||
|
|
||||||
if_info = info != NULL ? info : ifs + 4;
|
if_info = info;
|
||||||
condExpr = line;
|
condExpr = line;
|
||||||
condPushBack = TOK_NONE;
|
condPushBack = TOK_NONE;
|
||||||
|
|
||||||
|
40
dir.c
40
dir.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $ */
|
/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||||
@ -70,14 +70,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $";
|
static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
|
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $");
|
__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -803,11 +803,11 @@ DirExpandInt(const char *word, Lst path, Lst expansions)
|
|||||||
*-----------------------------------------------------------------------
|
*-----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
DirPrintWord(void *word, void *dummy)
|
DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
fprintf(debug_file, "%s ", (char *)word);
|
fprintf(debug_file, "%s ", (char *)word);
|
||||||
|
|
||||||
return(dummy ? 0 : 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1315,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path)
|
|||||||
fprintf(debug_file, " Trying exact path matches...\n");
|
fprintf(debug_file, " Trying exact path matches...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
|
if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
|
||||||
return *file?file:NULL;
|
!= NULL)) {
|
||||||
|
if (file[0] == '\0') {
|
||||||
|
free(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
(void)Lst_Open(path);
|
(void)Lst_Open(path);
|
||||||
while ((ln = Lst_Next(path)) != NULL) {
|
while ((ln = Lst_Next(path)) != NULL) {
|
||||||
@ -1325,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path)
|
|||||||
continue;
|
continue;
|
||||||
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
|
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
|
||||||
Lst_Close(path);
|
Lst_Close(path);
|
||||||
return *file?file:NULL;
|
if (file[0] == '\0') {
|
||||||
|
free(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lst_Close(path);
|
Lst_Close(path);
|
||||||
|
|
||||||
if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
|
if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
|
||||||
return *file?file:NULL;
|
!= NULL)) {
|
||||||
|
if (file[0] == '\0') {
|
||||||
|
free(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1851,10 +1867,10 @@ Dir_PrintDirectories(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
DirPrintDir(void *p, void *dummy)
|
DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
fprintf(debug_file, "%s ", ((Path *)p)->name);
|
fprintf(debug_file, "%s ", ((Path *)p)->name);
|
||||||
return (dummy ? 0 : 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
8
for.c
8
for.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $ */
|
/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, The Regents of the University of California.
|
* Copyright (c) 1992, The Regents of the University of California.
|
||||||
@ -30,14 +30,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $";
|
static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $");
|
__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len)
|
|||||||
for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) {
|
for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) {
|
||||||
char ech;
|
char ech;
|
||||||
ch = *++cp;
|
ch = *++cp;
|
||||||
if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) {
|
if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) {
|
||||||
cp++;
|
cp++;
|
||||||
/* Check variable name against the .for loop variables */
|
/* Check variable name against the .for loop variables */
|
||||||
STRLIST_FOREACH(var, &arg->vars, i) {
|
STRLIST_FOREACH(var, &arg->vars, i) {
|
||||||
|
48
job.c
48
job.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $ */
|
/* $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||||
@ -70,14 +70,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $";
|
static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $");
|
__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -427,7 +427,7 @@ static void JobSigUnlock(sigset_t *omaskp)
|
|||||||
static void
|
static void
|
||||||
JobCreatePipe(Job *job, int minfd)
|
JobCreatePipe(Job *job, int minfd)
|
||||||
{
|
{
|
||||||
int i, fd;
|
int i, fd, flags;
|
||||||
|
|
||||||
if (pipe(job->jobPipe) == -1)
|
if (pipe(job->jobPipe) == -1)
|
||||||
Punt("Cannot create pipe: %s", strerror(errno));
|
Punt("Cannot create pipe: %s", strerror(errno));
|
||||||
@ -442,8 +442,10 @@ JobCreatePipe(Job *job, int minfd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set close-on-exec flag for both */
|
/* Set close-on-exec flag for both */
|
||||||
(void)fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC);
|
if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1)
|
||||||
(void)fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC);
|
Punt("Cannot set close-on-exec: %s", strerror(errno));
|
||||||
|
if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1)
|
||||||
|
Punt("Cannot set close-on-exec: %s", strerror(errno));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We mark the input side of the pipe non-blocking; we poll(2) the
|
* We mark the input side of the pipe non-blocking; we poll(2) the
|
||||||
@ -451,8 +453,12 @@ JobCreatePipe(Job *job, int minfd)
|
|||||||
* race for the token when a new one becomes available, so the read
|
* race for the token when a new one becomes available, so the read
|
||||||
* from the pipe should not block.
|
* from the pipe should not block.
|
||||||
*/
|
*/
|
||||||
fcntl(job->jobPipe[0], F_SETFL,
|
flags = fcntl(job->jobPipe[0], F_GETFL, 0);
|
||||||
fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK);
|
if (flags == -1)
|
||||||
|
Punt("Cannot get flags: %s", strerror(errno));
|
||||||
|
flags |= O_NONBLOCK;
|
||||||
|
if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1)
|
||||||
|
Punt("Cannot set flags: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -754,6 +760,7 @@ JobPrintCommand(void *cmdp, void *jobp)
|
|||||||
* but this one needs to be - use compat mode just for it.
|
* but this one needs to be - use compat mode just for it.
|
||||||
*/
|
*/
|
||||||
CompatRunCommand(cmdp, job->node);
|
CompatRunCommand(cmdp, job->node);
|
||||||
|
free(cmdStart);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1382,15 +1389,27 @@ JobExec(Job *job, char **argv)
|
|||||||
execError("dup2", "job->cmdFILE");
|
execError("dup2", "job->cmdFILE");
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
(void)fcntl(0, F_SETFD, 0);
|
if (fcntl(0, F_SETFD, 0) == -1) {
|
||||||
(void)lseek(0, (off_t)0, SEEK_SET);
|
execError("fcntl clear close-on-exec", "stdin");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
if (lseek(0, (off_t)0, SEEK_SET) == -1) {
|
||||||
|
execError("lseek to 0", "stdin");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
|
if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
|
||||||
/*
|
/*
|
||||||
* Pass job token pipe to submakes.
|
* Pass job token pipe to submakes.
|
||||||
*/
|
*/
|
||||||
fcntl(tokenWaitJob.inPipe, F_SETFD, 0);
|
if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) {
|
||||||
fcntl(tokenWaitJob.outPipe, F_SETFD, 0);
|
execError("clear close-on-exec", "tokenWaitJob.inPipe");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) {
|
||||||
|
execError("clear close-on-exec", "tokenWaitJob.outPipe");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1407,7 +1426,10 @@ JobExec(Job *job, char **argv)
|
|||||||
* it before routing the shell's error output to the same place as
|
* it before routing the shell's error output to the same place as
|
||||||
* its standard output.
|
* its standard output.
|
||||||
*/
|
*/
|
||||||
(void)fcntl(1, F_SETFD, 0);
|
if (fcntl(1, F_SETFD, 0) == -1) {
|
||||||
|
execError("clear close-on-exec", "stdout");
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
if (dup2(1, 2) == -1) {
|
if (dup2(1, 2) == -1) {
|
||||||
execError("dup2", "1, 2");
|
execError("dup2", "1, 2");
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
107
main.c
107
main.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $ */
|
/* $NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,7 +69,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $";
|
static char rcsid[] = "$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $");
|
__RCSID("$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -187,6 +187,7 @@ static const char * tracefile;
|
|||||||
static void MainParseArgs(int, char **);
|
static void MainParseArgs(int, char **);
|
||||||
static int ReadMakefile(const void *, const void *);
|
static int ReadMakefile(const void *, const void *);
|
||||||
static void usage(void) MAKE_ATTR_DEAD;
|
static void usage(void) MAKE_ATTR_DEAD;
|
||||||
|
static void purge_cached_realpaths(void);
|
||||||
|
|
||||||
static Boolean ignorePWD; /* if we use -C, PWD is meaningless */
|
static Boolean ignorePWD; /* if we use -C, PWD is meaningless */
|
||||||
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
|
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
|
||||||
@ -336,7 +337,7 @@ parse_debug_options(const char *argvalue)
|
|||||||
goto debug_setbuf;
|
goto debug_setbuf;
|
||||||
}
|
}
|
||||||
len = strlen(modules);
|
len = strlen(modules);
|
||||||
fname = malloc(len + 20);
|
fname = bmake_malloc(len + 20);
|
||||||
memcpy(fname, modules, len + 1);
|
memcpy(fname, modules, len + 1);
|
||||||
/* Let the filename be modified by the pid */
|
/* Let the filename be modified by the pid */
|
||||||
if (strcmp(fname + len - 3, ".%d") == 0)
|
if (strcmp(fname + len - 3, ".%d") == 0)
|
||||||
@ -367,6 +368,32 @@ parse_debug_options(const char *argvalue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* does path contain any relative components
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
is_relpath(const char *path)
|
||||||
|
{
|
||||||
|
const char *cp;
|
||||||
|
|
||||||
|
if (path[0] != '/')
|
||||||
|
return TRUE;
|
||||||
|
cp = path;
|
||||||
|
do {
|
||||||
|
cp = strstr(cp, "/.");
|
||||||
|
if (!cp)
|
||||||
|
break;
|
||||||
|
cp += 2;
|
||||||
|
if (cp[0] == '/' || cp[0] == '\0')
|
||||||
|
return TRUE;
|
||||||
|
else if (cp[0] == '.') {
|
||||||
|
if (cp[1] == '/' || cp[1] == '\0')
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} while (cp);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* MainParseArgs --
|
* MainParseArgs --
|
||||||
* Parse a given argument vector. Called from main() and from
|
* Parse a given argument vector. Called from main() and from
|
||||||
@ -458,7 +485,7 @@ MainParseArgs(int argc, char **argv)
|
|||||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (argvalue[0] == '/' &&
|
if (!is_relpath(argvalue) &&
|
||||||
stat(argvalue, &sa) != -1 &&
|
stat(argvalue, &sa) != -1 &&
|
||||||
stat(curdir, &sb) != -1 &&
|
stat(curdir, &sb) != -1 &&
|
||||||
sa.st_ino == sb.st_ino &&
|
sa.st_ino == sb.st_ino &&
|
||||||
@ -732,8 +759,10 @@ Main_SetObjdir(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (path[0] != '/') {
|
if (path[0] != '/') {
|
||||||
snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path);
|
char buf2[MAXPATHLEN + 1];
|
||||||
path = buf;
|
|
||||||
|
snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path);
|
||||||
|
path = buf2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for the directory and try to chdir there */
|
/* look for the directory and try to chdir there */
|
||||||
@ -746,7 +775,7 @@ Main_SetObjdir(const char *fmt, ...)
|
|||||||
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
|
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
|
||||||
setenv("PWD", objdir, 1);
|
setenv("PWD", objdir, 1);
|
||||||
Dir_InitDot();
|
Dir_InitDot();
|
||||||
cached_realpath(".OBJDIR", NULL); /* purge */
|
purge_cached_realpaths();
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
if (enterFlag && strcmp(objdir, curdir) != 0)
|
if (enterFlag && strcmp(objdir, curdir) != 0)
|
||||||
enterFlagObj = TRUE;
|
enterFlagObj = TRUE;
|
||||||
@ -1907,42 +1936,56 @@ usage(void)
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* realpath(3) can get expensive, cache results...
|
* realpath(3) can get expensive, cache results...
|
||||||
*/
|
*/
|
||||||
|
static GNode *cached_realpaths = NULL;
|
||||||
|
|
||||||
|
static GNode *
|
||||||
|
get_cached_realpaths(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!cached_realpaths) {
|
||||||
|
cached_realpaths = Targ_NewGN("Realpath");
|
||||||
|
#ifndef DEBUG_REALPATH_CACHE
|
||||||
|
cached_realpaths->flags = INTERNAL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return cached_realpaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* purge any relative paths */
|
||||||
|
static void
|
||||||
|
purge_cached_realpaths(void)
|
||||||
|
{
|
||||||
|
GNode *cache = get_cached_realpaths();
|
||||||
|
Hash_Entry *he, *nhe;
|
||||||
|
Hash_Search hs;
|
||||||
|
|
||||||
|
he = Hash_EnumFirst(&cache->context, &hs);
|
||||||
|
while (he) {
|
||||||
|
nhe = Hash_EnumNext(&hs);
|
||||||
|
if (he->name[0] != '/') {
|
||||||
|
if (DEBUG(DIR))
|
||||||
|
fprintf(stderr, "cached_realpath: purging %s\n", he->name);
|
||||||
|
Hash_DeleteEntry(&cache->context, he);
|
||||||
|
}
|
||||||
|
he = nhe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
cached_realpath(const char *pathname, char *resolved)
|
cached_realpath(const char *pathname, char *resolved)
|
||||||
{
|
{
|
||||||
static GNode *cache;
|
GNode *cache;
|
||||||
char *rp, *cp;
|
char *rp, *cp;
|
||||||
|
|
||||||
if (!pathname || !pathname[0])
|
if (!pathname || !pathname[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!cache) {
|
cache = get_cached_realpaths();
|
||||||
cache = Targ_NewGN("Realpath");
|
|
||||||
#ifndef DEBUG_REALPATH_CACHE
|
|
||||||
cache->flags = INTERNAL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (resolved == NULL && strcmp(pathname, ".OBJDIR") == 0) {
|
|
||||||
/* purge any relative paths */
|
|
||||||
Hash_Entry *he, *nhe;
|
|
||||||
Hash_Search hs;
|
|
||||||
|
|
||||||
he = Hash_EnumFirst(&cache->context, &hs);
|
|
||||||
while (he) {
|
|
||||||
nhe = Hash_EnumNext(&hs);
|
|
||||||
if (he->name[0] != '/') {
|
|
||||||
if (DEBUG(DIR))
|
|
||||||
fprintf(stderr, "cached_realpath: purging %s\n", he->name);
|
|
||||||
Hash_DeleteEntry(&cache->context, he);
|
|
||||||
}
|
|
||||||
he = nhe;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
|
if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
|
||||||
/* a hit */
|
/* a hit */
|
||||||
strlcpy(resolved, rp, MAXPATHLEN);
|
strlcpy(resolved, rp, MAXPATHLEN);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $ */
|
/* $NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifdef MAKE_NATIVE
|
#ifdef MAKE_NATIVE
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
|
__RCSID("$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -39,13 +39,13 @@ __RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
|
|||||||
#include "make.h"
|
#include "make.h"
|
||||||
|
|
||||||
#ifndef USE_EMALLOC
|
#ifndef USE_EMALLOC
|
||||||
static void enomem(void) MAKE_ATTR_DEAD;
|
static MAKE_ATTR_DEAD void enomem(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* enomem --
|
* enomem --
|
||||||
* die when out of memory.
|
* die when out of memory.
|
||||||
*/
|
*/
|
||||||
static void
|
static MAKE_ATTR_DEAD void
|
||||||
enomem(void)
|
enomem(void)
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
|
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
|
* install-mk (MK_VERSION): 20170418
|
||||||
|
|
||||||
|
* auto.obj.mk: if using MAKEOBJDIRPREFIX check if it is a
|
||||||
|
prefix match for .CURDIR - in which case .CURDIR *is* __objdir.
|
||||||
|
|
||||||
2017-04-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
2017-04-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||||
|
|
||||||
* install-mk (MK_VERSION): 20170401
|
* install-mk (MK_VERSION): 20170401
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $Id: auto.obj.mk,v 1.13 2017/03/24 20:53:22 sjg Exp $
|
# $Id: auto.obj.mk,v 1.14 2017/04/18 23:53:18 sjg Exp $
|
||||||
#
|
#
|
||||||
# @(#) Copyright (c) 2004, Simon J. Gerraty
|
# @(#) Copyright (c) 2004, Simon J. Gerraty
|
||||||
#
|
#
|
||||||
@ -41,6 +41,10 @@ MKOBJDIRS= auto
|
|||||||
# Use __objdir here so it is easier to tweak without impacting
|
# Use __objdir here so it is easier to tweak without impacting
|
||||||
# the logic.
|
# the logic.
|
||||||
.if !empty(MAKEOBJDIRPREFIX)
|
.if !empty(MAKEOBJDIRPREFIX)
|
||||||
|
.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != ""
|
||||||
|
# we are already in obj tree!
|
||||||
|
__objdir?= ${.CURDIR}
|
||||||
|
.endif
|
||||||
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
|
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
|
||||||
.endif
|
.endif
|
||||||
__objdir?= ${MAKEOBJDIR:Uobj}
|
__objdir?= ${MAKEOBJDIR:Uobj}
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
# Simon J. Gerraty <sjg@crufty.net>
|
# Simon J. Gerraty <sjg@crufty.net>
|
||||||
|
|
||||||
# RCSid:
|
# RCSid:
|
||||||
# $Id: install-mk,v 1.140 2017/04/03 21:04:09 sjg Exp $
|
# $Id: install-mk,v 1.141 2017/04/18 23:53:18 sjg Exp $
|
||||||
#
|
#
|
||||||
# @(#) Copyright (c) 1994 Simon J. Gerraty
|
# @(#) Copyright (c) 1994 Simon J. Gerraty
|
||||||
#
|
#
|
||||||
@ -70,7 +70,7 @@
|
|||||||
# sjg@crufty.net
|
# sjg@crufty.net
|
||||||
#
|
#
|
||||||
|
|
||||||
MK_VERSION=20170401
|
MK_VERSION=20170418
|
||||||
OWNER=
|
OWNER=
|
||||||
GROUP=
|
GROUP=
|
||||||
MODE=444
|
MODE=444
|
||||||
|
32
parse.c
32
parse.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $ */
|
/* $NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $";
|
static char rcsid[] = "$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $");
|
__RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -130,6 +130,7 @@ __RCSID("$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $");
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "make.h"
|
#include "make.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
@ -539,7 +540,7 @@ loadfile(const char *path, int fd)
|
|||||||
if (lf->buf != MAP_FAILED) {
|
if (lf->buf != MAP_FAILED) {
|
||||||
/* succeeded */
|
/* succeeded */
|
||||||
if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
|
if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
|
||||||
char *b = malloc(lf->len + 1);
|
char *b = bmake_malloc(lf->len + 1);
|
||||||
b[lf->len] = '\n';
|
b[lf->len] = '\n';
|
||||||
memcpy(b, lf->buf, lf->len++);
|
memcpy(b, lf->buf, lf->len++);
|
||||||
munmap(lf->buf, lf->maplen);
|
munmap(lf->buf, lf->maplen);
|
||||||
@ -560,9 +561,15 @@ loadfile(const char *path, int fd)
|
|||||||
while (1) {
|
while (1) {
|
||||||
assert(bufpos <= lf->len);
|
assert(bufpos <= lf->len);
|
||||||
if (bufpos == lf->len) {
|
if (bufpos == lf->len) {
|
||||||
|
if (lf->len > SIZE_MAX/2) {
|
||||||
|
errno = EFBIG;
|
||||||
|
Error("%s: file too large", path);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
lf->len *= 2;
|
lf->len *= 2;
|
||||||
lf->buf = bmake_realloc(lf->buf, lf->len);
|
lf->buf = bmake_realloc(lf->buf, lf->len);
|
||||||
}
|
}
|
||||||
|
assert(bufpos < lf->len);
|
||||||
result = read(fd, lf->buf + bufpos, lf->len - bufpos);
|
result = read(fd, lf->buf + bufpos, lf->len - bufpos);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
Error("%s: read error: %s", path, strerror(errno));
|
Error("%s: read error: %s", path, strerror(errno));
|
||||||
@ -1099,15 +1106,15 @@ ParseDoSrc(int tOp, const char *src)
|
|||||||
*-----------------------------------------------------------------------
|
*-----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ParseFindMain(void *gnp, void *dummy)
|
ParseFindMain(void *gnp, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
GNode *gn = (GNode *)gnp;
|
GNode *gn = (GNode *)gnp;
|
||||||
if ((gn->type & OP_NOTARGET) == 0) {
|
if ((gn->type & OP_NOTARGET) == 0) {
|
||||||
mainNode = gn;
|
mainNode = gn;
|
||||||
Targ_SetMain(gn);
|
Targ_SetMain(gn);
|
||||||
return (dummy ? 1 : 1);
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return (dummy ? 0 : 0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,10 +1152,10 @@ ParseAddDir(void *path, void *name)
|
|||||||
*-----------------------------------------------------------------------
|
*-----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ParseClearPath(void *path, void *dummy)
|
ParseClearPath(void *path, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
Dir_ClearPath((Lst) path);
|
Dir_ClearPath((Lst) path);
|
||||||
return(dummy ? 0 : 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1685,10 +1692,12 @@ ParseDoDependency(char *line)
|
|||||||
}
|
}
|
||||||
if (paths) {
|
if (paths) {
|
||||||
Lst_Destroy(paths, NULL);
|
Lst_Destroy(paths, NULL);
|
||||||
|
paths = NULL;
|
||||||
}
|
}
|
||||||
if (specType == ExPath)
|
if (specType == ExPath)
|
||||||
Dir_SetPATH();
|
Dir_SetPATH();
|
||||||
} else {
|
} else {
|
||||||
|
assert(paths == NULL);
|
||||||
while (*line) {
|
while (*line) {
|
||||||
/*
|
/*
|
||||||
* The targets take real sources, so we must beware of archive
|
* The targets take real sources, so we must beware of archive
|
||||||
@ -1747,6 +1756,7 @@ ParseDoDependency(char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
assert(paths == NULL);
|
||||||
if (curTargs)
|
if (curTargs)
|
||||||
Lst_Destroy(curTargs, NULL);
|
Lst_Destroy(curTargs, NULL);
|
||||||
}
|
}
|
||||||
@ -2550,7 +2560,7 @@ ParseTraditionalInclude(char *line)
|
|||||||
if (*file == '\0') {
|
if (*file == '\0') {
|
||||||
Parse_Error(PARSE_FATAL,
|
Parse_Error(PARSE_FATAL,
|
||||||
"Filename missing from \"include\"");
|
"Filename missing from \"include\"");
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (file = all_files; !done; file = cp + 1) {
|
for (file = all_files; !done; file = cp + 1) {
|
||||||
@ -2565,6 +2575,7 @@ ParseTraditionalInclude(char *line)
|
|||||||
|
|
||||||
Parse_include_file(file, FALSE, FALSE, silent);
|
Parse_include_file(file, FALSE, FALSE, silent);
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
free(all_files);
|
free(all_files);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2615,6 +2626,7 @@ ParseGmakeExport(char *line)
|
|||||||
*/
|
*/
|
||||||
value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
|
value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
|
||||||
setenv(variable, value, 1);
|
setenv(variable, value, 1);
|
||||||
|
free(value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
29
suff.c
29
suff.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $ */
|
/* $NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $";
|
static char rcsid[] = "$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
|
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $");
|
__RCSID("$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -135,6 +135,7 @@ __RCSID("$NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $");
|
|||||||
* order to find the node.
|
* order to find the node.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "make.h"
|
#include "make.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
@ -762,12 +763,10 @@ Suff_AddTransform(char *line)
|
|||||||
*-----------------------------------------------------------------------
|
*-----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
Suff_EndTransform(void *gnp, void *dummy)
|
Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
GNode *gn = (GNode *)gnp;
|
GNode *gn = (GNode *)gnp;
|
||||||
|
|
||||||
(void)dummy;
|
|
||||||
|
|
||||||
if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts))
|
if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts))
|
||||||
gn = (GNode *)Lst_Datum(Lst_Last(gn->cohorts));
|
gn = (GNode *)Lst_Datum(Lst_Last(gn->cohorts));
|
||||||
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
|
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
|
||||||
@ -1908,6 +1907,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
|
|||||||
eoarch = strchr(gn->name, '(');
|
eoarch = strchr(gn->name, '(');
|
||||||
eoname = strchr(eoarch, ')');
|
eoname = strchr(eoarch, ')');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Caller guarantees the format `libname(member)', via
|
||||||
|
* Arch_ParseArchive.
|
||||||
|
*/
|
||||||
|
assert(eoarch != NULL);
|
||||||
|
assert(eoname != NULL);
|
||||||
|
|
||||||
*eoname = '\0'; /* Nuke parentheses during suffix search */
|
*eoname = '\0'; /* Nuke parentheses during suffix search */
|
||||||
*eoarch = '\0'; /* So a suffix can be found */
|
*eoarch = '\0'; /* So a suffix can be found */
|
||||||
|
|
||||||
@ -2597,23 +2603,20 @@ Suff_End(void)
|
|||||||
|
|
||||||
/********************* DEBUGGING FUNCTIONS **********************/
|
/********************* DEBUGGING FUNCTIONS **********************/
|
||||||
|
|
||||||
static int SuffPrintName(void *s, void *dummy)
|
static int SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
(void)dummy;
|
|
||||||
|
|
||||||
fprintf(debug_file, "%s ", ((Suff *)s)->name);
|
fprintf(debug_file, "%s ", ((Suff *)s)->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SuffPrintSuff(void *sp, void *dummy)
|
SuffPrintSuff(void *sp, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
Suff *s = (Suff *)sp;
|
Suff *s = (Suff *)sp;
|
||||||
int flags;
|
int flags;
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
(void)dummy;
|
|
||||||
|
|
||||||
fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
|
fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
|
||||||
|
|
||||||
flags = s->flags;
|
flags = s->flags;
|
||||||
@ -2650,12 +2653,10 @@ SuffPrintSuff(void *sp, void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SuffPrintTrans(void *tp, void *dummy)
|
SuffPrintTrans(void *tp, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
GNode *t = (GNode *)tp;
|
GNode *t = (GNode *)tp;
|
||||||
|
|
||||||
(void)dummy;
|
|
||||||
|
|
||||||
fprintf(debug_file, "%-16s: ", t->name);
|
fprintf(debug_file, "%-16s: ", t->name);
|
||||||
Targ_PrintType(t->type);
|
Targ_PrintType(t->type);
|
||||||
fputc('\n', debug_file);
|
fputc('\n', debug_file);
|
||||||
|
10
targ.c
10
targ.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $ */
|
/* $NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $";
|
static char rcsid[] = "$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $");
|
__RCSID("$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -521,10 +521,10 @@ TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Targ_PrintCmd(void *cmd, void *dummy)
|
Targ_PrintCmd(void *cmd, void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
fprintf(debug_file, "\t%s\n", (char *)cmd);
|
fprintf(debug_file, "\t%s\n", (char *)cmd);
|
||||||
return (dummy ? 0 : 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
|
24
var.c
24
var.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $ */
|
/* $NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990, 1993
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#ifndef MAKE_NATIVE
|
||||||
static char rcsid[] = "$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $";
|
static char rcsid[] = "$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $");
|
__RCSID("$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
@ -1181,7 +1181,7 @@ Var_Value(const char *name, GNode *ctxt, char **frp)
|
|||||||
static Boolean
|
static Boolean
|
||||||
VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
||||||
char *word, Boolean addSpace, Buffer *buf,
|
char *word, Boolean addSpace, Buffer *buf,
|
||||||
void *dummy)
|
void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
char *slash;
|
char *slash;
|
||||||
|
|
||||||
@ -1202,7 +1202,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
Buf_AddByte(buf, vpstate->varSpace);
|
Buf_AddByte(buf, vpstate->varSpace);
|
||||||
Buf_AddByte(buf, '.');
|
Buf_AddByte(buf, '.');
|
||||||
}
|
}
|
||||||
return(dummy ? TRUE : TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1229,7 +1229,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
static Boolean
|
static Boolean
|
||||||
VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
||||||
char *word, Boolean addSpace, Buffer *buf,
|
char *word, Boolean addSpace, Buffer *buf,
|
||||||
void *dummy)
|
void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
char *slash;
|
char *slash;
|
||||||
|
|
||||||
@ -1245,7 +1245,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
} else {
|
} else {
|
||||||
Buf_AddBytes(buf, strlen(word), word);
|
Buf_AddBytes(buf, strlen(word), word);
|
||||||
}
|
}
|
||||||
return (dummy ? TRUE : TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1271,7 +1271,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
static Boolean
|
static Boolean
|
||||||
VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
||||||
char *word, Boolean addSpace, Buffer *buf,
|
char *word, Boolean addSpace, Buffer *buf,
|
||||||
void *dummy)
|
void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
char *dot;
|
char *dot;
|
||||||
|
|
||||||
@ -1285,7 +1285,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
dot[-1] = '.';
|
dot[-1] = '.';
|
||||||
addSpace = TRUE;
|
addSpace = TRUE;
|
||||||
}
|
}
|
||||||
return (dummy ? addSpace : addSpace);
|
return addSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1312,7 +1312,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
static Boolean
|
static Boolean
|
||||||
VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
||||||
char *word, Boolean addSpace, Buffer *buf,
|
char *word, Boolean addSpace, Buffer *buf,
|
||||||
void *dummy)
|
void *dummy MAKE_ATTR_UNUSED)
|
||||||
{
|
{
|
||||||
char *dot;
|
char *dot;
|
||||||
|
|
||||||
@ -1328,7 +1328,7 @@ VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
|
|||||||
} else {
|
} else {
|
||||||
Buf_AddBytes(buf, strlen(word), word);
|
Buf_AddBytes(buf, strlen(word), word);
|
||||||
}
|
}
|
||||||
return (dummy ? TRUE : TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -1836,8 +1836,8 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
|
|||||||
Buf_AddByte(buf, ' ');
|
Buf_AddByte(buf, ' ');
|
||||||
Buf_AddBytes(buf, (slen = strlen(s)), s);
|
Buf_AddBytes(buf, (slen = strlen(s)), s);
|
||||||
addSpace = (slen > 0 && s[slen - 1] != '\n');
|
addSpace = (slen > 0 && s[slen - 1] != '\n');
|
||||||
free(s);
|
|
||||||
}
|
}
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
return addSpace;
|
return addSpace;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user