]> granicus.if.org Git - p11-kit/commitdiff
Fix getprogname() running under wine
authorStef Walter <stefw@gnome.org>
Tue, 17 Jul 2012 04:09:52 +0000 (06:09 +0200)
committerStef Walter <stefw@gnome.org>
Tue, 17 Jul 2012 04:09:52 +0000 (06:09 +0200)
 * Wine uses normal slashes instead of backslashes on windows

common/compat.c

index e1f75322e904a6107e24eb23344225fe000d8567..0f7cb7801c34af537f14f433aee9a38ce4fd7510 100644 (file)
@@ -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;