Commit 51d819b7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

module_t::toString: changed >0 to >=0.

parent ce6b8099
Pipeline #4999 passed with stages
in 16 minutes and 46 seconds
......@@ -84,7 +84,7 @@ following commands which will output a list of operators that have selected prop
could result in: baseName_1 baseName_2 ... baseName_N
\end{verbatim}
\end{itemize}
For checking a single or multiple operator directly the following usage of --attrib can be used.
For checking a single or multiple operator directly the following usage of --attribs can be used:
\begin{verbatim}
cdo --attribs operatorName
\end{verbatim}
......
......@@ -1038,7 +1038,7 @@ parseOptionsLong(int argc, char *argv[])
{ "float" , no_argument , (int*)&Options::CDO_Memtype , (int)MemType::Float },
{ "double" , no_argument , (int*)&Options::CDO_Memtype , (int)MemType::Double },
{ "rusage" , no_argument , &CDO_Rusage , 1 },
{ "attribs" , optional_argument , &attribRequest , 1 },
{ "attribs" , optional_argument , &attribRequest , 1 },
{ "operators" , no_argument , &lprintOperators , 1 },
{ "operators_no_output" , no_argument , &loperators_no , 1 },
{ "pedantic" , no_argument , &lpedantic , 1 },
......
......@@ -8,11 +8,13 @@
#include <string>
typedef std::function<bool(module_t &mod)> ModuleQuery;
bool
ModListOptions::requested(std::string name)
{
return opt[name];
}
bool
ModListOptions::modInfoRequested()
{
......@@ -179,13 +181,13 @@ operatorPrintList(ModListOptions &p_opt)
ModuleQuery defaultModuleQuery = [](module_t &) -> bool { return false; };
ModuleQuery runquestDefaultModuleQuery = [](module_t &) -> bool { return true; };
/* clang-format off */
// clang-format off
ModuleQuery hasObase = p_opt.requested(s_obase) ? [](module_t &mod) -> bool { return mod.streamOutCnt == -1; } : defaultModuleQuery;
ModuleQuery hasNoOut = p_opt.requested(s_noOutput) ? [](module_t &mod) -> bool { return mod.streamOutCnt == 0; } : defaultModuleQuery;
ModuleQuery hasArb = p_opt.requested(s_arbIn) ? [](module_t &mod) -> bool { return mod.streamInCnt == -1; } : defaultModuleQuery;
ModuleQuery onlyFiles = p_opt.requested(s_onlyFiles) ? [](module_t &mod) -> bool { return mod.restrictions == FilesOnly; } : defaultModuleQuery;
ModuleQuery onlyFirst = p_opt.requested(s_onlyFirst) ? [](module_t &mod) -> bool { return mod.restrictions == OnlyFirst; } : defaultModuleQuery;
/* clang-format on */
// clang-format on
operatorPrintList(
[&](module_t &mod) { return (hasObase(mod) || hasArb(mod) || hasNoOut(mod) || onlyFiles(mod) || onlyFirst(mod)); });
......
......@@ -46,9 +46,8 @@ std::map<std::string, std::string> aliases;
std::string
module_t::toString()
{
std::string inp = streamInCnt > 0 ? std::to_string(streamInCnt) : "Arbitrary";
std::string out = streamOutCnt > 0 ? std::to_string(streamOutCnt) : "Output base";
std::string inp = streamInCnt >= 0 ? std::to_string(streamInCnt) : "Arbitrary";
std::string out = streamOutCnt >= 0 ? std::to_string(streamOutCnt) : "Output base";
std::string restriction = "none";
if (restrictions == OnlyFirst) restriction = "Can only be the first operator";
......@@ -63,28 +62,22 @@ module_t::toString()
static const char *
getOperatorName(const char *operatorCommand)
{
char *operatorName = nullptr;
if (operatorCommand)
{
if (operatorCommand[0] == '-') operatorCommand++;
const char *commapos = strchr(operatorCommand, ',');
const auto len = (commapos != nullptr) ? (size_t)(commapos - operatorCommand) : strlen(operatorCommand);
operatorName = (char *) malloc(len + 1);
char *operatorName = (char *) malloc(len + 1);
if (operatorName != nullptr)
{
memcpy(operatorName, operatorCommand, len);
operatorName[len] = '\0';
return operatorName;
}
else
{
return nullptr;
}
operatorName[len] = '\0';
}
return operatorName;
return nullptr;
}
/**
......
......@@ -23,11 +23,10 @@
#include <array>
#include <vector>
#define OBASE \
-1 // Obase uses input name as base name for files e.g 'test' gets used as test_001 test_002 which are created inside the
// operator
// Obase uses input name as base name for files e.g 'test' gets used as test_001 test_002 which are created inside the operator
#define OBASE -1
#define INTERNAL 0
#define EXPOSED 1
#define EXPOSED 1
/***
type definition for module functions loaded from a custom module
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment