Darwin regtest: update none apple-main-arg for macOS 10.14

Looks like the apple pointer to the executable name started having a prefix
starting with macOS 10.14.
This commit is contained in:
Paul Floyd
2025-12-23 10:55:25 +01:00
parent 3932bdc09a
commit 7fa0593648

View File

@@ -24,19 +24,21 @@ int main(int argc, char *argv[], char *envp[], char *apple[])
// Make sure realpath(argv[0]) == realpath(apple[0]). (realpath resolves
// symlinks.)
// PJF this changed with macOS 11, apple path now has a prefix
#if (DARWIN_VERS >= DARWIN_11_00)
// PJF this changed with macOS 10.14, apple path now has a prefix
#if (DARWIN_VERS >= DARWIN_10_14)
const char prefix[] = "executable_path=";
const size_t prefix_len = strlen(prefix);
assert(strncmp(apple[0], prefix, prefix_len) == 0);
realpath(apple[0]+prefix_len, pappl);
exit(0);
#else
realpath(apple[0], pappl);
#endif
realpath(argv[0], pargv);
assert(0 == strcmp(pargv, pappl));
free(pargv);
free(pappl);
return 0;
}