summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2012-07-17 06:09:52 +0200
committerStef Walter <stefw@gnome.org>2012-07-17 06:09:52 +0200
commit5cd198107374ff1879767679d29df0ce78f9427f (patch)
treee6d36c0b7e64e8d6a9bc982dbd14ede12c3a61e9
parentd51914b6483b7ddc806ee3861084aa98ee97a7fb (diff)
downloadp11-kit-5cd198107374ff1879767679d29df0ce78f9427f.tar.gz
Fix getprogname() running under wine
* Wine uses normal slashes instead of backslashes on windows
-rw-r--r--common/compat.c7
1 files changed, 5 insertions, 2 deletions
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;