From 820ade383860692d0b5abbba00a3e428f21b88e4 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 22 Jan 2025 15:09:11 +0000 Subject: make: fix detection of target rule with inline command Commit f9d10b2b6 (make: fix detection of target rules (take 2)) added code to handle the case where a target rule had an inline command with a ';' separator in a macro. This required all macros on the line to be expanded, including those in the inline command. The ';' should first be searched for in the original line (without any macro expansion) and only if that fails should macros be expanded. This matches the behaviour of GNU and Unix V7 make. BSD and Schily make don't handle the case where the ';' is in a macro. (pdpmake GitHub issue 73) --- miscutils/make.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'miscutils') diff --git a/miscutils/make.c b/miscutils/make.c index 39c0081ab..a165274aa 100644 --- a/miscutils/make.c +++ b/miscutils/make.c @@ -2170,6 +2170,20 @@ pragmas_from_env(void) } #endif +/* + * Determine if a line is a target rule with an inline command. + * Return a pointer to the semicolon separator if it is, else NULL. + */ +static char * +inline_command(char *line) +{ + char *p = find_char(line, ':'); + + if (p) + p = strchr(p, ';'); + return p; +} + /* * Parse input from the makefile and construct a tree structure of it. */ @@ -2389,9 +2403,9 @@ input(FILE *fd, int ilevel) cp = NULL; s = strchr(q, ';'); if (s) { - // Retrieve command from expanded copy of line + // Retrieve command from original or expanded copy of line char *copy3 = expand_macros(copy, FALSE); - if ((p = find_colon(copy3)) && (p = strchr(p, ';'))) + if ((p = inline_command(copy)) || (p = inline_command(copy3))) newcmd(&cp, process_command(p + 1)); free(copy3); *s = '\0'; -- cgit v1.2.3-55-g6feb