pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: odd -J complaint from make on netbsd-11
On Wed, 04 Feb 2026 10:00:04 -0800, "Simon J. Gerraty" writes:
>>Actually it occurs to me now, that if GNode_AddCommand checks the
>>expanded command then the above is unnecessary.
>>
>>We'll still have the test result changes to deal with though, as there
>>should be fewer false positives etc.
>
>The patch below will check for both progname and "make" (if progname !=
>"make") in the expanded (if needed) commands.
>It does a much better job of spotting "make" as a word (preceded by '/'
>or space, and followed by space or nul.
>
>This change however results in a *lot* more (19) changes to test results.
>
>Some of them are obviously correct like;
>no longer setting OP_SUBMAKE for 'make-index'
>and setting OP_SUBMAKE for a target containing ${MAKE:T}
>but others are not at all obvious.
Many appear to just be parse errors showing up earlier,
perhaps we need a VARE_EVAL_SILENT ?
Regardless a number of unit-tests would need a rethink.
Patch needs to allow for ecmd == var_Error and probably varUndefined too
which is currently private to var.c
diff -r fbc7b47463d3 bmake/parse.c
--- a/bmake/parse.c Wed Feb 04 10:57:32 2026 -0800
+++ b/bmake/parse.c Wed Feb 04 15:15:31 2026 -0800
@@ -1984,6 +1984,24 @@
}
}
+/*
+ * Does cmd contain name?
+ * To match; name must be at the start or preceded by '/' or space,
+ * and it must be followed by '\0' or space.
+ */
+static bool
+maybeSubMake(const char *cmd, const char *name, size_t len)
+{
+ const char *p;
+
+ for (p = strstr(cmd, name); p != NULL; p = strstr(&p[1], name)) {
+ if (p == cmd || p[-1] == '/' || ch_isspace(p[-1])) {
+ if (p[len] == '\0' || ch_isspace(p[len]))
+ return true;
+ }
+ }
+ return false;
+}
/*
* See if the command possibly calls a sub-make by using the
@@ -1992,37 +2010,33 @@
static bool
MaybeSubMake(const char *cmd)
{
- const char *start;
-
- for (start = cmd; *start != '\0'; start++) {
- const char *p = start;
- char endc;
-
- /* XXX: What if progname != "make"? */
- if (strncmp(p, "make", 4) == 0)
- if (start == cmd || !ch_isalnum(p[-1]))
- if (!ch_isalnum(p[4]))
- return true;
-
- if (*p != '$')
- continue;
- p++;
-
- if (*p == '{')
- endc = '}';
- else if (*p == '(')
- endc = ')';
- else
- continue;
- p++;
-
- if (*p == '.') /* Accept either ${.MAKE} or ${MAKE}. */
- p++;
-
- if (strncmp(p, "MAKE", 4) == 0 && p[4] == endc)
- return true;
+ static size_t prognameLen;
+ static size_t makeLen;
+ char *ecmd;
+ bool rc = false;
+
+ if (!prognameLen) {
+ prognameLen = strlen(progname);
+
+ /* we are always called make for unit-tests */
+ if (prognameLen != 4 || strcmp(progname, "make") != 0)
+ makeLen = 4;
}
- return false;
+ if (strchr(cmd, '$') != NULL) {
+ ecmd = Var_Subst(cmd, SCOPE_GLOBAL, VARE_EVAL);
+ if (ecmd == var_Error)
+ ecmd = NULL;
+ } else
+ ecmd = NULL; /* const correctness is a PITA */
+
+ if (maybeSubMake(ecmd ? ecmd : cmd, progname, prognameLen))
+ rc = true;
+ else if (makeLen > 0 &&
+ maybeSubMake(ecmd ? ecmd : cmd, "make", makeLen))
+ rc = true;
+ if (ecmd != cmd)
+ free(ecmd);
+ return rc;
}
/* Append the command to the target node. */
Home |
Main Index |
Thread Index |
Old Index