Skip to content
Snippets Groups Projects
Commit 0c3e6258 authored by Julien Michel's avatar Julien Michel
Browse files

BUG: Fix trailing whitespace trimming in otbApplicationLauncherCommandLine...

BUG: Fix trailing whitespace trimming in otbApplicationLauncherCommandLine (kindly provided by Laurentiu Nicola)

std::string::find_last_not_of() returns a position, while std::string::substr takes an offset and a length. Fix the length computation and also add a comment regarding whether cleanStart must be checked.
parent 6eb64b68
No related branches found
No related tags found
No related merge requests found
......@@ -245,9 +245,10 @@ std::string CleanWord(const std::string & word)
// Suppress whitespace characters at the beginning and ending of the string
std::string::size_type cleanStart = word.find_first_not_of(" \t");
std::string::size_type cleanEnd = word.find_last_not_of(" \t\f\v\n\r");
// cleanStart == npos implies cleanEnd == npos
if (cleanEnd != std::string::npos)
{
res = word.substr(cleanStart,cleanEnd+1);
res = word.substr(cleanStart, cleanEnd - cleanStart + 1);
}
return res;
}
......@@ -265,7 +266,7 @@ int main(int argc, char* argv[])
}
std::vector<std::string> vexp;
std::string exp;
if (strcmp(argv[1], "-inxml") == 0)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment