Files
macports-ports/audio/dectalk/files/patch-fix-windic.diff

72 lines
2.1 KiB
Diff

commit abd064c9c9ec654e8a74d86475f596f9696309e6
Author: Mohamed Akram <mohd.akram@outlook.com>
Date: Sun May 26 02:50:08 2024 +0400
Fix Windic resource paths on macOS
diff --git samplosf/src/windict/windic.c samplosf/src/windict/windic.c
index e2c325b0..1c721acd 100644
--- samplosf/src/windict/windic.c
+++ samplosf/src/windict/windic.c
@@ -1210,7 +1210,19 @@ void HelpAboutCallback(GtkWidget *w, gpointer data)
if (config_file==NULL)
{
char p[PATH_MAX] = {};
- ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#if defined(__linux__)
+ ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#elif defined(__APPLE__)
+ char ep[PATH_MAX] = {};
+ uint32_t size = sizeof(ep);
+ ssize_t count = -1;
+ if (_NSGetExecutablePath(ep, &size) == 0) {
+ if (realpath(ep, p) != NULL) {
+ count = strlen(p);
+ }
+ }
+#endif
+
if (count != -1) {
char *cfg;
cfg = dirname(p);
@@ -1227,7 +1239,18 @@ void HelpAboutCallback(GtkWidget *w, gpointer data)
if (config_file==NULL)
{
char p[PATH_MAX] = {};
- ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#if defined(__linux__)
+ ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#elif defined(__APPLE__)
+ char ep[PATH_MAX] = {};
+ uint32_t size = sizeof(ep);
+ ssize_t count = -1;
+ if (_NSGetExecutablePath(ep, &size) == 0) {
+ if (realpath(ep, p) != NULL) {
+ count = strlen(p);
+ }
+ }
+#endif
if (count != -1) {
char *cfg;
cfg = dirname(p);
@@ -1269,7 +1292,18 @@ void HelpAboutCallback(GtkWidget *w, gpointer data)
#if defined __linux || defined (__APPLE__)
if (exe_path && (bitmap_path[0] != '/')) {
char p[PATH_MAX] = {};
- ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#if defined(__linux__)
+ ssize_t count = readlink("/proc/self/exe", p, PATH_MAX);
+#elif defined(__APPLE__)
+ char ep[PATH_MAX] = {};
+ uint32_t size = sizeof(ep);
+ ssize_t count = -1;
+ if (_NSGetExecutablePath(ep, &size) == 0) {
+ if (realpath(ep, p) != NULL) {
+ count = strlen(p);
+ }
+ }
+#endif
if (count != -1) {
char *bmp;
bmp = dirname(p);