[Fontconfig] fontconfig: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Jan 16 19:01:47 PST 2013
src/fcdefault.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
New commits:
commit 2fe5ddfdae6be80db5b7e622ab6c1ab985377542
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Jan 16 21:01:28 2013 -0600
Fix FC_PRGNAME default
As reported by Raimund Steger.
diff --git a/src/fcdefault.c b/src/fcdefault.c
index 88978b8..2d7c4f7 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -140,33 +140,34 @@ retry:
prgname = FcStrdup (p);
}
-#elif defined (HAVE_GETPROGNAME) && defined (HAVE_REALPATH)
- const char *p = getprogname ();
- char resolved_path[PATH_MAX + 1];
-
- if (p)
- {
- if (realpath (p, resolved_path) != NULL)
- prgname = FcStrdup (resolved_path);
- }
#else
- char buf[8192];
+ char buf[PATH_MAX + 1];
unsigned int len;
+ 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);
if (len > 0)
{
- char *p;
+ buf[len] = '\0';
+ p = buf;
+ }
+#endif
- 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 ("");
@@ -175,6 +176,7 @@ retry:
free (prgname);
goto retry;
}
+#endif
}
if (prgname && !prgname[0])
More information about the Fontconfig
mailing list