Import bmake-20200704

from ChangeLog:

    (most of this by rillig@)
    o lots of style and white-space cleanup
    o lots more unit tests for variable modifiers
    o simplified description of some functions
    o str.c: refactor Str_Match
    o var.c: debugging output for :@
      constify VarModify parameter
      fix :hash modifier on 16-bit platforms
      remove unnecessary forward declarations
      refactor ApplyModifier_SysV to have less indentation
      simplify code for :E and :R
      clean up code for :H and :T
      refactor ApplyModifiers

    * var.c: we need stdint.h on some platforms to get uint32_t
    * unit-test/Makefile: we need to supress the specific error
    for RE substitution error in modmisc, since it varies accross
    different OS.
This commit is contained in:
Simon J. Gerraty 2020-07-08 18:32:15 +00:00
parent 6e0296234f
commit 1a2b743f6b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/bmake/dist/; revision=363018
svn path=/vendor/NetBSD/bmake/20200704/; revision=363019; tag=vendor/NetBSD/bmake/20200704
60 changed files with 2466 additions and 2526 deletions

View File

@ -1,3 +1,42 @@
2020-07-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20200704
Merge with NetBSD make, pick up
(most of this by rillig@)
o lots of style and white-space cleanup
o lots more unit tests for variable modifiers
o simplified description of some functions
o str.c: refactor Str_Match
o var.c: debugging output for :@
constify VarModify parameter
fix :hash modifier on 16-bit platforms
remove unnecessary forward declarations
refactor ApplyModifier_SysV to have less indentation
simplify code for :E and :R
clean up code for :H and :T
refactor ApplyModifiers
* var.c: we need stdint.h on some platforms to get uint32_t
* unit-test/Makefile: we need to supress the specific error
for RE substitution error in modmisc, since it varies accross
different OS.
2020-07-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20200702
Merge with NetBSD make, pick up
o var.c: more improvements to avoiding unnecessary evaluation
use enums for flags
o remove flags arg to Var_Set which outside of var.c is always 0
2020-07-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20200701
Merge with NetBSD make, pick up
o var.c: with change to cond.c; ensure that nested variables
within a variable name are expanded.
o unit-tests/varmisc.mk: test for nested varname
2020-06-29 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20200629

View File

@ -1,2 +1,2 @@
# keep this compatible with sh and make
_MAKE_VERSION=20200629
_MAKE_VERSION=20200704

48
arch.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $ */
/* $NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $");
__RCSID("$NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -312,7 +312,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
free(freeIt);
if (result == var_Error) {
return(FAILURE);
return FAILURE;
} else {
subLibName = TRUE;
}
@ -354,7 +354,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
free(freeIt);
if (result == var_Error) {
return(FAILURE);
return FAILURE;
} else {
doSubst = TRUE;
}
@ -372,7 +372,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
*/
if (*cp == '\0') {
printf("No closing parenthesis in archive specification\n");
return (FAILURE);
return FAILURE;
}
/*
@ -426,7 +426,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
if (gn == NULL) {
free(buf);
return(FAILURE);
return FAILURE;
} else {
gn->type |= OP_ARCHV;
(void)Lst_AtEnd(nodeLst, gn);
@ -437,7 +437,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* ourselves.
*/
free(buf);
return(FAILURE);
return FAILURE;
}
/*
* Free buffer and continue with our work.
@ -461,7 +461,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
gn = Targ_FindNode(nameBuf, TARG_CREATE);
if (gn == NULL) {
free(nameBuf);
return (FAILURE);
return FAILURE;
} else {
/*
* We've found the node, but have to make sure the rest of
@ -483,7 +483,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
gn = Targ_FindNode(nameBuf, TARG_CREATE);
free(nameBuf);
if (gn == NULL) {
return (FAILURE);
return FAILURE;
} else {
/*
* We've found the node, but have to make sure the rest of the
@ -520,7 +520,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
} while (*cp != '\0' && isspace ((unsigned char)*cp));
*linePtr = cp;
return (SUCCESS);
return SUCCESS;
}
/*-
@ -544,7 +544,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
static int
ArchFindArchive(const void *ar, const void *archName)
{
return (strcmp(archName, ((const Arch *)ar)->name));
return strcmp(archName, ((const Arch *)ar)->name);
}
/*-
@ -602,7 +602,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
he = Hash_FindEntry(&ar->members, member);
if (he != NULL) {
return ((struct ar_hdr *)Hash_GetValue(he));
return (struct ar_hdr *)Hash_GetValue(he);
} else {
/* Try truncated name */
char copy[AR_MAX_NAME_LEN+1];
@ -614,7 +614,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
copy[AR_MAX_NAME_LEN] = '\0';
}
if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
return ((struct ar_hdr *)Hash_GetValue(he));
return (struct ar_hdr *)Hash_GetValue(he);
return NULL;
}
}
@ -635,7 +635,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
return NULL;
} else {
fclose(arch);
return (&sarh);
return &sarh;
}
}
@ -753,7 +753,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
he = Hash_FindEntry(&ar->members, member);
if (he != NULL) {
return ((struct ar_hdr *)Hash_GetValue(he));
return (struct ar_hdr *)Hash_GetValue(he);
} else {
return NULL;
}
@ -962,7 +962,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
fclose(arch);
return NULL;
}
return (arch);
return arch;
}
} else
#ifdef AR_EFMT1
@ -996,7 +996,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
fclose(arch);
return NULL;
}
return (arch);
return arch;
}
if (fseek(arch, -elen, SEEK_CUR) != 0) {
fclose(arch);
@ -1152,7 +1152,7 @@ Arch_MTime(GNode *gn)
}
gn->mtime = modTime;
return (modTime);
return modTime;
}
/*-
@ -1179,7 +1179,7 @@ Arch_MemMTime(GNode *gn)
if (Lst_Open(gn->parents) != SUCCESS) {
gn->mtime = 0;
return (0);
return 0;
}
while ((ln = Lst_Next(gn->parents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
@ -1211,7 +1211,7 @@ Arch_MemMTime(GNode *gn)
Lst_Close(gn->parents);
return (gn->mtime);
return gn->mtime;
}
/*-
@ -1252,9 +1252,9 @@ Arch_FindLib(GNode *gn, Lst path)
free(libName);
#ifdef LIBRARIES
Var_Set(TARGET, gn->name, gn, 0);
Var_Set(TARGET, gn->name, gn);
#else
Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn, 0);
Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn);
#endif /* LIBRARIES */
}
@ -1337,7 +1337,7 @@ Arch_LibOODate(GNode *gn)
oodate = FALSE;
#endif
}
return (oodate);
return oodate;
}
/*-

8
buf.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $ */
/* $NetBSD: buf.c,v 1.26 2020/07/03 08:02:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $";
static char rcsid[] = "$NetBSD: buf.c,v 1.26 2020/07/03 08:02:55 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $");
__RCSID("$NetBSD: buf.c,v 1.26 2020/07/03 08:02:55 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -160,7 +160,7 @@ Buf_GetAll(Buffer *bp, int *numBytesPtr)
if (numBytesPtr != NULL)
*numBytesPtr = bp->count;
return (bp->buffer);
return bp->buffer;
}
/*-

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.110 2020/01/19 19:42:32 riastradh Exp $ */
/* $NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: compat.c,v 1.110 2020/01/19 19:42:32 riastradh Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: compat.c,v 1.110 2020/01/19 19:42:32 riastradh Exp $");
__RCSID("$NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -236,7 +236,7 @@ CompatRunCommand(void *cmdp, void *gnp)
silent = gn->type & OP_SILENT;
errCheck = !(gn->type & OP_IGNORE);
doIt = FALSE;
cmdNode = Lst_Member(gn->commands, cmd);
cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
@ -249,18 +249,18 @@ CompatRunCommand(void *cmdp, void *gnp)
if (*cmdStart == '\0') {
free(cmdStart);
return(0);
return 0;
}
cmd = cmdStart;
Lst_Replace(cmdNode, cmdStart);
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
(void)Lst_AtEnd(ENDNode->commands, cmdStart);
return(0);
return 0;
}
if (strcmp(cmdStart, "...") == 0) {
gn->type |= OP_SAVE_CMDS;
return(0);
return 0;
}
while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) {
@ -287,7 +287,7 @@ CompatRunCommand(void *cmdp, void *gnp)
* If we did not end up with a command, just skip it.
*/
if (!*cmd)
return (0);
return 0;
#if !defined(MAKE_NATIVE)
/*
@ -307,7 +307,7 @@ CompatRunCommand(void *cmdp, void *gnp)
* go to the shell. Therefore treat '=' and ':' like shell
* meta characters as documented in make(1).
*/
useShell = needshell(cmd, FALSE);
#endif
@ -325,7 +325,7 @@ CompatRunCommand(void *cmdp, void *gnp)
* we go...
*/
if (!doIt && NoExecute(gn)) {
return (0);
return 0;
}
if (DEBUG(JOB))
fprintf(debug_file, "Execute: '%s'\n", cmd);
@ -377,7 +377,7 @@ CompatRunCommand(void *cmdp, void *gnp)
meta_compat_start();
}
#endif
/*
* Fork and execute the single command. If the fork fails, we abort.
*/
@ -499,8 +499,8 @@ CompatRunCommand(void *cmdp, void *gnp)
bmake_signal(compatSigno, SIG_DFL);
kill(myPid, compatSigno);
}
return (status);
return status;
}
/*-
@ -550,7 +550,7 @@ Compat_Make(void *gnp, void *pgnp)
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
}
@ -654,7 +654,7 @@ Compat_Make(void *gnp, void *pgnp)
} else {
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
}
switch(gn->made) {
@ -681,7 +681,7 @@ Compat_Make(void *gnp, void *pgnp)
cohorts:
Lst_ForEach(gn->cohorts, Compat_Make, pgnp);
return (0);
return 0;
}
/*-

38
cond.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.76 2020/06/28 11:06:26 rillig Exp $ */
/* $NetBSD: cond.c,v 1.78 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: cond.c,v 1.76 2020/06/28 11:06:26 rillig Exp $";
static char rcsid[] = "$NetBSD: cond.c,v 1.78 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: cond.c,v 1.76 2020/06/28 11:06:26 rillig Exp $");
__RCSID("$NetBSD: cond.c,v 1.78 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -186,7 +186,7 @@ static unsigned int cond_min_depth = 0; /* depth at makefile open */
* Indicate when we should be strict about lhs of comparisons.
* TRUE when Cond_EvalExpression is called from Cond_Eval (.if etc)
* FALSE when Cond_EvalExpression is called from var.c:ApplyModifiers
* since lhs is already expanded and we cannot tell if
* since lhs is already expanded and we cannot tell if
* it was a variable reference or not.
*/
static Boolean lhsStrict;
@ -256,7 +256,7 @@ CondGetArg(Boolean doEval, char **linePtr, char **argPtr, const char *func)
* the word 'make' or 'defined' at the beginning of a symbol...
*/
*argPtr = NULL;
return (0);
return 0;
}
while (*cp == ' ' || *cp == '\t') {
@ -314,11 +314,11 @@ CondGetArg(Boolean doEval, char **linePtr, char **argPtr, const char *func)
if (func != NULL && *cp++ != ')') {
Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
func);
return (0);
return 0;
}
*linePtr = cp;
return (argLen);
return argLen;
}
/*-
@ -347,7 +347,7 @@ CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
}
free(p1);
return (result);
return result;
}
/*-
@ -367,7 +367,7 @@ CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
static int
CondStrMatch(const void *string, const void *pattern)
{
return(!Str_Match(string, pattern));
return !Str_Match(string, pattern);
}
/*-
@ -412,14 +412,14 @@ CondDoExists(int argLen MAKE_ATTR_UNUSED, const char *arg)
if (DEBUG(COND)) {
fprintf(debug_file, "exists(%s) result is \"%s\"\n",
arg, path ? path : "");
}
}
if (path != NULL) {
result = TRUE;
free(path);
} else {
result = FALSE;
}
return (result);
return result;
}
/*-
@ -441,7 +441,7 @@ CondDoTarget(int argLen MAKE_ATTR_UNUSED, const char *arg)
GNode *gn;
gn = Targ_FindNode(arg, TARG_NOCREATE);
return (gn != NULL) && !OP_NOP(gn->type);
return gn != NULL && !OP_NOP(gn->type);
}
/*-
@ -465,7 +465,7 @@ CondDoCommands(int argLen MAKE_ATTR_UNUSED, const char *arg)
GNode *gn;
gn = Targ_FindNode(arg, TARG_NOCREATE);
return (gn != NULL) && !OP_NOP(gn->type) && !Lst_IsEmpty(gn->commands);
return gn != NULL && !OP_NOP(gn->type) && !Lst_IsEmpty(gn->commands);
}
/*-
@ -666,7 +666,7 @@ compare_expression(Boolean doEval)
rhs = NULL;
lhsFree = rhsFree = FALSE;
lhsQuoted = rhsQuoted = FALSE;
/*
* Parse the variable spec and skip over it, saving its
* value in lhs.
@ -709,7 +709,7 @@ compare_expression(Boolean doEval)
goto done;
}
/* For .ifxxx <number> compare against zero */
if (CondCvtArg(lhs, &left)) {
if (CondCvtArg(lhs, &left)) {
t = left != 0.0;
goto done;
}
@ -762,7 +762,7 @@ compare_expression(Boolean doEval)
* rhs is either a float or an integer. Convert both the
* lhs and the rhs to a double and compare the two.
*/
if (!CondCvtArg(lhs, &left) || !CondCvtArg(rhs, &right))
goto do_string_compare;
@ -1038,7 +1038,7 @@ CondT(Boolean doEval)
t = TOK_TRUE;
}
}
return (t);
return t;
}
/*-
@ -1084,7 +1084,7 @@ CondF(Boolean doEval)
CondPushBack(o);
}
}
return (l);
return l;
}
/*-
@ -1131,7 +1131,7 @@ CondE(Boolean doEval)
CondPushBack(o);
}
}
return (l);
return l;
}
/*-

56
dir.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.74 2020/06/05 18:03:59 sjg Exp $ */
/* $NetBSD: dir.c,v 1.76 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.74 2020/06/05 18:03:59 sjg Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.76 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.74 2020/06/05 18:03:59 sjg Exp $");
__RCSID("$NetBSD: dir.c,v 1.76 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -112,7 +112,7 @@ __RCSID("$NetBSD: dir.c,v 1.74 2020/06/05 18:03:59 sjg Exp $");
* Dir_FindHereOrAbove Search for a path in the current directory and
* then all the directories above it in turn until
* the path is found or we reach the root ("/").
*
*
* Dir_MTime Return the modification time of a node. The file
* is searched for along the default search path.
* The path and mtime fields of the node are filled
@ -377,7 +377,7 @@ void
Dir_InitCur(const char *cdname)
{
Path *p;
if (cdname != NULL) {
/*
* Our build directory is not the same as our source directory.
@ -480,7 +480,7 @@ Dir_SetPATH(void)
Boolean hasLastDot = FALSE; /* true we should search dot last */
Var_Delete(".PATH", VAR_GLOBAL);
if (Lst_Open(dirSearchPath) == SUCCESS) {
if ((ln = Lst_First(dirSearchPath)) != NULL) {
p = (Path *)Lst_Datum(ln);
@ -537,7 +537,7 @@ Dir_SetPATH(void)
static int
DirFindName(const void *p, const void *dname)
{
return (strcmp(((const Path *)p)->name, dname));
return strcmp(((const Path *)p)->name, dname);
}
/*-
@ -545,7 +545,7 @@ DirFindName(const void *p, const void *dname)
* Dir_HasWildcards --
* see if the given name has any wildcard characters in it
* be careful not to expand unmatching brackets or braces.
* XXX: This code is not 100% correct. ([^]] fails etc.)
* XXX: This code is not 100% correct. ([^]] fails etc.)
* I really don't think that make(1) should be expanding
* patterns, because then you have to set a mechanism for
* escaping the expansion!
@ -644,7 +644,7 @@ DirMatchFiles(const char *pattern, Path *p, Lst expansions)
STR_ADDSLASH)));
}
}
return (0);
return 0;
}
/*-
@ -947,7 +947,7 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
*-----------------------------------------------------------------------
*/
static char *
DirLookup(Path *p, const char *name MAKE_ATTR_UNUSED, const char *cp,
DirLookup(Path *p, const char *name MAKE_ATTR_UNUSED, const char *cp,
Boolean hasSlash MAKE_ATTR_UNUSED)
{
char *file; /* the current filename to check */
@ -1004,7 +1004,7 @@ DirLookupSubdir(Path *p, const char *name)
if (cached_stat(file, &stb) == 0) {
nearmisses += 1;
return (file);
return file;
}
free(file);
return NULL;
@ -1061,7 +1061,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
if (DEBUG(DIR)) {
fprintf(debug_file, " returning %s\n", name);
}
return (bmake_strdup(name));
return bmake_strdup(name);
}
/*-
@ -1087,7 +1087,7 @@ DirFindDot(Boolean hasSlash MAKE_ATTR_UNUSED, const char *name, const char *cp)
}
hits += 1;
dot->hits += 1;
return (bmake_strdup(name));
return bmake_strdup(name);
}
if (cur &&
Hash_FindEntry(&cur->files, cp) != NULL) {
@ -1185,7 +1185,7 @@ Dir_FindFile(const char *name, Lst path)
* is found, we concatenate the directory name and the final
* component and return the resulting string. If we don't find any
* such thing, we go on to phase two...
*
*
* No matter what, we always look for the file in the current
* directory before anywhere else (unless we found the magic
* DOTLAST path, in which case we search it last) and we *do not*
@ -1384,7 +1384,7 @@ Dir_FindFile(const char *name, Lst path)
}
if (Hash_FindEntry(&p->files, cp) != NULL) {
return (bmake_strdup(name));
return bmake_strdup(name);
} else {
return NULL;
}
@ -1395,7 +1395,7 @@ Dir_FindFile(const char *name, Lst path)
bigmisses += 1;
if (cached_stat(name, &stb) == 0) {
return (bmake_strdup(name));
return bmake_strdup(name);
}
if (DEBUG(DIR)) {
@ -1409,14 +1409,14 @@ Dir_FindFile(const char *name, Lst path)
/*-
*-----------------------------------------------------------------------
* Dir_FindHereOrAbove --
* search for a path starting at a given directory and then working
* search for a path starting at a given directory and then working
* our way up towards the root.
*
* Input:
* here starting directory
* search_path the path we are looking for
* result the result of a successful search is placed here
* rlen the length of the result buffer
* rlen the length of the result buffer
* (typically MAXPATHLEN + 1)
*
* Results:
@ -1426,7 +1426,7 @@ Dir_FindFile(const char *name, Lst path)
* Side Effects:
*-----------------------------------------------------------------------
*/
int
int
Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
struct stat st;
@ -1451,7 +1451,7 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
try_end = try + strlen(try);
while (try_end > try && *try_end != '/')
try_end--;
if (try_end > try)
if (try_end > try)
*try_end = 0; /* chop! */
}
@ -1459,10 +1459,10 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
* done!
*/
snprintf(result, rlen, "%s", try);
return(1);
return 1;
}
/*
/*
* nope, we didn't find it. if we used up dirbase we've
* reached the root and failed.
*/
@ -1479,9 +1479,9 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
} /* while (1) */
/*
* we failed...
* we failed...
*/
return(0);
return 0;
}
/*-
@ -1529,7 +1529,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
* see if we can find it via the current .PATH
*/
cp++;
fullName = Dir_FindFile(cp, Suff_FindPath(gn));
if (fullName) {
/*
@ -1572,7 +1572,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
}
gn->mtime = stb.st_mtime;
return (gn->mtime);
return gn->mtime;
}
/*-
@ -1677,7 +1677,7 @@ Dir_CopyDir(void *p)
{
((Path *)p)->refCount += 1;
return (p);
return p;
}
/*-
@ -1722,7 +1722,7 @@ Dir_MakeFlags(const char *flag, Lst path)
Lst_Close(path);
}
return (str);
return str;
}
/*-

14
for.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */
/* $NetBSD: for.c,v 1.54 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.54 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $");
__RCSID("$NetBSD: for.c,v 1.54 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -224,7 +224,7 @@ For_Eval(char *line)
words = brk_string(sub, &nwords, FALSE, &word_buf);
free(sub);
if (words != NULL) {
for (n = 0; n < nwords; n++) {
ptr = words[n];
@ -480,9 +480,9 @@ For_Iterate(void *v_arg, size_t *ret_len)
void
For_Run(int lineno)
{
{
For *arg;
arg = accumFor;
accumFor = NULL;
@ -491,6 +491,6 @@ For_Run(int lineno)
For_Free(arg);
return;
}
Parse_SetInput(NULL, lineno, -1, For_Iterate, arg);
}

25
hash.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $ */
/* $NetBSD: hash.c,v 1.22 2020/07/03 17:03:09 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $";
static char rcsid[] = "$NetBSD: hash.c,v 1.22 2020/07/03 17:03:09 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $");
__RCSID("$NetBSD: hash.c,v 1.22 2020/07/03 17:03:09 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -229,7 +229,7 @@ Hash_FindEntry(Hash_Table *t, const char *key)
p = key;
for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next)
if (e->namehash == h && strcmp(e->name, p) == 0)
return (e);
return e;
return NULL;
}
@ -279,7 +279,7 @@ Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr)
if (e->namehash == h && strcmp(e->name, p) == 0) {
if (newPtr != NULL)
*newPtr = FALSE;
return (e);
return e;
}
}
@ -301,7 +301,7 @@ Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr)
if (newPtr != NULL)
*newPtr = TRUE;
return (e);
return e;
}
/*
@ -418,7 +418,7 @@ Hash_EnumNext(Hash_Search *searchPtr)
e = t->bucketPtr[searchPtr->nextIndex++];
}
searchPtr->hashEntryPtr = e;
return (e);
return e;
}
/*
@ -464,3 +464,14 @@ RebuildTable(Hash_Table *t)
}
free(oldhp);
}
void Hash_ForEach(Hash_Table *t, void (*action)(void *, void *), void *data)
{
Hash_Search search;
Hash_Entry *e;
for (e = Hash_EnumFirst(t, &search);
e != NULL;
e = Hash_EnumNext(&search))
action(Hash_GetValue(e), data);
}

3
hash.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: hash.h,v 1.12 2017/05/31 21:07:03 maya Exp $ */
/* $NetBSD: hash.h,v 1.13 2020/07/03 17:03:09 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -145,5 +145,6 @@ Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);
void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
Hash_Entry *Hash_EnumNext(Hash_Search *);
void Hash_ForEach(Hash_Table *, void (*)(void *, void *), void *);
#endif /* _HASH_H */

62
job.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $ */
/* $NetBSD: job.c,v 1.201 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.201 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $");
__RCSID("$NetBSD: job.c,v 1.201 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -274,7 +274,7 @@ static Shell shells[] = {
"",
},
/*
* KSH description.
* KSH description.
*/
{
"ksh",
@ -447,7 +447,7 @@ JobCreatePipe(Job *job, int minfd)
job->jobPipe[i] = fd;
}
}
/* Set close-on-exec flag for both */
if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1)
Punt("Cannot set close-on-exec: %s", strerror(errno));
@ -457,7 +457,7 @@ JobCreatePipe(Job *job, int minfd)
/*
* We mark the input side of the pipe non-blocking; we poll(2) the
* pipe when we're waiting for a job token, but we might lose the
* 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.
*/
flags = fcntl(job->jobPipe[0], F_GETFL, 0);
@ -780,7 +780,7 @@ JobPrintCommand(void *cmdp, void *jobp)
/*
* If the shell doesn't have error control the alternate echo'ing will
* be done (to avoid showing additional error checking code)
* be done (to avoid showing additional error checking code)
* and this will need the characters '$ ` \ "' escaped
*/
@ -788,10 +788,10 @@ JobPrintCommand(void *cmdp, void *jobp)
/* Worst that could happen is every char needs escaping. */
escCmd = bmake_malloc((strlen(cmd) * 2) + 1);
for (i = 0, j= 0; cmd[i] != '\0'; i++, j++) {
if (cmd[i] == '$' || cmd[i] == '`' || cmd[i] == '\\' ||
if (cmd[i] == '$' || cmd[i] == '`' || cmd[i] == '\\' ||
cmd[i] == '"')
escCmd[j++] = '\\';
escCmd[j] = cmd[i];
escCmd[j] = cmd[i];
}
escCmd[j] = 0;
}
@ -864,13 +864,13 @@ JobPrintCommand(void *cmdp, void *jobp)
}
} else {
/*
/*
* If errors are being checked and the shell doesn't have error control
* but does supply an errOut template, then setup commands to run
* through it.
*/
if (!commandShell->hasErrCtl && commandShell->errOut &&
if (!commandShell->hasErrCtl && commandShell->errOut &&
(*commandShell->errOut != '\0')) {
if (!(job->flags & JOB_SILENT) && !shutUp) {
if (commandShell->hasEchoCtl) {
@ -894,7 +894,7 @@ JobPrintCommand(void *cmdp, void *jobp)
DBPRINTF("set -%s\n", "x");
job->flags |= JOB_TRACED;
}
DBPRINTF(cmdTemplate, cmd);
free(cmdStart);
free(escCmd);
@ -935,7 +935,7 @@ JobSaveCommand(void *cmd, void *gn)
{
cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, VARF_WANTRES);
(void)Lst_AtEnd(postCommands->commands, cmd);
return(0);
return 0;
}
@ -1102,7 +1102,7 @@ JobFinish (Job *job, WAIT_T status)
}
}
#endif
return_job_token = FALSE;
Trace_Log(JOBEND, job);
@ -1274,7 +1274,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
* .DEFAULT itself.
*/
Make_HandleUse(DEFAULT, gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
free(p1);
} else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
/*
@ -1419,7 +1419,7 @@ JobExec(Job *job, char **argv)
_exit(1);
}
}
/*
* Set up the child's output to be routed through the pipe
* we've created for it.
@ -1768,7 +1768,7 @@ JobStart(GNode *gn, int flags)
JobCreatePipe(job, 3);
JobExec(job, argv);
return(JOB_RUNNING);
return JOB_RUNNING;
}
static char *
@ -2260,11 +2260,11 @@ Shell_GetNewline(void)
void
Job_SetPrefix(void)
{
if (targPrefix) {
free(targPrefix);
} else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0);
Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL);
}
targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
@ -2410,7 +2410,7 @@ JobMatchShell(const char *name)
for (sh = shells; sh->name != NULL; sh++) {
if (strcmp(name, sh->name) == 0)
return (sh);
return sh;
}
return NULL;
}
@ -2526,7 +2526,7 @@ Job_ParseShell(char *line)
Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"",
*argv);
free(words);
return(FAILURE);
return FAILURE;
}
fullSpec = TRUE;
}
@ -2542,13 +2542,13 @@ Job_ParseShell(char *line)
if (newShell.name == NULL) {
Parse_Error(PARSE_FATAL, "Neither path nor name specified");
free(words);
return(FAILURE);
return FAILURE;
} else {
if ((sh = JobMatchShell(newShell.name)) == NULL) {
Parse_Error(PARSE_WARNING, "%s: No matching shell",
newShell.name);
free(words);
return(FAILURE);
return FAILURE;
}
commandShell = sh;
shellName = newShell.name;
@ -2584,7 +2584,7 @@ Job_ParseShell(char *line)
Parse_Error(PARSE_WARNING, "%s: No matching shell",
shellName);
free(words);
return(FAILURE);
return FAILURE;
}
commandShell = sh;
} else {
@ -2701,7 +2701,7 @@ Job_Finish(void)
JobRun(postCommands);
}
}
return(errors);
return errors;
}
/*-
@ -2940,7 +2940,7 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1)
{
int i;
char jobarg[64];
if (jp_0 >= 0 && jp_1 >= 0) {
/* Pipe passed in from parent */
tokenWaitJob.inPipe = jp_0;
@ -2956,12 +2956,12 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1)
tokenWaitJob.inPipe, tokenWaitJob.outPipe);
Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);
Var_Append(MAKEFLAGS, jobarg, VAR_GLOBAL);
Var_Append(MAKEFLAGS, jobarg, VAR_GLOBAL);
/*
* Preload the job pipe with one token per job, save the one
* "extra" token for the primary job.
*
*
* XXX should clip maxJobs against PIPE_BUF -- if max_tokens is
* larger than the write buffer size of the pipe, we will
* deadlock here.
@ -3078,7 +3078,7 @@ Job_RunTarget(const char *target, const char *fname) {
return FALSE;
if (fname)
Var_Set(ALLSRC, fname, gn, 0);
Var_Set(ALLSRC, fname, gn);
JobRun(gn);
if (gn->made == ERROR) {
@ -3113,9 +3113,9 @@ emul_poll(struct pollfd *fd, int nfd, int timeout)
if (fd[i].fd > maxfd)
maxfd = fd[i].fd;
}
if (maxfd >= FD_SETSIZE) {
Punt("Ran out of fd_set slots; "
Punt("Ran out of fd_set slots; "
"recompile with a larger FD_SETSIZE.");
}

12
job.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: job.h,v 1.42 2013/07/05 22:14:56 sjg Exp $ */
/* $NetBSD: job.h,v 1.43 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -106,7 +106,7 @@ emul_poll(struct pollfd *fd, int nfd, int timeout);
/*
* The POLL_MSEC constant determines the maximum number of milliseconds spent
* in poll before coming out to see if a child has finished.
* in poll before coming out to see if a child has finished.
*/
#define POLL_MSEC 5000
@ -203,11 +203,11 @@ typedef struct Job {
* a case, errCheck becomes a printf template for echoing the command,
* should echoing be on and ignErr becomes another printf template for
* executing the command while ignoring the return status. Finally errOut
* is a printf template for running the command and causing the shell to
* exit on error. If any of these strings are empty when hasErrCtl is FALSE,
* the command will be executed anyway as is and if it causes an error, so be
* is a printf template for running the command and causing the shell to
* exit on error. If any of these strings are empty when hasErrCtl is FALSE,
* the command will be executed anyway as is and if it causes an error, so be
* it. Any templates setup to echo the command will escape any '$ ` \ "'i
* characters in the command string to avoid common problems with
* characters in the command string to avoid common problems with
* echo "%s\n" as a template.
*/
typedef struct Shell {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstAppend.c,v 1.15 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.15 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstAppend.c,v 1.15 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -85,7 +85,7 @@ Lst_InsertAfter(Lst l, LstNode ln, void *d)
}
if (!LstValid (l) || LstIsEmpty (l) || ! LstNodeValid (ln, l)) {
return (FAILURE);
return FAILURE;
}
ok:
@ -117,6 +117,5 @@ Lst_InsertAfter(Lst l, LstNode ln, void *d)
}
}
return (SUCCESS);
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstAtEnd.c,v 1.14 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.14 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstAtEnd.c,v 1.14 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -75,5 +75,5 @@ Lst_AtEnd(Lst l, void *d)
LstNode end;
end = Lst_Last(l);
return (Lst_InsertAfter(l, end, d));
return Lst_InsertAfter(l, end, d);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstAtFront.c,v 1.14 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.14 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstAtFront.c,v 1.14 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -72,5 +72,5 @@ Lst_AtFront(Lst l, void *d)
LstNode front;
front = Lst_First(l);
return (Lst_InsertBefore(l, front, d));
return Lst_InsertBefore(l, front, d);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $ */
/* $NetBSD: lstClose.c,v 1.12 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $";
static char rcsid[] = "$NetBSD: lstClose.c,v 1.12 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $");
__RCSID("$NetBSD: lstClose.c,v 1.12 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -83,4 +83,3 @@ Lst_Close(Lst l)
list->atEnd = Unknown;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstConcat.c,v 1.17 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.17 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstConcat.c,v 1.17 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -86,7 +86,7 @@ Lst_Concat(Lst l1, Lst l2, int flags)
List list2 = l2;
if (!LstValid (l1) || !LstValid (l2)) {
return (FAILURE);
return FAILURE;
}
if (flags == LST_CONCLINK) {
@ -180,6 +180,5 @@ Lst_Concat(Lst l1, Lst l2, int flags)
}
}
return (SUCCESS);
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstDatum.c,v 1.14 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.14 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstDatum.c,v 1.14 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -69,9 +69,8 @@ void *
Lst_Datum(LstNode ln)
{
if (ln != NULL) {
return ((ln)->datum);
return ln->datum;
} else {
return NULL;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstDeQueue.c,v 1.15 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.15 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstDeQueue.c,v 1.15 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -81,7 +81,6 @@ Lst_DeQueue(Lst l)
if (Lst_Remove(l, tln) == FAILURE) {
return NULL;
} else {
return (rd);
return rd;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstDupl.c,v 1.17 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.17 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstDupl.c,v 1.17 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -103,5 +103,5 @@ Lst_Duplicate(Lst l, DuplicateProc *copyProc)
}
}
return (nl);
return nl;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstEnQueue.c,v 1.14 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.14 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstEnQueue.c,v 1.14 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -70,9 +70,8 @@ ReturnStatus
Lst_EnQueue(Lst l, void *d)
{
if (LstValid (l) == FALSE) {
return (FAILURE);
return FAILURE;
}
return (Lst_InsertAfter(l, Lst_Last(l), d));
return Lst_InsertAfter(l, Lst_Last(l), d);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $ */
/* $NetBSD: lstFind.c,v 1.16 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $";
static char rcsid[] = "$NetBSD: lstFind.c,v 1.16 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $");
__RCSID("$NetBSD: lstFind.c,v 1.16 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -69,6 +69,5 @@ __RCSID("$NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $");
LstNode
Lst_Find(Lst l, const void *d, int (*cProc)(const void *, const void *))
{
return (Lst_FindFrom(l, Lst_First(l), d, cProc));
return Lst_FindFrom(l, Lst_First(l), d, cProc);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $ */
/* $NetBSD: lstFindFrom.c,v 1.16 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $";
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.16 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $");
__RCSID("$NetBSD: lstFindFrom.c,v 1.16 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -81,10 +81,9 @@ Lst_FindFrom(Lst l, LstNode ln, const void *d,
do {
if ((*cProc)(tln->datum, d) == 0)
return (tln);
return tln;
tln = tln->nextPtr;
} while (tln != ln && tln != NULL);
return NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstFirst.c,v 1.13 2020/07/03 08:37:56 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.13 2020/07/03 08:37:56 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstFirst.c,v 1.13 2020/07/03 08:37:56 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -71,7 +71,6 @@ Lst_First(Lst l)
if (!LstValid (l) || LstIsEmpty (l)) {
return NULL;
} else {
return (l->firstPtr);
return l->firstPtr;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstForEach.c,v 1.14 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.14 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstForEach.c,v 1.14 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -73,4 +73,3 @@ Lst_ForEach(Lst l, int (*proc)(void *, void *), void *d)
{
return Lst_ForEachFrom(l, Lst_First(l), proc, d);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstForEachFrom.c,v 1.18 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.18 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstForEachFrom.c,v 1.18 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -122,4 +122,3 @@ Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(void *, void *),
return result;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstInit.c,v 1.13 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstInit.c,v 1.13 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstInit.c,v 1.13 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -81,5 +81,5 @@ Lst_Init(Boolean circ)
nList->isCirc = circ;
nList->atEnd = Unknown;
return (nList);
return nList;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstInsert.c,v 1.15 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.15 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstInsert.c,v 1.15 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -87,7 +87,7 @@ Lst_InsertBefore(Lst l, LstNode ln, void *d)
goto ok;
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
return (FAILURE);
return FAILURE;
}
ok:
@ -117,6 +117,5 @@ Lst_InsertBefore(Lst l, LstNode ln, void *d)
}
}
return (SUCCESS);
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $ */
/* $NetBSD: lstIsAtEnd.c,v 1.14 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $";
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.14 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $");
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.14 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -81,7 +81,6 @@ Lst_IsAtEnd(Lst l)
{
List list = l;
return (!LstValid (l) || !list->isOpen ||
(list->atEnd == Head) || (list->atEnd == Tail));
return !LstValid (l) || !list->isOpen ||
list->atEnd == Head || list->atEnd == Tail;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstIsEmpty.c,v 1.12 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstIsEmpty.c,v 1.12 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstIsEmpty.c,v 1.12 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -70,6 +70,5 @@ __RCSID("$NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $");
Boolean
Lst_IsEmpty(Lst l)
{
return ( ! LstValid (l) || LstIsEmpty(l));
return !LstValid(l) || LstIsEmpty(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstLast.c,v 1.13 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstLast.c,v 1.13 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstLast.c,v 1.13 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -71,7 +71,6 @@ Lst_Last(Lst l)
if (!LstValid(l) || LstIsEmpty (l)) {
return NULL;
} else {
return (l->lastPtr);
return l->lastPtr;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstNext.c,v 1.13 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstNext.c,v 1.13 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstNext.c,v 1.13 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -115,6 +115,5 @@ Lst_Next(Lst l)
}
}
return (tln);
return tln;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstOpen.c,v 1.13 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.13 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstOpen.c,v 1.13 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -76,12 +76,11 @@ ReturnStatus
Lst_Open(Lst l)
{
if (LstValid (l) == FALSE) {
return (FAILURE);
return FAILURE;
}
(l)->isOpen = TRUE;
(l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
(l)->curPtr = NULL;
return (SUCCESS);
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstPrev.c,v 1.4 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstPrev.c,v 1.4 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstPrev.c,v 1.4 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -73,7 +73,6 @@ Lst_Prev(LstNode ln)
if (ln == NULL) {
return NULL;
} else {
return (ln->prevPtr);
return ln->prevPtr;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $ */
/* $NetBSD: lstRemove.c,v 1.17 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $";
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.17 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $");
__RCSID("$NetBSD: lstRemove.c,v 1.17 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -73,9 +73,8 @@ Lst_Remove(Lst l, LstNode ln)
List list = l;
ListNode lNode = ln;
if (!LstValid (l) ||
!LstNodeValid (ln, l)) {
return (FAILURE);
if (!LstValid (l) || !LstNodeValid (ln, l)) {
return FAILURE;
}
/*
@ -131,6 +130,5 @@ Lst_Remove(Lst l, LstNode ln)
lNode->flags |= LN_DELETED;
}
return (SUCCESS);
return SUCCESS;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
/* $NetBSD: lstReplace.c,v 1.14 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.14 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
__RCSID("$NetBSD: lstReplace.c,v 1.14 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -69,10 +69,9 @@ ReturnStatus
Lst_Replace(LstNode ln, void *d)
{
if (ln == NULL) {
return (FAILURE);
return FAILURE;
} else {
(ln)->datum = d;
return (SUCCESS);
return SUCCESS;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstSucc.c,v 1.14 2020/07/03 08:37:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.14 2020/07/03 08:37:57 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstSucc.c,v 1.14 2020/07/03 08:37:57 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -73,7 +73,6 @@ Lst_Succ(LstNode ln)
if (ln == NULL) {
return NULL;
} else {
return (ln->nextPtr);
return ln->nextPtr;
}
}

110
main.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $ */
/* $NetBSD: main.c,v 1.279 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.279 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $");
__RCSID("$NetBSD: main.c,v 1.279 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -245,7 +245,7 @@ explode(const char *flags)
*nf = '\0';
return st;
}
static void
parse_debug_options(const char *argvalue)
{
@ -429,7 +429,7 @@ MainParseArgs(int argc, char **argv)
/* Can't actually use getopt(3) because rescanning is not portable */
getopt_def = OPTFLAGS;
rearg:
rearg:
inOption = FALSE;
optscan = NULL;
while(argc > 1) {
@ -465,7 +465,7 @@ MainParseArgs(int argc, char **argv)
arginc = 2;
}
} else {
argvalue = NULL;
argvalue = NULL;
}
switch(c) {
case '\0':
@ -475,7 +475,7 @@ MainParseArgs(int argc, char **argv)
case 'B':
compatMake = TRUE;
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
Var_Set(MAKE_MODE, "compat", VAR_GLOBAL, 0);
Var_Set(MAKE_MODE, "compat", VAR_GLOBAL);
break;
case 'C':
if (chdir(argvalue) == -1) {
@ -499,7 +499,7 @@ MainParseArgs(int argc, char **argv)
break;
case 'D':
if (argvalue == NULL || argvalue[0] == 0) goto noarg;
Var_Set(argvalue, "1", VAR_GLOBAL, 0);
Var_Set(argvalue, "1", VAR_GLOBAL);
Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
break;
@ -598,7 +598,7 @@ MainParseArgs(int argc, char **argv)
}
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL, 0);
Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL);
maxJobTokens = maxJobs;
break;
case 'k':
@ -776,7 +776,7 @@ Main_SetObjdir(const char *fmt, ...)
path, strerror(errno));
} else {
strncpy(objdir, path, MAXPATHLEN);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
setenv("PWD", objdir, 1);
Dir_InitDot();
purge_cached_realpaths();
@ -822,7 +822,7 @@ Main_SetVarObjdir(const char *var, const char *suffix)
static int
ReadAllMakefiles(const void *p, const void *q)
{
return (ReadMakefile(p, q) == 0);
return ReadMakefile(p, q) == 0;
}
int
@ -838,7 +838,7 @@ str2Lst_Append(Lst lp, char *str, const char *sep)
(void)Lst_AtEnd(lp, cp);
n++;
}
return (n);
return n;
}
#ifdef SIGINFO
@ -901,14 +901,14 @@ doPrintVars(void)
char *var = (char *)Lst_Datum(ln);
char *value;
char *p1;
if (strchr(var, '$')) {
value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
VARF_WANTRES);
} else if (expandVars) {
char tmp[128];
int len = snprintf(tmp, sizeof(tmp), "${%s}", var);
if (len >= (int)sizeof(tmp))
Fatal("%s: variable name too big: %s",
progname, var);
@ -1017,7 +1017,7 @@ main(int argc, char **argv)
*/
gettimeofday(&rightnow, NULL);
srandom(rightnow.tv_sec + rightnow.tv_usec);
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
else
@ -1067,7 +1067,7 @@ main(int argc, char **argv)
static char machine_arch_buf[sizeof(utsname.machine)];
int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
size_t len = sizeof(machine_arch_buf);
if (sysctl(mib, __arraycount(mib), machine_arch_buf,
&len, NULL, 0) < 0) {
(void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
@ -1096,13 +1096,13 @@ main(int argc, char **argv)
*/
Var_Init(); /* Initialize the lists of variables for
* parsing arguments */
Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0);
Var_Set("MACHINE", machine, VAR_GLOBAL, 0);
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0);
Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL);
Var_Set("MACHINE", machine, VAR_GLOBAL);
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
#ifdef MAKE_VERSION
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0);
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
#endif
Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */
Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
/*
* This is the traditional preference for makefiles.
*/
@ -1110,8 +1110,8 @@ main(int argc, char **argv)
# define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
#endif
Var_Set(MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST,
VAR_GLOBAL, 0);
Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL, 0);
VAR_GLOBAL);
Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
create = Lst_Init(FALSE);
makefiles = Lst_Init(FALSE);
@ -1165,14 +1165,14 @@ main(int argc, char **argv)
p1 = argv[0]; /* realpath failed */
}
}
Var_Set("MAKE", p1, VAR_GLOBAL, 0);
Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);
Var_Set("MAKE", p1, VAR_GLOBAL);
Var_Set(".MAKE", p1, VAR_GLOBAL);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
Var_Set("MFLAGS", "", VAR_GLOBAL);
Var_Set(".ALLTARGETS", "", VAR_GLOBAL);
/* some makefiles need to know this */
Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD, 0);
Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD);
/*
* Set some other useful macros
@ -1184,11 +1184,11 @@ main(int argc, char **argv)
if (makelevel < 0)
makelevel = 0;
snprintf(tmp, sizeof(tmp), "%d", makelevel);
Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0);
Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL);
snprintf(tmp, sizeof(tmp), "%u", myPid);
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL);
snprintf(tmp, sizeof(tmp), "%u", getppid());
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL);
}
if (makelevel > 0) {
char pn[1024];
@ -1269,7 +1269,7 @@ main(int argc, char **argv)
free(ptmp2);
}
#endif
Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
/*
* Find the .OBJDIR. If MAKEOBJDIRPREFIX, or failing that,
@ -1303,7 +1303,7 @@ main(int argc, char **argv)
(void)time(&now);
Trace_Log(MAKESTART, NULL);
/*
* Set up the .TARGETS variable to contain the list of targets to be
* created. If none specified, make the variable empty -- the parser
@ -1319,7 +1319,7 @@ main(int argc, char **argv)
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
} else
Var_Set(".TARGETS", "", VAR_GLOBAL, 0);
Var_Set(".TARGETS", "", VAR_GLOBAL);
/*
@ -1342,7 +1342,7 @@ main(int argc, char **argv)
if (strncmp(".../", start, 4) != 0) {
(void)Dir_AddDir(defIncPath, start);
} else {
if (Dir_FindHereOrAbove(curdir, start+4,
if (Dir_FindHereOrAbove(curdir, start+4,
found_path, sizeof(found_path))) {
(void)Dir_AddDir(defIncPath, found_path);
}
@ -1377,7 +1377,7 @@ main(int argc, char **argv)
ln = Lst_Find(makefiles, NULL, ReadAllMakefiles);
if (ln != NULL)
Fatal("%s: cannot open %s.", progname,
Fatal("%s: cannot open %s.", progname,
(char *)Lst_Datum(ln));
} else {
p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}",
@ -1400,7 +1400,7 @@ main(int argc, char **argv)
if (enterFlagObj)
printf("%s: Entering directory `%s'\n", progname, objdir);
MakeMode(NULL);
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
@ -1444,7 +1444,8 @@ main(int argc, char **argv)
if (!printVars)
Main_ExportMAKEFLAGS(TRUE); /* initial export */
/*
* For compatibility, look at the directories in the VPATH variable
* and add them to the search path, if the variable is defined. The
@ -1552,21 +1553,21 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
if (!strcmp(fname, "-")) {
Parse_File(NULL /*stdin*/, -1);
Var_Set("MAKEFILE", "", VAR_INTERNAL, 0);
Var_Set("MAKEFILE", "", VAR_INTERNAL);
} else {
/* if we've chdir'd, rebuild the path name */
if (strcmp(curdir, objdir) && *fname != '/') {
size_t plen = strlen(curdir) + strlen(fname) + 2;
if (len < plen)
path = bmake_realloc(path, len = 2 * plen);
(void)snprintf(path, len, "%s/%s", curdir, fname);
fd = open(path, O_RDONLY);
if (fd != -1) {
fname = path;
goto found;
}
/* If curdir failed, try objdir (ala .depend) */
plen = strlen(objdir) + strlen(fname) + 2;
if (len < plen)
@ -1590,7 +1591,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
if (!name || (fd = open(name, O_RDONLY)) == -1) {
free(name);
free(path);
return(-1);
return -1;
}
fname = name;
/*
@ -1600,11 +1601,11 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
*/
found:
if (!doing_depend)
Var_Set("MAKEFILE", fname, VAR_INTERNAL, 0);
Var_Set("MAKEFILE", fname, VAR_INTERNAL);
Parse_File(fname, fd);
}
free(path);
return(0);
return 0;
}
@ -2020,8 +2021,9 @@ cached_realpath(const char *pathname, char *resolved)
/* a hit */
strlcpy(resolved, rp, MAXPATHLEN);
} else if ((rp = realpath(pathname, resolved)) != NULL) {
Var_Set(pathname, rp, cache, 0);
}
Var_Set(pathname, rp, cache);
} /* else should we negative-cache? */
free(cp);
return rp ? resolved : NULL;
}
@ -2077,7 +2079,7 @@ PrintOnError(GNode *gn, const char *s)
if (s)
printf("%s", s);
printf("\n%s: stopped in %s\n", progname, curdir);
if (en)
@ -2086,7 +2088,7 @@ PrintOnError(GNode *gn, const char *s)
/*
* We can print this even if there is no .ERROR target.
*/
Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL, 0);
Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
Var_Delete(".ERROR_CMD", VAR_GLOBAL);
Lst_ForEach(gn->commands, addErrorCMD, gn);
}
@ -2120,7 +2122,7 @@ Main_ExportMAKEFLAGS(Boolean first)
if (once != first)
return;
once = 0;
strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
sizeof(tmp));
s = Var_Subst(NULL, tmp, VAR_CMD, VARF_WANTRES);
@ -2166,7 +2168,7 @@ mkTempFile(const char *pattern, char **fnamep)
static char *tmpdir = NULL;
char tfile[MAXPATHLEN];
int fd;
if (!pattern)
pattern = TMPPAT;
if (!tmpdir)
@ -2222,7 +2224,7 @@ s2Boolean(const char *s, Boolean bf)
break;
}
}
return (bf);
return bf;
}
/*
@ -2246,5 +2248,5 @@ getBoolean(const char *name, Boolean bf)
free(cp);
}
}
return (bf);
return bf;
}

56
make.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $ */
/* $NetBSD: make.c,v 1.99 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.99 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $");
__RCSID("$NetBSD: make.c,v 1.99 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -175,7 +175,7 @@ Make_TimeStamp(GNode *pgn, GNode *cgn)
if (pgn->cmgn == NULL || cgn->mtime > pgn->cmgn->mtime) {
pgn->cmgn = cgn;
}
return (0);
return 0;
}
/*
@ -264,7 +264,7 @@ Make_OODate(GNode *gn)
* always out of date if no children and :: target
* or non-existent.
*/
oodate = (gn->mtime == 0 || Arch_LibOODate(gn) ||
oodate = (gn->mtime == 0 || Arch_LibOODate(gn) ||
(gn->cmgn == NULL && (gn->type & OP_DOUBLEDEP)));
} else if (gn->type & OP_JOIN) {
/*
@ -317,7 +317,7 @@ Make_OODate(GNode *gn)
}
oodate = TRUE;
} else {
/*
/*
* When a non-existing child with no sources
* (such as a typically used FORCE source) has been made and
* the target of the child (usually a directory) has the same
@ -348,7 +348,7 @@ Make_OODate(GNode *gn)
Lst_ForEach(gn->parents, MakeTimeStamp, gn);
}
return (oodate);
return oodate;
}
/*-
@ -380,7 +380,7 @@ MakeAddChild(void *gnp, void *lp)
gn->name, gn->cohort_num);
(void)Lst_EnQueue(l, gn);
}
return (0);
return 0;
}
/*-
@ -410,7 +410,7 @@ MakeFindChild(void *gnp, void *pgnp)
Make_TimeStamp(pgn, gn);
pgn->unmade--;
return (0);
return 0;
}
/*-
@ -535,7 +535,7 @@ MakeHandleUse(void *cgnp, void *pgnp)
cgn->type |= OP_MARK;
if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0)
return (0);
return 0;
if (unmarked)
Make_HandleUse(cgn, pgn);
@ -551,7 +551,7 @@ MakeHandleUse(void *cgnp, void *pgnp)
Lst_Remove(pgn->children, ln);
pgn->unmade--;
}
return (0);
return 0;
}
@ -831,9 +831,9 @@ Make_Update(GNode *cgn)
while ((ln = Lst_Next(cgn->iParents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
if (pgn->flags & REMAKE) {
Var_Set(IMPSRC, cname, pgn, 0);
Var_Set(IMPSRC, cname, pgn);
if (cpref != NULL)
Var_Set(PREFIX, cpref, pgn, 0);
Var_Set(PREFIX, cpref, pgn);
}
}
free(p1);
@ -869,7 +869,7 @@ MakeUnmark(void *cgnp, void *pgnp MAKE_ATTR_UNUSED)
GNode *cgn = (GNode *)cgnp;
cgn->type &= ~OP_MARK;
return (0);
return 0;
}
/*
@ -886,7 +886,7 @@ MakeAddAllSrc(void *cgnp, void *pgnp)
GNode *pgn = (GNode *)pgnp;
if (cgn->type & OP_MARK)
return (0);
return 0;
cgn->type |= OP_MARK;
if ((cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE|OP_INVISIBLE)) == 0) {
@ -932,7 +932,7 @@ MakeAddAllSrc(void *cgnp, void *pgnp)
}
free(p1);
}
return (0);
return 0;
}
/*-
@ -962,20 +962,20 @@ Make_DoAllVar(GNode *gn)
{
if (gn->flags & DONE_ALLSRC)
return;
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeAddAllSrc, gn);
if (!Var_Exists (OODATE, gn)) {
Var_Set(OODATE, "", gn, 0);
Var_Set(OODATE, "", gn);
}
if (!Var_Exists (ALLSRC, gn)) {
Var_Set(ALLSRC, "", gn, 0);
Var_Set(ALLSRC, "", gn);
}
if (gn->type & OP_JOIN) {
char *p1;
Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0);
Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn);
free(p1);
}
gn->flags |= DONE_ALLSRC;
@ -1119,7 +1119,7 @@ MakeStartJobs(void)
fprintf(debug_file, "out-of-date\n");
}
if (queryFlag) {
return (TRUE);
return TRUE;
}
Make_DoAllVar(gn);
Job_Make(gn);
@ -1145,7 +1145,7 @@ MakeStartJobs(void)
if (have_token)
Job_TokenReturn();
return (FALSE);
return FALSE;
}
/*-
@ -1293,7 +1293,7 @@ Make_ExpandUse(Lst targs)
*/
while (!Lst_IsEmpty (examine)) {
gn = (GNode *)Lst_DeQueue(examine);
if (gn->flags & REMAKE)
/* We've looked at this one already */
continue;
@ -1324,14 +1324,14 @@ Make_ExpandUse(Lst targs)
continue;
*eoa = '\0';
*eon = '\0';
Var_Set(MEMBER, eoa + 1, gn, 0);
Var_Set(ARCHIVE, gn->name, gn, 0);
Var_Set(MEMBER, eoa + 1, gn);
Var_Set(ARCHIVE, gn->name, gn);
*eoa = '(';
*eon = ')';
}
(void)Dir_MTime(gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeHandleUse, gn);
@ -1429,7 +1429,7 @@ Make_ProcessWait(Lst targs)
while (!Lst_IsEmpty (examine)) {
pgn = Lst_DeQueue(examine);
/* We only want to process each child-list once */
if (pgn->flags & DONE_WAIT)
continue;
@ -1509,7 +1509,7 @@ Make_Run(Lst targs)
* next loop... (we won't actually start any, of course, this is just
* to see if any of the targets was out of date)
*/
return (MakeStartJobs());
return MakeStartJobs();
}
/*
* Initialization. At the moment, no jobs are running and until some

6
make.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.108 2020/06/19 21:17:48 sjg Exp $ */
/* $NetBSD: make.h,v 1.109 2020/07/02 15:14:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -512,10 +512,6 @@ int str2Lst_Append(Lst, char *, const char *);
int cached_lstat(const char *, void *);
int cached_stat(const char *, void *);
#define VARF_UNDEFERR 1
#define VARF_WANTRES 2
#define VARF_ASSIGN 4
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
union __unconst { \

View File

@ -1,4 +1,4 @@
/* $NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $ */
/* $NetBSD: make_malloc.c,v 1.12 2020/07/03 08:02:55 rillig Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -28,7 +28,7 @@
#ifdef MAKE_NATIVE
#include <sys/cdefs.h>
__RCSID("$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $");
__RCSID("$NetBSD: make_malloc.c,v 1.12 2020/07/03 08:02:55 rillig Exp $");
#endif
#include <stdio.h>
@ -63,7 +63,7 @@ bmake_malloc(size_t len)
if ((p = malloc(len)) == NULL)
enomem();
return(p);
return p;
}
/*
@ -102,7 +102,7 @@ bmake_strndup(const char *str, size_t max_len)
memcpy(p, str, len);
p[len] = '\0';
return(p);
return p;
}
/*
@ -114,6 +114,6 @@ bmake_realloc(void *ptr, size_t size)
{
if ((ptr = realloc(ptr, size)) == NULL)
enomem();
return(ptr);
return ptr;
}
#endif

74
meta.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: meta.c,v 1.82 2020/06/25 15:45:37 sjg Exp $ */
/* $NetBSD: meta.c,v 1.85 2020/07/03 08:13:23 rillig Exp $ */
/*
* Implement 'meta' mode.
@ -8,16 +8,16 @@
/*
* Copyright (c) 2009-2016, Juniper Networks, Inc.
* Portions Copyright (c) 2009, John Birrell.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -28,7 +28,7 @@
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_META)
@ -113,7 +113,7 @@ extern char **environ;
*
* See meta_oodate below - we mainly care about 'E' and 'R'.
*
* We can still use meta mode without filemon, but
* We can still use meta mode without filemon, but
* the benefits are more limited.
*/
#ifdef USE_FILEMON
@ -218,7 +218,7 @@ eat_dots(char *buf, size_t bufsz, int dots)
default:
return;
}
do {
cp = strstr(buf, eat);
if (cp) {
@ -308,7 +308,7 @@ meta_name(char *mname, size_t mnamelen,
}
}
free(tp);
return (mname);
return mname;
}
/*
@ -359,7 +359,7 @@ is_submake(void *cmdp, void *gnp)
}
}
free(mp);
return (rc);
return rc;
}
typedef struct meta_file_s {
@ -407,7 +407,7 @@ meta_needed(GNode *gn, const char *dname,
if (verbose)
verbose = DEBUG(META);
/* This may be a phony node which we don't want meta data for... */
/* Skip .meta for .BEGIN, .END, .ERROR etc as well. */
/* Or it may be explicitly flagged as .NOMETA */
@ -458,7 +458,7 @@ meta_needed(GNode *gn, const char *dname,
return TRUE;
}
static FILE *
meta_create(BuildMon *pbm, GNode *gn)
{
@ -549,7 +549,7 @@ meta_create(BuildMon *pbm, GNode *gn)
free(p[i]);
}
return (mf.fp);
return mf.fp;
}
static Boolean
@ -574,7 +574,7 @@ meta_init(void)
{
#ifdef USE_FILEMON
/* this allows makefiles to test if we have filemon support */
Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL, 0);
Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL);
#endif
}
@ -620,7 +620,7 @@ meta_mode_init(const char *make_mode)
* This works be cause :H will generate '.' if there is no /
* and :tA will resolve that to cwd.
*/
Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL, 0);
Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL);
}
if (once)
return;
@ -794,12 +794,12 @@ meta_job_error(Job *job, GNode *gn, int flags, int status)
"(ignored)" : "");
}
if (gn) {
Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL, 0);
Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL);
}
getcwd(cwd, sizeof(cwd));
Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL, 0);
Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);
if (pbm->meta_fname[0]) {
Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL, 0);
Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL);
}
meta_job_finish(job);
}
@ -808,7 +808,7 @@ void
meta_job_output(Job *job, char *cp, const char *nl)
{
BuildMon *pbm;
if (job != NULL) {
pbm = &job->bm;
} else {
@ -904,7 +904,7 @@ meta_finish(void)
* Fetch a full line from fp - growing bufp if needed
* Return length in bufp.
*/
static int
static int
fgetLine(char **bufp, size_t *szp, int o, FILE *fp)
{
char *buf = *bufp;
@ -955,7 +955,7 @@ prefix_match(void *p, void *q)
const char *path = q;
size_t n = strlen(prefix);
return (0 == strncmp(path, prefix, n));
return strncmp(path, prefix, n) == 0;
}
/*
@ -1017,7 +1017,7 @@ meta_ignore(GNode *gn, const char *p)
if (metaIgnorePatterns) {
char *pm;
Var_Set(".p.", p, gn, 0);
Var_Set(".p.", p, gn);
pm = Var_Subst(NULL,
"${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}",
gn, VARF_WANTRES);
@ -1192,7 +1192,7 @@ meta_oodate(GNode *gn, Boolean oodate)
have_filemon = TRUE;
continue;
}
}
}
/* Delimit the record type. */
p = buf;
@ -1242,11 +1242,11 @@ meta_oodate(GNode *gn, Boolean oodate)
if (pid > 0 && pid != lastpid) {
char *ldir;
char *tp;
if (lastpid > 0) {
/* We need to remember these. */
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
Var_Set(ldir_vname, latestdir, VAR_GLOBAL, 0);
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
Var_Set(ldir_vname, latestdir, VAR_GLOBAL);
}
snprintf(lcwd_vname, sizeof(lcwd_vname), LCWD_VNAME_FMT, pid);
snprintf(ldir_vname, sizeof(ldir_vname), LDIR_VNAME_FMT, pid);
@ -1292,9 +1292,9 @@ meta_oodate(GNode *gn, Boolean oodate)
child = atoi(p);
if (child > 0) {
snprintf(cldir, sizeof(cldir), LCWD_VNAME_FMT, child);
Var_Set(cldir, lcwd, VAR_GLOBAL, 0);
Var_Set(cldir, lcwd, VAR_GLOBAL);
snprintf(cldir, sizeof(cldir), LDIR_VNAME_FMT, child);
Var_Set(cldir, latestdir, VAR_GLOBAL, 0);
Var_Set(cldir, latestdir, VAR_GLOBAL);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
@ -1307,10 +1307,10 @@ meta_oodate(GNode *gn, Boolean oodate)
case 'C': /* Chdir */
/* Update lcwd and latest directory. */
strlcpy(latestdir, p, sizeof(latestdir));
strlcpy(latestdir, p, sizeof(latestdir));
strlcpy(lcwd, p, sizeof(lcwd));
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
Var_Set(ldir_vname, lcwd, VAR_GLOBAL, 0);
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
Var_Set(ldir_vname, lcwd, VAR_GLOBAL);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, lcwd);
@ -1387,7 +1387,7 @@ meta_oodate(GNode *gn, Boolean oodate)
/*
* If a file we generated within our bailiwick
* but outside of .OBJDIR is missing,
* we need to do it again.
* we need to do it again.
*/
/* ignore non-absolute paths */
if (*p != '/')
@ -1436,7 +1436,7 @@ meta_oodate(GNode *gn, Boolean oodate)
*/
if (meta_ignore(gn, p))
break;
/*
* The rest of the record is the file name.
* Check if it's not an absolute path.
@ -1637,7 +1637,7 @@ meta_oodate(GNode *gn, Boolean oodate)
* All we can sanely do is set it to .ALLSRC.
*/
Var_Delete(OODATE, gn);
Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0);
Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn);
free(cp);
}
@ -1660,7 +1660,7 @@ meta_compat_start(void)
* We need to re-open filemon for each cmd.
*/
BuildMon *pbm = &Mybm;
if (pbm->mfp != NULL && useFilemon) {
meta_open_filemon(pbm);
} else {

18
meta.h
View File

@ -1,23 +1,23 @@
/* $NetBSD: meta.h,v 1.6 2020/01/19 19:42:32 riastradh Exp $ */
/* $NetBSD: meta.h,v 1.7 2020/07/03 08:13:23 rillig Exp $ */
/*
* Things needed for 'meta' mode.
*/
/*
* Copyright (c) 2009-2010, Juniper Networks, Inc.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -28,7 +28,7 @@
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
typedef struct BuildMon {

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.75 2020/04/25 18:20:57 christos Exp $ */
/* $NetBSD: nonints.h,v 1.78 2020/07/03 07:40:13 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -139,7 +139,7 @@ Lst Parse_MainName(void);
char *str_concat(const char *, const char *, int);
char **brk_string(const char *, int *, Boolean, char **);
char *Str_FindSubstring(const char *, const char *);
int Str_Match(const char *, const char *);
Boolean Str_Match(const char *, const char *);
char *Str_SYSVMatch(const char *, const char *, size_t *, Boolean *);
void Str_SYSVSubst(Buffer *, char *, char *, size_t, Boolean);
@ -185,13 +185,20 @@ void Targ_Propagate(void);
void Targ_Propagate_Wait(void);
/* var.c */
typedef enum {
VARF_UNDEFERR = 1,
VARF_WANTRES = 2,
VARF_ASSIGN = 4
} Varf_Flags;
void Var_Delete(const char *, GNode *);
void Var_Set(const char *, const char *, GNode *, int);
void Var_Set(const char *, const char *, GNode *);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
char *Var_Parse(const char *, GNode *, int, int *, void **);
char *Var_Subst(const char *, const char *, GNode *, int);
char *Var_Parse(const char *, GNode *, Varf_Flags, int *, void **);
char *Var_Subst(const char *, const char *, GNode *, Varf_Flags);
char *Var_GetTail(const char *);
char *Var_GetHead(const char *);
void Var_Init(void);

52
parse.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $ */
/* $NetBSD: parse.c,v 1.236 2020/07/03 08:13:23 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.236 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $");
__RCSID("$NetBSD: parse.c,v 1.236 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -657,14 +657,14 @@ ParseFindKeyword(const char *str)
diff = strcmp(str, parseKeywords[cur].name);
if (diff == 0) {
return (cur);
return cur;
} else if (diff < 0) {
end = cur - 1;
} else {
start = cur + 1;
}
} while (start <= end);
return (-1);
return -1;
}
/*-
@ -889,7 +889,7 @@ ParseLinkSrc(void *pgnp, void *cgnp)
Targ_PrintNode(pgn, 0);
Targ_PrintNode(cgn, 0);
}
return (0);
return 0;
}
/*-
@ -926,7 +926,7 @@ ParseDoOp(void *gnp, void *opp)
!OP_NOP(gn->type) && !OP_NOP(op))
{
Parse_Error(PARSE_FATAL, "Inconsistent operator for %s", gn->name);
return (1);
return 1;
}
if ((op == OP_DOUBLEDEP) && ((gn->type & OP_OPMASK) == OP_DOUBLEDEP)) {
@ -970,7 +970,7 @@ ParseDoOp(void *gnp, void *opp)
gn->type |= op;
}
return (0);
return 0;
}
/*-
@ -1146,7 +1146,7 @@ static int
ParseAddDir(void *path, void *name)
{
(void)Dir_AddDir((Lst) path, (char *)name);
return(0);
return 0;
}
/*-
@ -1605,7 +1605,7 @@ ParseDoDependency(char *line)
break;
#ifdef POSIX
case Posix:
Var_Set("%POSIX", "1003.2", VAR_GLOBAL, 0);
Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
break;
#endif
default:
@ -1980,13 +1980,13 @@ Parse_DoVar(char *line, GNode *ctxt)
* so that it gets substituted!
*/
if (!Var_Exists(line, ctxt))
Var_Set(line, "", ctxt, 0);
Var_Set(line, "", ctxt);
cp = Var_Subst(NULL, cp, ctxt, VARF_WANTRES|VARF_ASSIGN);
oldVars = oldOldVars;
freeCp = TRUE;
Var_Set(line, cp, ctxt, 0);
Var_Set(line, cp, ctxt);
} else if (type == VAR_SHELL) {
char *res;
const char *error;
@ -2002,7 +2002,7 @@ Parse_DoVar(char *line, GNode *ctxt)
}
res = Cmd_Exec(cp, &error);
Var_Set(line, res, ctxt, 0);
Var_Set(line, res, ctxt);
free(res);
if (error)
@ -2011,7 +2011,7 @@ Parse_DoVar(char *line, GNode *ctxt)
/*
* Normal assignment -- just do it.
*/
Var_Set(line, cp, ctxt, 0);
Var_Set(line, cp, ctxt);
}
if (strcmp(line, MAKEOVERRIDES) == 0)
Main_ExportMAKEFLAGS(FALSE); /* re-export MAKEFLAGS */
@ -2115,7 +2115,7 @@ ParseAddCmd(void *gnp, void *cmd)
gn->name);
#endif
}
return(0);
return 0;
}
/*-
@ -2367,9 +2367,9 @@ ParseSetIncludedFile(void)
char *pd, *dp = NULL;
pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp);
Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0);
Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL);
pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp);
Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0);
Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL);
if (DEBUG(PARSE))
fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
@ -2401,16 +2401,16 @@ ParseSetParseFile(const char *filename)
slash = strrchr(filename, '/');
if (slash == NULL) {
Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL, 0);
Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL);
Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL);
dirname= NULL;
} else {
len = slash - filename;
dirname = bmake_malloc(len + 1);
memcpy(dirname, filename, len);
dirname[len] = '\0';
Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);
Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL);
Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL);
}
if (DEBUG(PARSE))
fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n",
@ -2431,7 +2431,7 @@ ParseTrackInput(const char *name)
char *ep;
char *fp = NULL;
size_t name_len = strlen(name);
old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
if (old) {
ep = old + strlen(old) - name_len;
@ -2772,7 +2772,7 @@ ParseEOF(void)
/* Restore the PARSEDIR/PARSEFILE variables */
ParseSetParseFile(curFile->fname);
return (CONTINUE);
return CONTINUE;
}
#define PARSE_RAW 1
@ -3009,7 +3009,7 @@ ParseReadLine(void)
/* Read next line from for-loop buffer */
continue;
}
return (line);
return line;
}
}
@ -3119,7 +3119,7 @@ Parse_File(const char *name, int fd)
strncmp(cp, "warning", 7) == 0) {
if (ParseMessage(cp))
continue;
}
}
}
if (*line == '\t') {
@ -3350,7 +3350,7 @@ Parse_MainName(void)
else
(void)Lst_AtEnd(mainList, mainNode);
Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
return (mainList);
return mainList;
}
/*-

183
str.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.48 2020/06/15 14:46:28 rillig Exp $ */
/* $NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: str.c,v 1.48 2020/06/15 14:46:28 rillig Exp $";
static char rcsid[] = "$NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
__RCSID("$NetBSD: str.c,v 1.48 2020/06/15 14:46:28 rillig Exp $");
__RCSID("$NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -320,123 +320,110 @@ Str_FindSubstring(const char *string, const char *substring)
}
/*
* Str_Match --
*
* See if a particular string matches a particular pattern.
*
* Results: Non-zero is returned if string matches pattern, 0 otherwise. The
* matching operation permits the following special characters in the
* pattern: *?\[] (see the man page for details on what these mean).
* Str_Match -- Test if a string matches a pattern like "*.[ch]".
*
* XXX this function does not detect or report malformed patterns.
*
* Results:
* Non-zero is returned if string matches the pattern, 0 otherwise. The
* matching operation permits the following special characters in the
* pattern: *?\[] (as in fnmatch(3)).
*
* Side effects: None.
*/
int
Str_Match(const char *string, const char *pattern)
Boolean
Str_Match(const char *str, const char *pat)
{
char c2;
for (;;) {
/*
* See if we're at the end of both the pattern and the
* string. If, we succeeded. If we're at the end of the
* pattern but not at the end of the string, we failed.
*/
if (*pattern == 0)
return !*string;
if (*string == 0 && *pattern != '*')
return 0;
/*
* Check for a "*" as the next pattern character. It matches
* any substring. We handle this by calling ourselves
* recursively for each postfix of string, until either we
* match or we reach the end of the string.
*/
if (*pattern == '*') {
pattern++;
while (*pattern == '*')
pattern++;
if (*pattern == 0)
return 1;
while (*string != 0) {
if (Str_Match(string, pattern))
return 1;
++string;
}
return 0;
}
/*
* Check for a "?" as the next pattern character. It matches
* any single character.
*/
if (*pattern == '?')
goto thisCharOK;
/*
* Check for a "[" as the next pattern character. It is
* followed by a list of characters that are acceptable, or
* by a range (two characters separated by "-").
*/
if (*pattern == '[') {
int nomatch;
if (*pat == 0)
return *str == 0;
if (*str == 0 && *pat != '*')
return FALSE;
++pattern;
if (*pattern == '^') {
++pattern;
nomatch = 1;
} else
nomatch = 0;
for (;;) {
if ((*pattern == ']') || (*pattern == 0)) {
if (nomatch)
break;
return 0;
}
if (*pattern == *string)
break;
if (pattern[1] == '-') {
c2 = pattern[2];
if (c2 == 0)
return nomatch;
if ((*pattern <= *string) &&
(c2 >= *string))
break;
if ((*pattern >= *string) &&
(c2 <= *string))
break;
pattern += 2;
}
++pattern;
/*
* A '*' in the pattern matches any substring. We handle this
* by calling ourselves for each suffix of the string.
*/
if (*pat == '*') {
pat++;
while (*pat == '*')
pat++;
if (*pat == 0)
return TRUE;
while (*str != 0) {
if (Str_Match(str, pat))
return TRUE;
str++;
}
if (nomatch && (*pattern != ']') && (*pattern != 0))
return 0;
while ((*pattern != ']') && (*pattern != 0))
++pattern;
if (*pattern == 0)
--pattern;
return FALSE;
}
/* A '?' in the pattern matches any single character. */
if (*pat == '?')
goto thisCharOK;
/*
* A '[' in the pattern matches a character from a list.
* The '[' is followed by the list of acceptable characters,
* or by ranges (two characters separated by '-'). In these
* character lists, the backslash is an ordinary character.
*/
if (*pat == '[') {
Boolean neg = pat[1] == '^';
pat += 1 + neg;
for (;;) {
if (*pat == ']' || *pat == 0) {
if (neg)
break;
return FALSE;
}
if (*pat == *str)
break;
if (pat[1] == '-') {
if (pat[2] == 0)
return neg;
if (*pat <= *str && pat[2] >= *str)
break;
if (*pat >= *str && pat[2] <= *str)
break;
pat += 2;
}
pat++;
}
if (neg && *pat != ']' && *pat != 0)
return FALSE;
while (*pat != ']' && *pat != 0)
pat++;
if (*pat == 0)
pat--;
goto thisCharOK;
}
/*
* If the next pattern character is a backslash, just strip it
* off so we do exact matching on the character that follows.
* A backslash in the pattern matches the character following
* it exactly.
*/
if (*pattern == '\\') {
++pattern;
if (*pattern == 0)
return 0;
if (*pat == '\\') {
pat++;
if (*pat == 0)
return FALSE;
}
/*
* There's no special character. Just make sure that the
* next characters of each string match.
*/
if (*pattern != *string)
return 0;
thisCharOK: ++pattern;
++string;
if (*pat != *str)
return FALSE;
thisCharOK:
pat++;
str++;
}
}
/*-
*-----------------------------------------------------------------------
* Str_SYSVMatch --

76
suff.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $ */
/* $NetBSD: suff.c,v 1.88 2020/07/03 08:02:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.88 2020/07/03 08:02:55 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
__RCSID("$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $");
__RCSID("$NetBSD: suff.c,v 1.88 2020/07/03 08:02:55 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -266,7 +266,7 @@ SuffStrIsPrefix(const char *pref, const char *str)
str++;
}
return (*pref ? NULL : str);
return *pref ? NULL : str;
}
/*-
@ -304,7 +304,7 @@ SuffSuffIsSuffix(const Suff *s, const SuffixCmpData *sd)
p2--;
}
return (p1 == s->name - 1 ? p2 : NULL);
return p1 == s->name - 1 ? p2 : NULL;
}
/*-
@ -324,7 +324,7 @@ SuffSuffIsSuffix(const Suff *s, const SuffixCmpData *sd)
static int
SuffSuffIsSuffixP(const void *s, const void *sd)
{
return(!SuffSuffIsSuffix(s, sd));
return !SuffSuffIsSuffix(s, sd);
}
/*-
@ -347,7 +347,7 @@ SuffSuffIsSuffixP(const void *s, const void *sd)
static int
SuffSuffHasNameP(const void *s, const void *sname)
{
return (strcmp(sname, ((const Suff *)s)->name));
return strcmp(sname, ((const Suff *)s)->name);
}
/*-
@ -394,7 +394,7 @@ SuffSuffIsPrefix(const void *s, const void *str)
static int
SuffGNHasNameP(const void *gn, const void *name)
{
return (strcmp(name, ((const GNode *)gn)->name));
return strcmp(name, ((const GNode *)gn)->name);
}
/*********** Maintenance Functions ************/
@ -632,9 +632,9 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
*/
*srcPtr = single;
*targPtr = suffNull;
return(TRUE);
return TRUE;
}
return (FALSE);
return FALSE;
}
src = (Suff *)Lst_Datum(srcLn);
str2 = str + src->nameLen;
@ -646,7 +646,7 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
if (targLn != NULL) {
*srcPtr = src;
*targPtr = (Suff *)Lst_Datum(targLn);
return (TRUE);
return TRUE;
}
}
}
@ -674,7 +674,7 @@ Suff_IsTransform(char *str)
{
Suff *src, *targ;
return (SuffParseTransform(str, &src, &targ));
return SuffParseTransform(str, &src, &targ);
}
/*-
@ -738,7 +738,7 @@ Suff_AddTransform(char *line)
SuffInsert(t->children, s);
SuffInsert(s->parents, t);
return (gn);
return gn;
}
/*-
@ -860,7 +860,7 @@ SuffRebuildGraph(void *transformp, void *sp)
s2 = (Suff *)Lst_Datum(ln);
SuffInsert(s2->children, s);
SuffInsert(s->parents, s2);
return(0);
return 0;
}
}
@ -889,7 +889,7 @@ SuffRebuildGraph(void *transformp, void *sp)
SuffInsert(s2->parents, s);
}
}
return(0);
return 0;
}
/*-
@ -1035,7 +1035,7 @@ Suff_GetPath(char *sname)
return NULL;
} else {
s = (Suff *)Lst_Datum(ln);
return (s->searchPath);
return s->searchPath;
}
}
@ -1093,9 +1093,9 @@ Suff_DoPaths(void)
}
}
Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL, 0);
Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
free(ptr);
Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL, 0);
Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
free(ptr);
Lst_Destroy(inIncludes, Dir_Destroy);
@ -1239,7 +1239,7 @@ SuffAddSrc(void *sp, void *lsp)
fprintf(debug_file, "\n");
#endif
return(0);
return 0;
}
/*-
@ -1399,7 +1399,7 @@ SuffFindThem(Lst srcs, Lst slst)
if (DEBUG(SUFF) && rs) {
fprintf(debug_file, "got it\n");
}
return (rs);
return rs;
}
/*-
@ -1505,7 +1505,7 @@ SuffFindCmds(Src *targ, Lst slst)
if (DEBUG(SUFF)) {
fprintf(debug_file, "\tusing existing source %s\n", s->name);
}
return (ret);
return ret;
}
/*-
@ -1831,7 +1831,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* called to link an OP_MEMBER and OP_ARCHV node), so return
* FALSE.
*/
return(FALSE);
return FALSE;
}
gn = (GNode *)Lst_Datum(ln);
@ -1864,7 +1864,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
*/
(void)Lst_AtEnd(sGn->iParents, tGn);
return(TRUE);
return TRUE;
}
@ -1941,7 +1941,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
*/
for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) {
char *p1;
Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn, 0);
Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn);
free(p1);
}
@ -1961,13 +1961,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
/*
* Set the other two local variables required for this target.
*/
Var_Set(MEMBER, name, gn, 0);
Var_Set(ARCHIVE, gn->name, gn, 0);
Var_Set(MEMBER, name, gn);
Var_Set(ARCHIVE, gn->name, gn);
/*
* Set $@ for compatibility with other makes
*/
Var_Set(TARGET, gn->name, gn, 0);
Var_Set(TARGET, gn->name, gn);
/*
* Now we've got the important local variables set, expand any sources
@ -2213,10 +2213,10 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
}
}
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
pref = (targ != NULL) ? targ->pref : gn->name;
Var_Set(PREFIX, pref, gn, 0);
Var_Set(PREFIX, pref, gn);
/*
* Now we've got the important local variables set, expand any sources
@ -2246,7 +2246,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
targ->suff->searchPath));
if (gn->path != NULL) {
char *ptr;
Var_Set(TARGET, gn->path, gn, 0);
Var_Set(TARGET, gn->path, gn);
if (targ != NULL) {
/*
@ -2269,7 +2269,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
else
ptr = gn->path;
Var_Set(PREFIX, ptr, gn, 0);
Var_Set(PREFIX, ptr, gn);
gn->path[savep] = savec;
} else {
@ -2286,7 +2286,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
else
ptr = gn->path;
Var_Set(PREFIX, ptr, gn, 0);
Var_Set(PREFIX, ptr, gn);
}
}
}
@ -2373,9 +2373,9 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
*/
targ->node->type |= OP_DEPS_FOUND;
Var_Set(PREFIX, targ->pref, targ->node, 0);
Var_Set(PREFIX, targ->pref, targ->node);
Var_Set(TARGET, targ->node->name, targ->node, 0);
Var_Set(TARGET, targ->node->name, targ->node);
}
}
@ -2458,8 +2458,8 @@ SuffFindDeps(GNode *gn, Lst slst)
/*
* Make sure we have these set, may get revised below.
*/
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Var_Set(PREFIX, gn->name, gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set(PREFIX, gn->name, gn);
if (DEBUG(SUFF)) {
fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
@ -2488,14 +2488,14 @@ SuffFindDeps(GNode *gn, Lst slst)
Arch_FindLib(gn, s->searchPath);
} else {
gn->suffix = NULL;
Var_Set(TARGET, gn->name, gn, 0);
Var_Set(TARGET, gn->name, gn);
}
/*
* Because a library (-lfoo) target doesn't follow the standard
* filesystem conventions, we don't set the regular variables for
* the thing. .PREFIX is simply made empty...
*/
Var_Set(PREFIX, "", gn, 0);
Var_Set(PREFIX, "", gn);
} else {
SuffFindNormalDeps(gn, slst);
}

32
targ.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $ */
/* $NetBSD: targ.c,v 1.63 2020/07/03 08:02:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.63 2020/07/03 08:02:55 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $");
__RCSID("$NetBSD: targ.c,v 1.63 2020/07/03 08:02:55 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -269,7 +269,7 @@ Targ_NewGN(const char *name)
Lst_AtEnd(allGNs, gn);
#endif
return (gn);
return gn;
}
#ifdef CLEANUP
@ -389,7 +389,7 @@ Targ_FindList(Lst names, int flags)
nodes = Lst_Init(FALSE);
if (Lst_Open(names) == FAILURE) {
return (nodes);
return nodes;
}
while ((ln = Lst_Next(names)) != NULL) {
name = (char *)Lst_Datum(ln);
@ -406,7 +406,7 @@ Targ_FindList(Lst names, int flags)
}
}
Lst_Close(names);
return (nodes);
return nodes;
}
/*-
@ -428,9 +428,9 @@ Boolean
Targ_Ignore(GNode *gn)
{
if (ignoreErrors || gn->type & OP_IGNORE) {
return (TRUE);
return TRUE;
} else {
return (FALSE);
return FALSE;
}
}
@ -453,9 +453,9 @@ Boolean
Targ_Silent(GNode *gn)
{
if (beSilent || gn->type & OP_SILENT) {
return (TRUE);
return TRUE;
} else {
return (FALSE);
return FALSE;
}
}
@ -478,9 +478,9 @@ Boolean
Targ_Precious(GNode *gn)
{
if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
return (TRUE);
return TRUE;
} else {
return (FALSE);
return FALSE;
}
}
@ -549,7 +549,7 @@ Targ_FmtTime(time_t tm)
parts = localtime(&tm);
(void)strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
return(buf);
return buf;
}
/*-
@ -698,7 +698,7 @@ Targ_PrintNode(void *gnp, void *passp)
Lst_ForEach(gn->cohorts, Targ_PrintNode, &pass);
}
}
return (0);
return 0;
}
/*-
@ -794,7 +794,7 @@ TargPropagateNode(void *gnp, void *junk MAKE_ATTR_UNUSED)
if (gn->type & OP_DOUBLEDEP)
Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
return (0);
return 0;
}
/*-
@ -822,7 +822,7 @@ TargPropagateCohort(void *cgnp, void *pgnp)
GNode *pgn = (GNode *)pgnp;
cgn->type |= pgn->type & ~OP_OPMASK;
return (0);
return 0;
}
/*-

View File

@ -1,4 +1,4 @@
/* $NetBSD: trace.c,v 1.11 2008/12/28 18:31:51 christos Exp $ */
/* $NetBSD: trace.c,v 1.12 2020/07/03 08:13:23 rillig Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -31,11 +31,11 @@
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: trace.c,v 1.11 2008/12/28 18:31:51 christos Exp $";
static char rcsid[] = "$NetBSD: trace.c,v 1.12 2020/07/03 08:13:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trace.c,v 1.11 2008/12/28 18:31:51 christos Exp $");
__RCSID("$NetBSD: trace.c,v 1.12 2020/07/03 08:13:23 rillig Exp $");
#endif /* not lint */
#endif
@ -90,7 +90,7 @@ void
Trace_Log(TrEvent event, Job *job)
{
struct timeval rightnow;
if (trfile == NULL)
return;

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.55 2020/06/29 14:47:56 sjg Exp $
# $Id: Makefile,v 1.58 2020/07/04 22:33:00 sjg Exp $
#
# $NetBSD: Makefile,v 1.59 2020/06/28 09:42:40 rillig Exp $
#
@ -105,6 +105,9 @@ LANG= C
SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
-e '/command/s,No such.*,not found,'
# the detailed error message can vary across systems
SED_CMDS.modmisc = -e 's,\(substitution error:\).*,\1 details omitted,'
# the tests are actually done with sub-makes.
.SUFFIXES: .mk .rawout .out
.mk.rawout:

View File

@ -1,6 +1,9 @@
expected and
expected and exists
expected and empty
expected U23 condition
expected VAR23
expected M pattern
expected or
expected or exists
expected or empty

View File

@ -1,4 +1,4 @@
# $NetBSD: cond-short.mk,v 1.2 2020/06/28 11:06:26 rillig Exp $
# $NetBSD: cond-short.mk,v 1.6 2020/07/02 16:37:56 rillig Exp $
#
# Demonstrates that in conditions, the right-hand side of an && or ||
# is only evaluated if it can actually influence the result.
@ -27,6 +27,45 @@
.if 1 && empty(${echo "expected and empty" 1>&2 :L:sh})
.endif
# "VAR U11" is not evaluated; it was evaluated before 2020-07-02.
# The whole !empty condition is only parsed and then discarded.
VAR= ${VAR${:U11${echo "unexpected VAR U11" 1>&2 :L:sh}}}
VAR13= ${VAR${:U12${echo "unexpected VAR13" 1>&2 :L:sh}}}
.if 0 && !empty(VAR${:U13${echo "unexpected U13 condition" 1>&2 :L:sh}})
.endif
VAR= ${VAR${:U21${echo "unexpected VAR U21" 1>&2 :L:sh}}}
VAR23= ${VAR${:U22${echo "expected VAR23" 1>&2 :L:sh}}}
.if 1 && !empty(VAR${:U23${echo "expected U23 condition" 1>&2 :L:sh}})
.endif
VAR= # empty again, for the following tests
# The :M modifier is only parsed, not evaluated.
# Before 2020-07-02, it was wrongly evaluated.
.if 0 && !empty(VAR:M${:U${echo "unexpected M pattern" 1>&2 :L:sh}})
.endif
.if 1 && !empty(VAR:M${:U${echo "expected M pattern" 1>&2 :L:sh}})
.endif
.if 0 && !empty(VAR:S,from,${:U${echo "unexpected S modifier" 1>&2 :L:sh}},)
.endif
.if 0 && !empty(VAR:C,from,${:U${echo "unexpected C modifier" 1>&2 :L:sh}},)
.endif
.if 0 && !empty("" == "" :? ${:U${echo "unexpected ? modifier" 1>&2 :L:sh}} :)
.endif
.if 0 && !empty(VAR:old=${:U${echo "unexpected = modifier" 1>&2 :L:sh}})
.endif
.if 0 && !empty(1 2 3:L:@var@${:U${echo "unexpected @ modifier" 1>&2 :L:sh}}@)
.endif
.if 0 && !empty(:U${:!echo "unexpected exclam modifier" 1>&2 !})
.endif
# The || operator.
.if 1 || ${echo "unexpected or" 1>&2 :L:sh}

View File

@ -7,4 +7,29 @@ path_/usr/xbin=/opt/xbin/
paths=/bin /tmp / /no/such/dir /opt/xbin
PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
The answer is 42
dirname of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'a/b . . a.b . . . . .'
basename of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'c def a.b.c c a a.a .gitignore a a.a'
suffix of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'c b/c a gitignore a'
root of 'a/b/c def a.b.c a.b/c a a.a .gitignore a a.a' is 'a/b/c def a.b a a a a a'
S:
C:
@:
S:empty
C:empty
@:
:a b b c:
:a b b c:
: b c:
:a c:
:x__ 3 x__ 3:
:a b b c:
:a b b c:
: b c:
make: RE substitution error: details omitted
make: Unclosed substitution for (, missing)
:C,word,____,:Q}:
:a c:
:x__ 3 x__ 3:
:+one+ +two+ +three+:
mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
exit status 0

View File

@ -1,4 +1,4 @@
# $Id: modmisc.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
# $Id: modmisc.mk,v 1.1.1.2 2020/07/04 17:52:46 sjg Exp $
#
# miscellaneous modifier tests
@ -15,7 +15,8 @@ MOD_HOMES=S,/home/,/homes/,
MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
MOD_SEP=S,:, ,g
all: modvar modvarloop modsysv
all: modvar modvarloop modsysv mod-HTE emptyvar undefvar
all: mod-S mod-C mod-at-varname mod-at-resolve
modsysv:
@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@ -36,3 +37,59 @@ modvarloop:
@echo "path_/usr/xbin=${path_/usr/xbin}"
@echo "paths=${paths}"
@echo "PATHS=${paths:tu}"
PATHNAMES= a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
mod-HTE:
@echo "dirname of '"${PATHNAMES:Q}"' is '"${PATHNAMES:H:Q}"'"
@echo "basename of '"${PATHNAMES:Q}"' is '"${PATHNAMES:T:Q}"'"
@echo "suffix of '"${PATHNAMES:Q}"' is '"${PATHNAMES:E:Q}"'"
@echo "root of '"${PATHNAMES:Q}"' is '"${PATHNAMES:R:Q}"'"
# When a modifier is applied to the "" variable, the result is discarded.
emptyvar:
@echo S:${:S,^$,empty,}
@echo C:${:C,^$,empty,}
@echo @:${:@var@${var}@}
# The :U modifier turns even the "" variable into something that has a value.
# The resulting variable is empty, but is still considered to contain a
# single empty word. This word can be accessed by the :S and :C modifiers,
# but not by the :@ modifier since it explicitly skips empty words.
undefvar:
@echo S:${:U:S,^$,empty,}
@echo C:${:U:C,^$,empty,}
@echo @:${:U:@var@empty@}
mod-S:
@echo :${:Ua b b c:S,a b,,:Q}:
@echo :${:Ua b b c:S,a b,,1:Q}:
@echo :${:Ua b b c:S,a b,,W:Q}:
@echo :${:Ua b b c:S,b,,g:Q}:
@echo :${:U1 2 3 1 2 3:S,1 2,___,Wg:S,_,x,:Q}:
mod-C:
@echo :${:Ua b b c:C,a b,,:Q}:
@echo :${:Ua b b c:C,a b,,1:Q}:
@echo :${:Ua b b c:C,a b,,W:Q}:
@echo :${:Uword1 word2:C,****,____,g:C,word,____,:Q}:
@echo :${:Ua b b c:C,b,,g:Q}:
@echo :${:U1 2 3 1 2 3:C,1 2,___,Wg:C,_,x,:Q}:
# In the :@ modifier, the name of the loop variable can even be generated
# dynamically. There's no practical use-case for this, and hopefully nobody
# will ever depend on this, but technically it's possible.
mod-at-varname:
@echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
# The :@ modifier resolves the variables a little more often than expected.
# In particular, it resolves _all_ variables from the context, and not only
# the loop variable (in this case v).
#
# The d means direct reference, the i means indirect reference.
RESOLVE= ${RES1} $${RES1}
RES1= 1d${RES2} 1i$${RES2}
RES2= 2d${RES3} 2i$${RES3}
RES3= 3
mod-at-resolve:
@echo $@:${RESOLVE:@v@w${v}w@:Q}:

View File

@ -12,4 +12,5 @@ asam.c.c
asam.c
a.c.c
ax:Q b c d eb
exit status 0

View File

@ -1,4 +1,4 @@
# $Id: sysv.mk,v 1.4 2020/05/07 01:17:51 sjg Exp $
# $Id: sysv.mk,v 1.5 2020/07/04 18:16:55 sjg Exp $
FOO ?=
FOOBAR = ${FOO:=bar}
@ -11,7 +11,7 @@ FUN = ${B}${S}fun
SUN = the Sun
# we expect nothing when FOO is empty
all: foo fun sam bla
all: foo fun sam bla words
foo:
@echo FOOBAR = ${FOOBAR}
@ -41,3 +41,8 @@ BLA=
bla:
@echo $(BLA:%=foo/%x)
# The :Q looks like a modifier but isn't.
# It is part of the replacement string.
words:
@echo a${a b c d e:L:%a=x:Q}b

View File

@ -22,4 +22,5 @@ date=20160401
Version=123.456.789 == 123456789
Literal=3.4.5 == 3004005
We have target specific vars
MAN= make.1
exit status 0

View File

@ -1,9 +1,9 @@
# $Id: varmisc.mk,v 1.9 2017/02/01 18:44:54 sjg Exp $
# $Id: varmisc.mk,v 1.11 2020/07/02 15:43:43 sjg Exp $
#
# Miscellaneous variable tests.
all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
strftime cmpv
strftime cmpv manok
unmatched_var_paren:
@echo ${foo::=foo-text}
@ -60,3 +60,25 @@ cmpv:
@echo Version=${Version} == ${Version:${M_cmpv}}
@echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}}
@echo We have ${${.TARGET:T}.only}
# catch misshandling of nested vars in .for loop
MAN=
MAN1= make.1
.for s in 1 2
.if defined(MAN$s) && !empty(MAN$s)
MAN+= ${MAN$s}
.endif
.endfor
manok:
@echo MAN=${MAN}
# This is an expanded variant of the above .for loop.
# Between 2020-08-28 and 2020-07-02 this paragraph generated a wrong
# error message "Variable VARNAME is recursive".
# When evaluating the !empty expression, the ${:U1} was not expanded and
# thus resulted in the seeming definition VARNAME=${VARNAME}, which is
# obviously recursive.
VARNAME= ${VARNAME${:U1}}
.if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
.endif

18
util.c
View File

@ -1,9 +1,9 @@
/* $NetBSD: util.c,v 1.55 2020/01/07 21:24:16 rillig Exp $ */
/* $NetBSD: util.c,v 1.57 2020/07/03 08:13:23 rillig Exp $ */
/*
* Missing stuff from OS's
*
* $Id: util.c,v 1.34 2020/01/22 01:19:25 sjg Exp $
* $Id: util.c,v 1.35 2020/07/04 18:16:55 sjg Exp $
*/
#if defined(__MINT__) || defined(__linux__)
#include <signal.h>
@ -12,10 +12,10 @@
#include "make.h"
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: util.c,v 1.55 2020/01/07 21:24:16 rillig Exp $";
static char rcsid[] = "$NetBSD: util.c,v 1.57 2020/07/03 08:13:23 rillig Exp $";
#else
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.55 2020/01/07 21:24:16 rillig Exp $");
__RCSID("$NetBSD: util.c,v 1.57 2020/07/03 08:13:23 rillig Exp $");
#endif
#endif
@ -68,7 +68,7 @@ getenv(const char *name)
{
int offset;
return(findenv(name, &offset));
return findenv(name, &offset);
}
int
@ -173,7 +173,7 @@ strrcpy(char *ptr, char *str)
while (len)
*--ptr = str[--len];
return (ptr);
return ptr;
} /* end strrcpy */
@ -276,7 +276,7 @@ getwd(char *pathname)
if (st_cur.st_ino == st_root.st_ino &&
DEV_DEV_COMPARE(st_cur.st_dev, st_root.st_dev)) {
(void)strcpy(pathname, *pathptr != '/' ? "/" : pathptr);
return (pathname);
return pathname;
}
/* open the parent directory */
@ -399,7 +399,7 @@ vsnprintf(char *s, size_t n, const char *fmt, va_list args)
putc('\0', &fakebuf);
if (fakebuf._cnt<0)
fakebuf._cnt = 0;
return (n-fakebuf._cnt-1);
return n-fakebuf._cnt-1;
#else
#ifndef _PATH_DEVNULL
# define _PATH_DEVNULL "/dev/null"
@ -442,7 +442,7 @@ size_t
strftime(char *buf, size_t len, const char *fmt, const struct tm *tm)
{
static char months[][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

3587
var.c

File diff suppressed because it is too large Load Diff