Fix find_ivl_root for OSX

(cherry picked from commit 57cfbc0cea)
This commit is contained in:
Miodrag Milanovic 2022-01-05 09:23:48 +01:00 committed by Martin Whitaker
parent 7d3c25f39a
commit 3e84e6e93a
1 changed files with 4 additions and 1 deletions

View File

@ -1046,7 +1046,7 @@ static void find_ivl_root(void)
if the user has overridden $(bindir) or $(libdir), but there's if the user has overridden $(bindir) or $(libdir), but there's
not a lot we can do in that case. not a lot we can do in that case.
*/ */
#ifdef __MINGW32__ #if defined(__MINGW32__)
char tmppath[MAXSIZE]; char tmppath[MAXSIZE];
len = GetModuleFileName(NULL, tmppath, sizeof tmppath); len = GetModuleFileName(NULL, tmppath, sizeof tmppath);
if (len >= (ssize_t) sizeof ivl_root) { if (len >= (ssize_t) sizeof ivl_root) {
@ -1054,6 +1054,9 @@ static void find_ivl_root(void)
} }
/* Convert to a short name to remove any embedded spaces. */ /* Convert to a short name to remove any embedded spaces. */
len = GetShortPathName(tmppath, ivl_root, sizeof ivl_root); len = GetShortPathName(tmppath, ivl_root, sizeof ivl_root);
#elif defined(__APPLE__)
uint32_t size = sizeof ivl_root;
len = _NSGetExecutablePath(ivl_root, &size) + 1;
#else #else
len = readlink("/proc/self/exe", ivl_root, sizeof ivl_root); len = readlink("/proc/self/exe", ivl_root, sizeof ivl_root);
#endif #endif