aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fcdefault.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-01-17 09:25:28 +0100
committermarha <marha@users.sourceforge.net>2013-01-17 09:25:28 +0100
commit50c07563e17397daf040a32d8fdd3ab397e72371 (patch)
treeae9c109e16ba86a498c43ab62830bca3641a78aa /fontconfig/src/fcdefault.c
parentdc163f625ef006c8550791122bda28fb3eb67e3d (diff)
parent4fc6b34d1c14cc61f553ca59264d0909656933f3 (diff)
downloadvcxsrv-50c07563e17397daf040a32d8fdd3ab397e72371.tar.gz
vcxsrv-50c07563e17397daf040a32d8fdd3ab397e72371.tar.bz2
vcxsrv-50c07563e17397daf040a32d8fdd3ab397e72371.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libxcb mesa xkbcomp git update 17 jan 2013
Diffstat (limited to 'fontconfig/src/fcdefault.c')
-rw-r--r--fontconfig/src/fcdefault.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/fontconfig/src/fcdefault.c b/fontconfig/src/fcdefault.c
index aa47840d1..b1bd9cc1f 100644
--- a/fontconfig/src/fcdefault.c
+++ b/fontconfig/src/fcdefault.c
@@ -23,6 +23,7 @@
*/
#include "fcint.h"
+#include <limits.h>
#include <string.h>
/* MT-safe */
@@ -139,27 +140,38 @@ retry:
prgname = FcStrdup (p);
}
+#elif defined (HAVE_GETPROGNAME)
+ const char *q = getprogname ();
+ if (q)
+ prgname = FcStrdup (q);
+ else
+ prgname = FcStrdup ("");
#else
- char buf[8192];
+ char buf[PATH_MAX + 1];
unsigned int len;
+ char *p = NULL;
len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
if (len > 0)
{
- char *p;
+ buf[len] = '\0';
+ p = buf;
+ }
- p = strrchr (buf, '/');
- if (p)
- p++;
+ if (p)
+ {
+ char *r = strrchr (p, '/');
+ if (r)
+ r++;
else
- p = buf;
+ r = p;
- prgname = FcStrdup (p);
+ prgname = FcStrdup (r);
}
-#endif
if (!prgname)
prgname = FcStrdup ("");
+#endif
if (!fc_atomic_ptr_cmpexch (&default_prgname, NULL, prgname)) {
free (prgname);