summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2018-06-14 11:00:21 +1000
committerTimothy Arceri <[email protected]>2018-06-19 12:09:56 +1000
commitde93f546a7f9f3407f88ea8dd2d4b3f7158e94ed (patch)
treee61a5fc96fb63b43bd6596b2facea01ea28f28ed
parent1a8501a9ddfff6c3eab47046e0e8a9dc17492bf0 (diff)
util: manually extract the program name from program_invocation_name
Glibc has the same code to get program_invocation_short_name. However for some reason the short name gets mangled for some wine apps. For example with Google Earth VR I get: program_invocation_name: "/home/tarceri/.local/share/Steam/steamapps/common/EarthVR/Earth.exe" program_invocation_short_name: "e" Acked-by: Eric Engestrom <[email protected]>
-rw-r--r--src/util/xmlconfig.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index 60a6331c86c..ad943e2ce48 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -45,7 +45,16 @@
/* These aren't declared in any libc5 header */
extern char *program_invocation_name, *program_invocation_short_name;
# endif
-# define GET_PROGRAM_NAME() program_invocation_short_name
+static const char *
+__getProgramName()
+{
+ char * arg = strrchr(program_invocation_name, '/');
+ if (arg)
+ return arg+1;
+ else
+ return program_invocation_name;
+}
+# define GET_PROGRAM_NAME() __getProgramName()
#elif defined(__CYGWIN__)
# define GET_PROGRAM_NAME() program_invocation_short_name
#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)