add default executable

This commit is contained in:
Vitor Santos Costa 2016-07-31 04:29:47 -05:00
parent 0cc010bc42
commit 4ebb83e998

View File

@ -70,21 +70,13 @@ char *Yap_FindExecutable(void) {
// Solaris // Solaris
return getexecname(); return getexecname();
#elif __APPLE__ #elif __APPLE__
char path[1024]; char *buf = malloc(YAP_FILENAME_MAX);
char *buf;
uint32_t size = sizeof(path); uint32_t size;
if (!_NSGetExecutablePath(path, &size)) { if (!_NSGetExecutablePath(buf, &size)) {
size_t sz = strlen(path); buf = realloc(buf, size + 1);
buf = malloc(sz + 1);
strncpy(buf, path, sz);
return buf; return buf;
} else { } return "yap";
char *rc = malloc(size + 1);
if (_NSGetExecutablePath(rc, &size) == 0)
return "yap";
return rc;
}
#elif defined(__linux__) #elif defined(__linux__)
enum { BUFFERSIZE = 1024 }; enum { BUFFERSIZE = 1024 };
char *buf = malloc(BUFFERSIZE); char *buf = malloc(BUFFERSIZE);