[schilytools] [PATCH] smake: Fix issue #46 smake does not always set CURDIR

Friedhelm Mehnert lists at friedhelms.net
Sun Jan 8 14:16:39 CET 2023


>From a38e8298d9a8501c0d4e6de5c5688209e15cee56 Mon Sep 17 00:00:00 2001
From: Friedhelm Mehnert <friedhelm at friedhelms.net>
Date: Sun, 8 Jan 2023 13:55:30 +0100
Subject: [PATCH] smake: Fix issue #46 smake does not always set CURDIR

---
This patch should fix issue #46. I have tested it, and it works.
However, there may be more elegant solutions. So feel free to change it.

Best Regards
Friedhelm


 smake/make.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/smake/make.c b/smake/make.c
index ed329424..c51c3bf9 100644
--- a/smake/make.c
+++ b/smake/make.c
@@ -608,6 +608,7 @@ setup_vars()
  * Set up the special macro $(MAKE).
  * If we were called with an absolute PATH or without any '/', use argv[0],
  * else compute the absolute PATH by prepending working dir to argv[0].
+ * (We need to compute the absolute PATH anyway, so CURDIR will be set).
  */
 LOCAL void
 setup_MAKE(name)
@@ -622,8 +623,10 @@ setup_MAKE(name)
 	 * it is useful as $(MAKE).
 	 */
 #ifdef HAVE_DOS_DRIVELETTER
+	strncpy(wd, curwdir(), sizeof (wd));
 	if (name[0] == SLASH || strchr(name, SLASH) == NULL || name[1] == ':') {
 #else
+	strncpy(wd, curwdir(), sizeof (wd));
 	if (name[0] == SLASH || strchr(name, SLASH) == NULL) {
 #endif
 		define_var("MAKE", name);
-- 
2.30.2



More information about the schilytools mailing list