From 5cd198107374ff1879767679d29df0ce78f9427f Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 17 Jul 2012 06:09:52 +0200 Subject: Fix getprogname() running under wine * Wine uses normal slashes instead of backslashes on windows --- common/compat.c | 7 +++++-- 1 file 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; -- cgit v1.2.1