Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
/* $NetBSD: for.c,v 1.182 2024/06/07 18:57:30 rillig Exp $ */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* 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.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, 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.
|
|
|
|
*/
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
/*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Handling of .for/.endfor loops in a makefile.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2021-01-14 01:24:34 +00:00
|
|
|
* For loops have the form:
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2021-01-14 01:24:34 +00:00
|
|
|
* .for <varname...> in <value...>
|
|
|
|
* # the body
|
|
|
|
* .endfor
|
2020-11-07 19:39:21 +00:00
|
|
|
*
|
2021-01-14 01:24:34 +00:00
|
|
|
* When a .for line is parsed, the following lines are copied to the body of
|
|
|
|
* the .for loop, until the corresponding .endfor line is reached. In this
|
|
|
|
* phase, the body is not yet evaluated. This also applies to any nested
|
|
|
|
* .for loops.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2021-01-14 01:24:34 +00:00
|
|
|
* After reaching the .endfor, the values from the .for line are grouped
|
|
|
|
* according to the number of variables. For each such group, the unexpanded
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
* body is scanned for expressions, and those that match the
|
2021-12-18 07:27:22 +00:00
|
|
|
* variable names are replaced with expressions of the form ${:U...}. After
|
|
|
|
* that, the body is treated like a file from an .include directive.
|
2020-11-07 19:39:21 +00:00
|
|
|
*
|
|
|
|
* Interface:
|
|
|
|
* For_Eval Evaluate the loop in the passed line.
|
|
|
|
*
|
|
|
|
* For_Run Run accumulated loop
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
#include "make.h"
|
|
|
|
|
|
|
|
/* "@(#)for.c 8.1 (Berkeley) 6/6/93" */
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
MAKE_RCSID("$NetBSD: for.c,v 1.182 2024/06/07 18:57:30 rillig Exp $");
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
typedef struct ForLoop {
|
2022-02-05 20:03:50 +00:00
|
|
|
Vector /* of 'char *' */ vars; /* Iteration variables */
|
2021-12-18 07:27:22 +00:00
|
|
|
SubstringWords items; /* Substitution items */
|
2022-02-05 20:03:50 +00:00
|
|
|
Buffer body; /* Unexpanded body of the loop */
|
2021-12-18 07:27:22 +00:00
|
|
|
unsigned int nextItem; /* Where to continue iterating */
|
2021-02-11 01:51:11 +00:00
|
|
|
} ForLoop;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
static ForLoop *accumFor; /* Loop being accumulated */
|
2021-02-11 01:51:11 +00:00
|
|
|
|
|
|
|
|
2023-05-13 17:03:50 +00:00
|
|
|
/* See LK_FOR_BODY. */
|
|
|
|
static void
|
|
|
|
skip_whitespace_or_line_continuation(const char **pp)
|
|
|
|
{
|
|
|
|
const char *p = *pp;
|
|
|
|
for (;;) {
|
|
|
|
if (ch_isspace(*p))
|
|
|
|
p++;
|
|
|
|
else if (p[0] == '\\' && p[1] == '\n')
|
|
|
|
p += 2;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*pp = p;
|
|
|
|
}
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
static ForLoop *
|
|
|
|
ForLoop_New(void)
|
2020-11-07 19:39:21 +00:00
|
|
|
{
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop *f = bmake_malloc(sizeof *f);
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
Vector_Init(&f->vars, sizeof(char *));
|
2021-12-18 07:27:22 +00:00
|
|
|
SubstringWords_Init(&f->items);
|
2022-02-05 20:03:50 +00:00
|
|
|
Buf_Init(&f->body);
|
2021-12-18 07:27:22 +00:00
|
|
|
f->nextItem = 0;
|
2021-02-11 01:51:11 +00:00
|
|
|
|
|
|
|
return f;
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
void
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop_Free(ForLoop *f)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
while (f->vars.len > 0)
|
|
|
|
free(*(char **)Vector_Pop(&f->vars));
|
2021-01-14 01:24:34 +00:00
|
|
|
Vector_Done(&f->vars);
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
SubstringWords_Free(f->items);
|
2022-02-05 20:03:50 +00:00
|
|
|
Buf_Done(&f->body);
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
free(f);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
char *
|
2023-06-27 20:29:43 +00:00
|
|
|
ForLoop_Details(const ForLoop *f)
|
2021-02-11 01:51:11 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
size_t i, n;
|
|
|
|
const char **vars;
|
|
|
|
const Substring *items;
|
|
|
|
Buffer buf;
|
|
|
|
|
|
|
|
n = f->vars.len;
|
|
|
|
vars = f->vars.items;
|
|
|
|
assert(f->nextItem >= n);
|
|
|
|
items = f->items.words + f->nextItem - n;
|
|
|
|
|
|
|
|
Buf_Init(&buf);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if (i > 0)
|
|
|
|
Buf_AddStr(&buf, ", ");
|
|
|
|
Buf_AddStr(&buf, vars[i]);
|
|
|
|
Buf_AddStr(&buf, " = ");
|
2023-06-27 20:29:43 +00:00
|
|
|
Buf_AddRange(&buf, items[i].start, items[i].end);
|
2022-02-05 20:03:50 +00:00
|
|
|
}
|
|
|
|
return Buf_DoneData(&buf);
|
2021-02-11 01:51:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2023-05-13 17:03:50 +00:00
|
|
|
IsValidInVarname(char c)
|
|
|
|
{
|
|
|
|
return c != '$' && c != ':' && c != '\\' &&
|
|
|
|
c != '(' && c != '{' && c != ')' && c != '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop_ParseVarnames(ForLoop *f, const char **pp)
|
|
|
|
{
|
|
|
|
const char *p = *pp;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
cpp_skip_whitespace(&p);
|
|
|
|
if (*p == '\0') {
|
|
|
|
Parse_Error(PARSE_FATAL, "missing `in' in for");
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
while (f->vars.len > 0)
|
|
|
|
free(*(char **)Vector_Pop(&f->vars));
|
2023-05-13 17:03:50 +00:00
|
|
|
return;
|
2021-02-11 01:51:11 +00:00
|
|
|
}
|
|
|
|
|
2023-05-13 17:03:50 +00:00
|
|
|
for (len = 0; p[len] != '\0' && !ch_isspace(p[len]); len++) {
|
|
|
|
if (!IsValidInVarname(p[len])) {
|
|
|
|
Parse_Error(PARSE_FATAL,
|
|
|
|
"invalid character '%c' "
|
|
|
|
"in .for loop variable name",
|
|
|
|
p[len]);
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
while (f->vars.len > 0)
|
|
|
|
free(*(char **)Vector_Pop(&f->vars));
|
2023-05-13 17:03:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-02-11 01:51:11 +00:00
|
|
|
|
|
|
|
if (len == 2 && p[0] == 'i' && p[1] == 'n') {
|
|
|
|
p += 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
*(char **)Vector_Push(&f->vars) = bmake_strldup(p, len);
|
2021-02-11 01:51:11 +00:00
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f->vars.len == 0) {
|
|
|
|
Parse_Error(PARSE_FATAL, "no iteration variables in for");
|
2023-05-13 17:03:50 +00:00
|
|
|
return;
|
2021-02-11 01:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*pp = p;
|
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop_ParseItems(ForLoop *f, const char *p)
|
|
|
|
{
|
|
|
|
char *items;
|
|
|
|
|
|
|
|
cpp_skip_whitespace(&p);
|
|
|
|
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
items = Var_Subst(p, SCOPE_GLOBAL, VARE_EVAL);
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
/* TODO: handle errors */
|
2021-02-11 01:51:11 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
f->items = Substring_Words(items, false);
|
2021-02-11 01:51:11 +00:00
|
|
|
free(items);
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (f->items.len == 1 && Substring_IsEmpty(f->items.words[0]))
|
2022-02-05 20:03:50 +00:00
|
|
|
f->items.len = 0; /* .for var in ${:U} */
|
2021-02-11 01:51:11 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
if (f->items.len % f->vars.len != 0) {
|
2021-02-11 01:51:11 +00:00
|
|
|
Parse_Error(PARSE_FATAL,
|
|
|
|
"Wrong number of words (%u) in .for "
|
|
|
|
"substitution list with %u variables",
|
|
|
|
(unsigned)f->items.len, (unsigned)f->vars.len);
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-02-11 01:51:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2021-02-11 01:51:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2020-11-07 19:39:21 +00:00
|
|
|
IsFor(const char *p)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
return p[0] == 'f' && p[1] == 'o' && p[2] == 'r' && ch_isspace(p[3]);
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2020-11-07 19:39:21 +00:00
|
|
|
IsEndfor(const char *p)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
return p[0] == 'e' && strncmp(p, "endfor", 6) == 0 &&
|
|
|
|
(p[6] == '\0' || ch_isspace(p[6]));
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Evaluate the for loop in the passed line. The line looks like this:
|
2020-11-07 19:39:21 +00:00
|
|
|
* .for <varname...> in <value...>
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* Results:
|
2022-02-05 20:03:50 +00:00
|
|
|
* 0 not a .for directive
|
|
|
|
* 1 found a .for directive
|
|
|
|
* -1 erroneous .for directive
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
|
|
|
int
|
2020-11-07 19:39:21 +00:00
|
|
|
For_Eval(const char *line)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
const char *p;
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop *f;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
p = line + 1; /* skip the '.' */
|
2023-05-13 17:03:50 +00:00
|
|
|
skip_whitespace_or_line_continuation(&p);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
if (IsFor(p)) {
|
|
|
|
p += 3;
|
|
|
|
|
|
|
|
f = ForLoop_New();
|
2023-05-13 17:03:50 +00:00
|
|
|
ForLoop_ParseVarnames(f, &p);
|
|
|
|
if (f->vars.len > 0 && !ForLoop_ParseItems(f, p))
|
2022-02-05 20:03:50 +00:00
|
|
|
f->items.len = 0; /* don't iterate */
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
accumFor = f;
|
|
|
|
return 1;
|
|
|
|
} else if (IsEndfor(p)) {
|
|
|
|
Parse_Error(PARSE_FATAL, "for-less endfor");
|
2021-01-14 01:24:34 +00:00
|
|
|
return -1;
|
2022-02-05 20:03:50 +00:00
|
|
|
} else
|
|
|
|
return 0;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-02-11 01:51:11 +00:00
|
|
|
* Add another line to the .for loop that is being built up.
|
2021-06-25 18:16:24 +00:00
|
|
|
* Returns false when the matching .endfor is reached.
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
bool
|
2022-02-05 20:03:50 +00:00
|
|
|
For_Accum(const char *line, int *forLevel)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-02-11 01:51:11 +00:00
|
|
|
const char *p = line;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
if (*p == '.') {
|
|
|
|
p++;
|
2023-05-13 17:03:50 +00:00
|
|
|
skip_whitespace_or_line_continuation(&p);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
if (IsEndfor(p)) {
|
2022-02-05 20:03:50 +00:00
|
|
|
DEBUG1(FOR, "For: end for %d\n", *forLevel);
|
|
|
|
if (--*forLevel == 0)
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-02-11 01:51:11 +00:00
|
|
|
} else if (IsFor(p)) {
|
2022-02-05 20:03:50 +00:00
|
|
|
(*forLevel)++;
|
|
|
|
DEBUG1(FOR, "For: new loop %d\n", *forLevel);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
Buf_AddStr(&accumFor->body, line);
|
|
|
|
Buf_AddByte(&accumFor->body, '\n');
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:52:53 +00:00
|
|
|
/*
|
|
|
|
* When the body of a '.for i' loop is prepared for an iteration, each
|
|
|
|
* occurrence of $i in the body is replaced with ${:U...}, inserting the
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
* value of the item. If this item contains a '$', it may be the start of an
|
|
|
|
* expression. This expression is copied verbatim, its length is
|
2022-07-26 15:52:53 +00:00
|
|
|
* determined here, in a rather naive way, ignoring escape characters and
|
|
|
|
* funny delimiters in modifiers like ':S}from}to}'.
|
|
|
|
*/
|
2020-09-05 16:11:04 +00:00
|
|
|
static size_t
|
2021-12-18 07:27:22 +00:00
|
|
|
ExprLen(const char *s, const char *e)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-12-18 07:27:22 +00:00
|
|
|
char expr_open, expr_close;
|
2021-01-14 01:24:34 +00:00
|
|
|
int depth;
|
2021-12-18 07:27:22 +00:00
|
|
|
const char *p;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (s == e)
|
|
|
|
return 0; /* just escape the '$' */
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
expr_open = s[0];
|
|
|
|
if (expr_open == '(')
|
|
|
|
expr_close = ')';
|
|
|
|
else if (expr_open == '{')
|
|
|
|
expr_close = '}';
|
2021-01-14 01:24:34 +00:00
|
|
|
else
|
|
|
|
return 1; /* Single char variable */
|
|
|
|
|
|
|
|
depth = 1;
|
2021-12-18 07:27:22 +00:00
|
|
|
for (p = s + 1; p != e; p++) {
|
|
|
|
if (*p == expr_open)
|
2021-01-14 01:24:34 +00:00
|
|
|
depth++;
|
2021-12-18 07:27:22 +00:00
|
|
|
else if (*p == expr_close && --depth == 0)
|
|
|
|
return (size_t)(p + 1 - s);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
/* Expression end not found, escape the $ */
|
2021-01-14 01:24:34 +00:00
|
|
|
return 0;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
2023-06-27 20:29:43 +00:00
|
|
|
* While expanding the body of a .for loop, write the item as a ${:U...}
|
2022-02-05 20:03:50 +00:00
|
|
|
* expression, escaping characters as needed. The result is later unescaped
|
|
|
|
* by ApplyModifier_Defined.
|
2021-01-14 01:24:34 +00:00
|
|
|
*/
|
2012-06-08 21:57:36 +00:00
|
|
|
static void
|
2022-02-05 20:03:50 +00:00
|
|
|
AddEscaped(Buffer *cmds, Substring item, char endc)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-12-18 07:27:22 +00:00
|
|
|
const char *p;
|
2021-01-14 01:24:34 +00:00
|
|
|
char ch;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
for (p = item.start; p != item.end;) {
|
2021-12-18 07:27:22 +00:00
|
|
|
ch = *p;
|
2021-01-14 01:24:34 +00:00
|
|
|
if (ch == '$') {
|
2021-12-18 07:27:22 +00:00
|
|
|
size_t len = ExprLen(p + 1, item.end);
|
2021-01-14 01:24:34 +00:00
|
|
|
if (len != 0) {
|
2021-12-18 07:27:22 +00:00
|
|
|
/*
|
|
|
|
* XXX: Should a '\' be added here?
|
|
|
|
* See directive-for-escape.mk, ExprLen.
|
|
|
|
*/
|
|
|
|
Buf_AddBytes(cmds, p, 1 + len);
|
2022-02-05 20:03:50 +00:00
|
|
|
p += 1 + len;
|
2021-01-14 01:24:34 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Buf_AddByte(cmds, '\\');
|
|
|
|
} else if (ch == ':' || ch == '\\' || ch == endc)
|
|
|
|
Buf_AddByte(cmds, '\\');
|
2021-12-18 07:27:22 +00:00
|
|
|
else if (ch == '\n') {
|
|
|
|
Parse_Error(PARSE_FATAL, "newline in .for value");
|
|
|
|
ch = ' '; /* prevent newline injection */
|
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
Buf_AddByte(cmds, ch);
|
2022-02-05 20:03:50 +00:00
|
|
|
p++;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
2023-06-27 20:29:43 +00:00
|
|
|
* While expanding the body of a .for loop, replace the variable name of an
|
2021-01-14 01:24:34 +00:00
|
|
|
* expression like ${i} or ${i:...} or $(i) or $(i:...) with ":Uvalue".
|
|
|
|
*/
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstVarLong(ForLoop *f, unsigned int firstItem, Buffer *body,
|
|
|
|
const char **pp, char endc, const char **inout_mark)
|
2020-11-07 19:39:21 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
size_t i;
|
2022-02-05 20:03:50 +00:00
|
|
|
const char *start = *pp;
|
2023-06-27 20:29:43 +00:00
|
|
|
const char **varnames = Vector_Get(&f->vars, 0);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
for (i = 0; i < f->vars.len; i++) {
|
2022-02-05 20:03:50 +00:00
|
|
|
const char *p = start;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2023-06-27 20:29:43 +00:00
|
|
|
if (!cpp_skip_string(&p, varnames[i]))
|
2021-01-14 01:24:34 +00:00
|
|
|
continue;
|
|
|
|
/* XXX: why test for backslash here? */
|
2022-02-05 20:03:50 +00:00
|
|
|
if (*p != ':' && *p != endc && *p != '\\')
|
2021-01-14 01:24:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Found a variable match. Skip over the variable name and
|
|
|
|
* instead add ':U<value>' to the current body.
|
|
|
|
*/
|
2023-06-27 20:29:43 +00:00
|
|
|
Buf_AddRange(body, *inout_mark, start);
|
2022-02-05 20:03:50 +00:00
|
|
|
Buf_AddStr(body, ":U");
|
|
|
|
AddEscaped(body, f->items.words[firstItem + i], endc);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
*inout_mark = p;
|
|
|
|
*pp = p;
|
|
|
|
return;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
2023-06-27 20:29:43 +00:00
|
|
|
* While expanding the body of a .for loop, replace single-character
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
* expressions like $i with their ${:U...} expansion.
|
2021-01-14 01:24:34 +00:00
|
|
|
*/
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstVarShort(ForLoop *f, unsigned int firstItem, Buffer *body,
|
|
|
|
const char *p, const char **inout_mark)
|
2020-11-07 19:39:21 +00:00
|
|
|
{
|
Import bmake-20240309
Intersting/relevant changes since bmake-20240108
ChangeLog since bmake-20240108
2024-03-10 Simon J Gerraty <sjg@beast.crufty.net>
* boot-strap: tests can take a long time; use a cookie to
skip them if bmake has not been updated since tests last
ran successfully.
* Makefile: Cygwin handles MANTARGET man
* unit-tests/Makefile: set BROKEN_TESTS for Cygwin
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240309
Merge with NetBSD make, pick up
o set .ERROR_EXIT to the exit status of .ERROR_TARGET
this allows a .ERROR target to ignore the case of
.ERROR_EXIT==6 which just means that the build actually
failed somewhere else.
2024-03-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240303
* var.c: on IRIX we need both inttypes.h and stdint.h
2024-03-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240301
Merge with NetBSD make, pick up
o export variables with value from target scope
when appropriate.
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240212
Merge with NetBSD make, pick up
o remove unneeded conditional-compilation toggles
INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT NO_REGEX and SUNSHCMD
* configure.in: add check for regex.h
* var.c: replace use of NO_REGEX with HAVE_REGEX_H
2024-02-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240204
Merge with NetBSD make, pick up
o var.c: fix some lint (-dL) mode parsing issues
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION: (_MAKE_VERSION): 20240202
Merge with NetBSD make, pick up
o make.1: note that arg to :D and :U can be empty
o var.c: $$ is not a parse error when .MAKE.SAVE_DOLLARS=no
mk/ChangeLog since bmake-20240108
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240309
* meta.sys.mk: _metaError: if .ERROR_EXIT == 6, we do not
want to save the .ERROR_META_FILE
2024-02-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240220
* sys.dirdeps.mk, dirdeps-targets.mk, init.mk:
do not set .MAIN: dirdeps in sys.dirdeps.mk
dirdeps-targets.mk will do that for top-level builds
and init.mk will do it for others.
This allows a Makefile which has no need of 'dirdeps' to
set .MAIN for itself and "just work".
2024-02-18 Simon J Gerraty <sjg@beast.crufty.net>
* bsd.*.mk: for makefiles that get a bsd. symlink,
use _this in multiple inclusion tags since .PARSEFILE will not
DTRT when such a makefile is included directly by Makefile and
automatically (without bsd. prefix).
Since we cannot guarantee that our sys.mk will be used, we provide
a default _this in each makefile that gets a bsd. prefix such that
the value is the same regardless of bsd. prefix.
* subdir.mk: drop the !target guard on $SUBDIR_TARGETS
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240212
* SPDX-License-Identifier: BSD-2-Clause
Add SPDX-License-Identifier to inidicate that I consider
my copyright on any of these makefiles equivalent to BSD-2-Clause
* autoconf.mk: allow for configure.ac as currently recommended
* subdir.mk: support @auto
which is replaced with each subdir that
has a [Mm]akefile.
* subdir.mk: include local.subdir.mk if it exists.
* subdir.mk: rework to handle .WAIT
2024-02-11 Simon J Gerraty <sjg@beast.crufty.net>
* subdir.mk: _SUBDIRUSE report the target we are entering subdirs for.
2024-02-10 Simon J Gerraty <sjg@beast.crufty.net>
* prog.mk: treat empty SRCS the same as undefined
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* Avoid undefined errors in lint (-dL) mode
* man.mk (CMT2DOC_FLAGS): note that -mm does mdoc(7)
2024-01-28 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240128
* FILES: add ccm.dep.mk for C++ modules
add suffixes.mk for common location for generic SUFFIX rules.
* auto.dep.mk autodep.mk meta.autodep.mk: include ccm.dep.mk
replace OBJ_EXTENSIONS with OBJ_SUFFIXES
* autodep.mk: leverage CXX_SUFFIXES for __depsrcs
and update style (spaces around = etc)
* init.mk: add OBJS_SRCS_FILTER to filter SRCS when
setting OBJS
* meta2deps.py: handle multiple ./ embedded in path better.
2024-03-14 02:14:41 +00:00
|
|
|
char ch = *p;
|
2022-02-05 20:03:50 +00:00
|
|
|
const char **vars;
|
2021-01-14 01:24:34 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/* Skip $$ and stupid ones. */
|
2021-12-18 07:27:22 +00:00
|
|
|
if (ch == '}' || ch == ')' || ch == ':' || ch == '$')
|
2021-01-14 01:24:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
vars = Vector_Get(&f->vars, 0);
|
|
|
|
for (i = 0; i < f->vars.len; i++) {
|
2022-02-05 20:03:50 +00:00
|
|
|
const char *varname = vars[i];
|
2021-01-14 01:24:34 +00:00
|
|
|
if (varname[0] == ch && varname[1] == '\0')
|
|
|
|
goto found;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
return;
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
found:
|
2023-06-27 20:29:43 +00:00
|
|
|
Buf_AddRange(body, *inout_mark, p);
|
2021-12-18 07:27:22 +00:00
|
|
|
*inout_mark = p + 1;
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/* Replace $<ch> with ${:U<value>} */
|
2022-02-05 20:03:50 +00:00
|
|
|
Buf_AddStr(body, "{:U");
|
|
|
|
AddEscaped(body, f->items.words[firstItem + i], '}');
|
|
|
|
Buf_AddByte(body, '}');
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* Compute the body for the current iteration by copying the unexpanded body,
|
|
|
|
* replacing the expressions for the iteration variables on the way.
|
2020-11-07 19:39:21 +00:00
|
|
|
*
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
* Using expressions ensures that the .for loop can't generate
|
2023-06-27 20:29:43 +00:00
|
|
|
* syntax, and that the later parsing will still see an expression.
|
|
|
|
* This code assumes that the variable with the empty name is never defined,
|
|
|
|
* see unit-tests/varname-empty.mk.
|
2020-11-07 19:39:21 +00:00
|
|
|
*
|
2021-02-11 01:51:11 +00:00
|
|
|
* The detection of substitutions of the loop control variables is naive.
|
2021-12-18 07:27:22 +00:00
|
|
|
* Many of the modifiers use '\$' instead of '$$' to escape '$', so it is
|
|
|
|
* possible to contrive a makefile where an unwanted substitution happens.
|
2023-06-27 20:29:43 +00:00
|
|
|
* See unit-tests/directive-for-escape.mk.
|
2020-11-07 19:39:21 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
static void
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstBody(ForLoop *f, unsigned int firstItem, Buffer *body)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
const char *p, *end;
|
2021-12-18 07:27:22 +00:00
|
|
|
const char *mark; /* where the last substitution left off */
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
Buf_Clear(body);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
mark = f->body.data;
|
2022-02-05 20:03:50 +00:00
|
|
|
end = f->body.data + f->body.len;
|
2021-01-14 01:24:34 +00:00
|
|
|
for (p = mark; (p = strchr(p, '$')) != NULL;) {
|
|
|
|
if (p[1] == '{' || p[1] == '(') {
|
2021-12-18 07:27:22 +00:00
|
|
|
char endc = p[1] == '{' ? '}' : ')';
|
2021-01-14 01:24:34 +00:00
|
|
|
p += 2;
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstVarLong(f, firstItem, body,
|
|
|
|
&p, endc, &mark);
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
} else {
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstVarShort(f, firstItem, body,
|
|
|
|
p + 1, &mark);
|
2021-01-14 01:24:34 +00:00
|
|
|
p += 2;
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2023-06-27 20:29:43 +00:00
|
|
|
Buf_AddRange(body, mark, end);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Compute the body for the current iteration by copying the unexpanded body,
|
|
|
|
* replacing the expressions for the iteration variables on the way.
|
|
|
|
*/
|
2022-02-05 20:03:50 +00:00
|
|
|
bool
|
|
|
|
For_NextIteration(ForLoop *f, Buffer *body)
|
2021-01-14 01:24:34 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
if (f->nextItem == f->items.len)
|
|
|
|
return false;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
f->nextItem += (unsigned int)f->vars.len;
|
2022-02-05 20:03:50 +00:00
|
|
|
ForLoop_SubstBody(f, f->nextItem - (unsigned int)f->vars.len, body);
|
2023-06-27 20:29:43 +00:00
|
|
|
if (DEBUG(FOR)) {
|
|
|
|
char *details = ForLoop_Details(f);
|
|
|
|
debug_printf("For: loop body with %s:\n%s",
|
|
|
|
details, body->data);
|
|
|
|
free(details);
|
|
|
|
}
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2023-01-28 00:23:54 +00:00
|
|
|
/* Break out of the .for loop. */
|
|
|
|
void
|
|
|
|
For_Break(ForLoop *f)
|
|
|
|
{
|
|
|
|
f->nextItem = (unsigned int)f->items.len;
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/* Run the .for loop, imitating the actions of an include file. */
|
2012-06-08 21:57:36 +00:00
|
|
|
void
|
2022-02-05 20:03:50 +00:00
|
|
|
For_Run(unsigned headLineno, unsigned bodyReadLines)
|
2020-07-08 18:32:15 +00:00
|
|
|
{
|
2022-02-05 20:03:50 +00:00
|
|
|
Buffer buf;
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop *f = accumFor;
|
2021-01-14 01:24:34 +00:00
|
|
|
accumFor = NULL;
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
if (f->items.len > 0) {
|
|
|
|
Buf_Init(&buf);
|
|
|
|
Parse_PushInput(NULL, headLineno, bodyReadLines, buf, f);
|
|
|
|
} else
|
2021-02-11 01:51:11 +00:00
|
|
|
ForLoop_Free(f);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|