1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-15 17:30:06 +00:00

Try reading from /proc/self first on linux, this is needed to make the edgy "make avail" work

This commit is contained in:
Bob Andrews 2022-04-30 15:01:58 +02:00 committed by GitHub
parent d78672a4b4
commit 74f92564c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -296,10 +296,23 @@ void AddSubSearchPathFromBin (SearchPaths* P, const char* SubDir)
}
*Ptr = '\0';
#elif defined(__linux__)
/* reading from proc will return the real location, excluding symlinked
pathes - which is needed for certain edgy cases */
if (readlink("/proc/self/exe", Dir, sizeof(Dir) - 1) < 0) {
GetProgPath(Dir, ArgVec[0]);
} else {
/* Remove binary name */
Ptr = strrchr (Dir, PATHSEP[0]);
if (Ptr == 0) {
return;
}
*Ptr = '\0';
}
#else
GetProgPath(Dir, ArgVec[0]);
#endif
/* Check for 'bin' directory */