From 68233b9402c1de7017e7f17010d3e99839dee860 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 5 Sep 2020 18:56:30 +1000 Subject: [PATCH] updated basename fix for multi-platform --- app/common/commandlineparser.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/common/commandlineparser.cpp b/app/common/commandlineparser.cpp index 3eed80942..9585a0c69 100644 --- a/app/common/commandlineparser.cpp +++ b/app/common/commandlineparser.cpp @@ -115,24 +115,24 @@ void CommandLineParser::PrintHelp(const char* filename) } const char* basename; - bool path = true; #ifdef Q_OS_WINDOWS basename = strrchr(filename, '\\'); if (!basename) { basename = strrchr(filename, '/'); } - // If no slashes are found we are probably running Olive from the executables own directory - // so we set basename equal to the filename (olive-editor.exe). This ensures basename is - // always valid. - if (!basename) { - basename = filename; - path = false; - } #else basename = strrchr(filename, '/'); #endif - printf("Usage: %s [options] %s\n\n", path ? basename + 1 : basename, positional_args.toUtf8().constData()); + if (basename) { + // Slash found, increment pointer to avoid showing the slash itself + basename++; + } else { + // If no slashes are found, assume string is already a basename + basename = filename; + } + + printf("Usage: %s [options] %s\n\n", basename, positional_args.toUtf8().constData()); foreach (const KnownOption& o, options_) { QString all_args;