From: Stef Walter <stefw@gnome.org> Date: Tue, 17 Jul 2012 04:09:52 +0000 (+0200) Subject: Fix getprogname() running under wine X-Git-Tag: 0.14~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cd198107374ff1879767679d29df0ce78f9427f;p=p11-kit Fix getprogname() running under wine * Wine uses normal slashes instead of backslashes on windows --- diff --git a/common/compat.c b/common/compat.c index e1f7532..0f7cb78 100644 --- a/common/compat.c +++ b/common/compat.c @@ -82,7 +82,7 @@ const char * getprogname (void) { const char *name; - const char *p; + const char *p, *p2; size_t length; name = __argv[0]; @@ -90,6 +90,9 @@ getprogname (void) return NULL; p = strrchr (name, '\\'); + p2 = strrchr (name, '/'); + if (p2 > p) + p = p2; if (p != NULL) name = p + 1; @@ -97,7 +100,7 @@ getprogname (void) strncpy (prognamebuf, name, length); prognamebuf[length] = 0; length = strlen (prognamebuf); - if (length > 4 && _stricmp (prognamebuf + (length - 4), ".exe")) + if (length > 4 && _stricmp (prognamebuf + (length - 4), ".exe") == 0) prognamebuf[length - 4] = '\0'; return prognamebuf;