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.
This commit is contained in:
Thomas Wilshaw
2020-09-02 23:35:44 +01:00
parent e42ba3f9d4
commit 8d6bd5e929
+6 -2
View File
@@ -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;