diff --git a/enc/enc_lua/luafar_manual.tsi b/enc/enc_lua/luafar_manual.tsi
index 9476ce7283..9d8e22593f 100644
--- a/enc/enc_lua/luafar_manual.tsi
+++ b/enc/enc_lua/luafar_manual.tsi
@@ -9848,16 +9848,20 @@ lv=3
dt=Text
nm=win.JoinPath
ctime=3922434993
-mtime=3922435036
+mtime=3940098857
#_path = win.JoinPath (...)
#_
#_**Parameters:**
-#_ ... : 0 or more strings (nils allowed)
+#_ ... : 0 or more strings
#_
#_**Returns:**
#_ path: string
#_
+#_**Note:**
+#_ Empty string arguments are ignored except the last
+#_ argument where it's treated as the path delimiter.
+#_
#_@@@
#_
diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua
index 1dc5160d52..f9fc150dba 100644
--- a/plugins/luamacro/_globalinfo.lua
+++ b/plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
- Version = { 3, 0, 0, 856 },
+ Version = { 3, 0, 0, 857 },
MinFarVersion = { 3, 0, 0, 6380 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog
index 42e3991bc7..5dee2fa779 100644
--- a/plugins/luamacro/changelog
+++ b/plugins/luamacro/changelog
@@ -1,3 +1,7 @@
+shmuel 2024-11-06 23:51:17+02:00 - build 857
+
+1. LuaFAR: change win.JoinPath a little (see the manual)
+
shmuel 2024-10-31 22:45:33+02:00 - build 856
1. LuaFAR: fix actl.GetFarmanagerVersion(true)
diff --git a/plugins/luamacro/luafar/version.h b/plugins/luamacro/luafar/version.h
index b5add3fc7f..b75158e788 100644
--- a/plugins/luamacro/luafar/version.h
+++ b/plugins/luamacro/luafar/version.h
@@ -1,3 +1,3 @@
#include
-#define PLUGIN_BUILD 856
+#define PLUGIN_BUILD 857
diff --git a/plugins/luamacro/luafar/win.c b/plugins/luamacro/luafar/win.c
index a391c68a8d..7809fb44a9 100644
--- a/plugins/luamacro/luafar/win.c
+++ b/plugins/luamacro/luafar/win.c
@@ -970,9 +970,14 @@ static int win_JoinPath(lua_State *L)
luaL_buffinit(L, &buf);
for (idx=1; idx <= top; idx++) {
- const char *s = luaL_optstring(L, idx, "");
- if (*s == 0)
+ const char *s = luaL_checkstring(L, idx);
+ if (*s == 0) {
+ if (idx == top && !was_slash) { // treat empty string in last arg as delimiter
+ luaL_addchar(&buf, DELIM);
+ break;
+ }
continue;
+ }
if (!empty && !was_slash && *s != DELIM)
luaL_addchar(&buf, DELIM);
else if (was_slash && *s == DELIM)