Better fix for 2fe5ddfd

Drop realpath() and fix breakage on Win32
This commit is contained in:
Akira TAGOH 2013-01-17 12:49:16 +09:00
parent 2fe5ddfdae
commit 671bcb34e2
2 changed files with 8 additions and 8 deletions

View File

@ -141,7 +141,7 @@ AC_TYPE_PID_T
# Checks for library functions. # Checks for library functions.
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
AC_FUNC_MMAP AC_FUNC_MMAP
AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s getopt getopt_long getprogname rand random lrand48 random_r rand_r realpath regcomp regerror regexec regfree fstatvfs fstatfs lstat]) AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s getopt getopt_long getprogname rand random lrand48 random_r rand_r regcomp regerror regexec regfree fstatvfs fstatfs lstat])
dnl AC_CHECK_FUNCS doesn't check for header files. dnl AC_CHECK_FUNCS doesn't check for header files.
dnl posix_fadvise() may be not available in older libc. dnl posix_fadvise() may be not available in older libc.

View File

@ -140,23 +140,23 @@ retry:
prgname = FcStrdup (p); prgname = FcStrdup (p);
} }
#elif defined (HAVE_GETPROGNAME)
const char *q = getprogname ();
if (q)
prgname = FcStrdup (q);
else
prgname = FcStrdup ("");
#else #else
char buf[PATH_MAX + 1]; char buf[PATH_MAX + 1];
unsigned int len; unsigned int len;
char *p = NULL; char *p = NULL;
#if defined (HAVE_GETPROGNAME) && defined (HAVE_REALPATH)
const char *q = getprogname ();
if (q)
p = realpath (q, buf);
#else
len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1); len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
if (len > 0) if (len > 0)
{ {
buf[len] = '\0'; buf[len] = '\0';
p = buf; p = buf;
} }
#endif
if (p) if (p)
{ {
@ -171,12 +171,12 @@ retry:
if (!prgname) if (!prgname)
prgname = FcStrdup (""); prgname = FcStrdup ("");
#endif
if (!fc_atomic_ptr_cmpexch (&default_prgname, NULL, prgname)) { if (!fc_atomic_ptr_cmpexch (&default_prgname, NULL, prgname)) {
free (prgname); free (prgname);
goto retry; goto retry;
} }
#endif
} }
if (prgname && !prgname[0]) if (prgname && !prgname[0])