1
0
forked from 0ad/0ad

Allow command line options to start with - or --

Reviewed by: mimo
Differential Revision: https://code.wildfiregames.com/D883
This was SVN commit r20249.
This commit is contained in:
Imarok 2017-09-30 16:12:18 +00:00
parent 9d232fd39a
commit 7a5c5100c0
2 changed files with 5 additions and 5 deletions

View File

@ -457,7 +457,7 @@ static void RunGameOrAtlas(int argc, const char* argv[])
g_args = args;
if (args.Has("version") || args.Has("-version"))
if (args.Has("version"))
{
debug_printf("Pyrogenesis %s\n", engine_version);
return;

View File

@ -37,19 +37,19 @@ CmdLineArgs::CmdLineArgs(int argc, const char* argv[])
if (argv[i][0] != '-')
continue;
// Allow -arg and --arg
char offset = argv[i][1] == '-' ? 2 : 1;
CStr name, value;
// Check for "-arg=value"
const char* eq = strchr(argv[i], '=');
if (eq)
{
name = CStr(argv[i]+1, eq-argv[i]-1);
name = CStr(argv[i]+offset, eq-argv[i]-offset);
value = CStr(eq+1);
}
else
{
name = CStr(argv[i]+1);
}
name = CStr(argv[i]+offset);
m_Args.emplace_back(std::move(name), std::move(value));
}