From 0fc9f646c3f5df129adde5c0ebab274a123fba03 Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@pobox.com>
Date: Wed, 5 Jun 2024 09:22:08 +0100
Subject: make: restore check for c:/path target

Commit f9d10b2b6 (make: fix detection of target rules (take 2))
failed to include the function find_colon() which is used to skip
targets of the form c:/path when checking for a target rule.

Restore the function so Windows paths can be used as targets.

Adds 48 bytes.
---
 miscutils/make.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/miscutils/make.c b/miscutils/make.c
index 0235d9877..06917a867 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -1243,6 +1243,28 @@ find_char(const char *str, int c)
 	return NULL;
 }
 
+#if ENABLE_PLATFORM_MINGW32
+/*
+ * Check for a target rule by searching for a colon that isn't
+ * part of a Windows path.  Return a pointer to the colon or NULL.
+ */
+static char *
+find_colon(char *p)
+{
+	char *q;
+
+	for (q = p; (q = strchr(q, ':')); ++q) {
+		if (posix && !(pragma & P_WINDOWS))
+			break;
+		if (q == p || !isalpha(q[-1]) || q[1] != '/')
+			break;
+	}
+	return q;
+}
+#else
+# define find_colon(s) find_char(s, ':')
+#endif
+
 /*
  * Recursively expand any macros in str to an allocated string.
  */
@@ -2115,7 +2137,7 @@ input(FILE *fd, int ilevel)
 		p = expanded = expand_macros(str, FALSE);
 
 		// Look for colon separator
-		q = find_char(p, ':');
+		q = find_colon(p);
 		if (q == NULL)
 			error("expected separator");
 
-- 
cgit v1.2.3-55-g6feb