diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-05-04 06:17:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-05-04 06:17:15 -0700 |
commit | 8ac435caf03bd91f4f73e62e57bcc9a2f31eaf4c (patch) | |
tree | 854a1cb903cedd928715ee2f169648c67a864856 | |
parent | 742a7bf9408b976c84ad947f9b39637f184482fa (diff) | |
download | txr-8ac435caf03bd91f4f73e62e57bcc9a2f31eaf4c.tar.gz txr-8ac435caf03bd91f4f73e62e57bcc9a2f31eaf4c.tar.bz2 txr-8ac435caf03bd91f4f73e62e57bcc9a2f31eaf4c.zip |
bugfix: correcly obtain self path on Solaris.
* configure: Add detection for getexecname.
* sysif.c (getcwd_wrap): Change static function to external.
* sysif.h (getcwd_wrap): Declared.
* txr.c (get_self_path): New implementation for Solaris
using getexecname, which requires us to prepend the current
directory name if the result is a relative path.
-rwxr-xr-x | configure | 18 | ||||
-rw-r--r-- | sysif.c | 2 | ||||
-rw-r--r-- | sysif.h | 3 | ||||
-rw-r--r-- | txr.c | 8 |
4 files changed, 30 insertions, 1 deletions
@@ -2973,6 +2973,24 @@ else printf "no\n" fi +printf "Checking for getexecname ... " +cat > conftest.c <<! +#include <stdlib.h> + +int main(void) +{ + const char *rp = getexecname(); + return 0; +} +! + +if conftest ; then + printf "yes\n" + printf "#define HAVE_GETEXECNAME 1\n" >> config.h +else + printf "no\n" +fi + # # Dependent variables # @@ -335,7 +335,7 @@ static val chdir_wrap(val path) return t; } -static val getcwd_wrap(void) +val getcwd_wrap(void) { size_t guess = 256; @@ -69,4 +69,7 @@ INLINE void repress_privilege(void) { } INLINE void drop_privilege(void) { } INLINE void simulate_setuid_setgid(val open_script) { } #endif +#if HAVE_UNISTD_H +val getcwd_wrap(void); +#endif void sysif_init(void); @@ -243,6 +243,14 @@ static val get_self_path(void) return nil; return string_utf8(self); } +#elif HAVE_GETEXECNAME +static val get_self_path(void) +{ + val execname = string_utf8(getexecname()); + if (car(execname) == chr('/')) + return execname; + return format(nil, lit("~a/~a"), getcwd_wrap(), execname, nao); +} #else static val get_self_path(void) { |