shithub: ft²

Download patch

ref: 5005e7fee4b5f79ce772272edc4f1bf84542eed4
parent: 2f4ee149c4b1d39c65ce6f0fdcc6c66bec05291d
author: CuriouslyCurious <thecuriouslycurious@protonmail.com>
date: Tue Jul 29 20:49:48 EDT 2025

Fix diskop not working on musl systems

--- a/src/ft2_diskop.c
+++ b/src/ft2_diskop.c
@@ -20,6 +20,7 @@
 #include <fts.h> // for fts_open() and stuff in recursiveDelete()
 #include <unistd.h>
 #include <dirent.h>
+#include <errno.h>
 #endif
 #include <wchar.h>
 #include <sys/stat.h>
@@ -1753,7 +1754,7 @@
 	char *asciiPath = unicharToCp850(FReq_CurPathU, true);
 	if (asciiPath == NULL)
 	{
-		okBox(0, "System message", "Not enough memory!", NULL);
+		okBox(0, "System message", "Could not get CWD!", NULL);
 		return;
 	}
 
--- a/src/ft2_unicode.c
+++ b/src/ft2_unicode.c
@@ -3,6 +3,23 @@
 #include <crtdbg.h>
 #endif
 
+// for detecting if musl or glibc is used
+#ifndef _WIN32
+	#ifndef _GNU_SOURCE
+		#define _GNU_SOURCE
+	  #include <features.h>
+	  #ifndef __USE_GNU
+	      #define __MUSL__
+	  #endif
+	  #undef _GNU_SOURCE /* don't contaminate other includes unnecessarily */
+	#else
+	  #include <features.h>
+	  #ifndef __USE_GNU
+	      #define __MUSL__
+	  #endif
+	#endif
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
@@ -285,6 +302,8 @@
 	iconv_t cd = iconv_open("850//TRANSLIT//IGNORE", "UTF-8-MAC");
 #elif defined(__NetBSD__) || defined(__sun) || defined(sun)
 	iconv_t cd = iconv_open("850", "UTF-8");
+#elif defined(__MUSL__)
+	iconv_t cd = iconv_open("cp850", "UTF-8");
 #else
 	iconv_t cd = iconv_open("850//TRANSLIT//IGNORE", "UTF-8");
 #endif
--