mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Restore argument processing to InSitu benchmark
GBench barfs on arguments such as --size without this patch that restores removing vtkm specific arguments from the command-line.
This commit is contained in:
parent
9e9f903f6b
commit
b4a6c2b546
@ -984,6 +984,55 @@ void ParseBenchmarkOptions(int& argc, char** argv)
|
||||
|
||||
std::cerr << "Using data set dimensions = " << DataSetDim << std::endl;
|
||||
std::cerr << "Using image size = " << ImageSize << "x" << ImageSize << std::endl;
|
||||
|
||||
// Now go back through the arg list and remove anything that is not in the list of
|
||||
// unknown options or non-option arguments.
|
||||
int destArg = 1;
|
||||
// This is copy/pasted from vtkm::cont::Initialize(), should probably be abstracted eventually:
|
||||
for (int srcArg = 1; srcArg < argc; ++srcArg)
|
||||
{
|
||||
std::string thisArg{ argv[srcArg] };
|
||||
bool copyArg = false;
|
||||
|
||||
// Special case: "--" gets removed by optionparser but should be passed.
|
||||
if (thisArg == "--")
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
for (const option::Option* opt = options[UNKNOWN]; !copyArg && opt != nullptr;
|
||||
opt = opt->next())
|
||||
{
|
||||
if (thisArg == opt->name)
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
if ((opt->arg != nullptr) && (thisArg == opt->arg))
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
// Special case: optionparser sometimes removes a single "-" from an option
|
||||
if (thisArg.substr(1) == opt->name)
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
}
|
||||
for (int nonOpt = 0; !copyArg && nonOpt < commandLineParse.nonOptionsCount(); ++nonOpt)
|
||||
{
|
||||
if (thisArg == commandLineParse.nonOption(nonOpt))
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
}
|
||||
if (copyArg)
|
||||
{
|
||||
if (destArg != srcArg)
|
||||
{
|
||||
argv[destArg] = argv[srcArg];
|
||||
}
|
||||
++destArg;
|
||||
}
|
||||
}
|
||||
argc = destArg;
|
||||
}
|
||||
|
||||
} // end anon namespace
|
||||
|
Loading…
Reference in New Issue
Block a user