Commit bee68e51 authored by Andrey Morozov's avatar Andrey Morozov

fixed several bugs in CommandLineParser

parent bf636e40
...@@ -208,8 +208,6 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const c ...@@ -208,8 +208,6 @@ CommandLineParser::CommandLineParser(int argc, const char* const argv[], const c
withNoKey = false; withNoKey = false;
hasValueThroughEq = false; hasValueThroughEq = false;
if(!isFound)
printf("The current parameter is not defined: %s\n", curName.c_str());
isFound = false; isFound = false;
} }
} }
...@@ -273,6 +271,7 @@ template<typename _Tp> ...@@ -273,6 +271,7 @@ template<typename _Tp>
for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]); for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]);
cout << " "; cout << " ";
buf = "";
if (keysVector[0] != "") if (keysVector[0] != "")
{ {
buf = "-" + keysVector[0]; buf = "-" + keysVector[0];
...@@ -294,13 +293,19 @@ template<typename _Tp> ...@@ -294,13 +293,19 @@ template<typename _Tp>
while (true) while (true)
{ {
bool tr = (buf.length() >= col_d-2) ? true: false; bool tr = (buf.length() > col_d-2) ? true: false;
int pos; int pos;
if (tr) if (tr)
{ {
pos = buf.find_first_of(' '); pos = buf.find_first_of(' ');
while (buf.find_first_of(' ', pos + 1 ) > 0 && pos < col_d-2) pos = buf.find_first_of(' ', pos + 1); while (true)
{
if (buf.find_first_of(' ', pos + 1 ) < col_d-2 && buf.find_first_of(' ', pos + 1 ) != std::string::npos)
pos = buf.find_first_of(' ', pos + 1);
else
break;
}
pos++; pos++;
cout << setw(col_d-2) << left << buf.substr(0, pos) << endl; cout << setw(col_d-2) << left << buf.substr(0, pos) << endl;
} }
......
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