From b8d0da94c3014753ce948f5d861ebfebb467eafe Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sun, 26 Feb 2006 21:27:02 +0000 Subject: * Merged ioq3-r589 --- src/unix/unix_main.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'src/unix') diff --git a/src/unix/unix_main.c b/src/unix/unix_main.c index c9b0a781..eb815685 100644 --- a/src/unix/unix_main.c +++ b/src/unix/unix_main.c @@ -1347,38 +1347,24 @@ to symlink to binaries and /not/ have the links resolved. */ char *Sys_BinName( const char *arg0 ) { -#ifdef NDEBUG - int n; - char src[ PATH_MAX ]; - char dir[ PATH_MAX ]; - qboolean links = qfalse; -#endif - static char dst[ PATH_MAX ]; - Q_strncpyz( dst, arg0, PATH_MAX ); - #ifdef NDEBUG - while( ( n = readlink( dst, src, PATH_MAX ) ) >= 0 ) - { - src[ n ] = '\0'; - Q_strncpyz( dir, dirname( dst ), PATH_MAX ); - Q_strncpyz( dst, dir, PATH_MAX ); - Q_strcat( dst, PATH_MAX, "/" ); - Q_strcat( dst, PATH_MAX, src ); +#ifdef __linux__ + int n = readlink( "/proc/self/exe", dst, PATH_MAX - 1 ); - links = qtrue; - } + if( n >= 0 && n < PATH_MAX ) + dst[ n ] = '\0'; + else + Q_strncpyz( dst, arg0, PATH_MAX ); +#else +#warning Sys_BinName not implemented + Q_strncpyz( dst, arg0, PATH_MAX ); +#endif - if( links ) - { - Q_strncpyz( dst, Sys_Cwd( ), PATH_MAX ); - Q_strcat( dst, PATH_MAX, "/" ); - Q_strcat( dst, PATH_MAX, dir ); - Q_strcat( dst, PATH_MAX, "/" ); - Q_strcat( dst, PATH_MAX, src ); - } +#else + Q_strncpyz( dst, arg0, PATH_MAX ); #endif return dst; -- cgit