From 8d6bd5e9294a3e60ded1df01bd6dca9772450cac Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Wed, 2 Sep 2020 23:26:05 +0100 Subject: [PATCH] Fix Help option in headless mode on Windows Help option failed when Olive was run in its own directory as strrchr failed. If all else fails basename is equal to argv[0] and we don't increment in the print statement. Tested on Windows 7. --- app/common/commandlineparser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/common/commandlineparser.cpp b/app/common/commandlineparser.cpp index 584f6f1f3..deaf200ea 100644 --- a/app/common/commandlineparser.cpp +++ b/app/common/commandlineparser.cpp @@ -115,17 +115,21 @@ 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 (!basename) { + basename = filename; + path = false; + } #else basename = strrchr(filename, '/'); #endif - printf("Usage: %s [options] %s\n\n", basename + 1, positional_args.toUtf8().constData()); - + printf("Usage: %s [options] %s\n\n", path ? basename + 1 : basename, positional_args.toUtf8().constData()); foreach (const KnownOption& o, options_) { QString all_args;