negEntry: Supporting negation of already negative quantities

This commit is contained in:
Will Bainbridge
2018-12-18 11:51:45 +00:00
parent 5925868fb7
commit 7fc61d7eb7

View File

@ -85,11 +85,20 @@ Foam::string Foam::functionEntries::negEntry::negateVariable
{ {
const token variable(ePtr->stream()); const token variable(ePtr->stream());
// Negate variable // Convert to a string
OStringStream os(is.format()); OStringStream os(is.format());
os << '-' << variable; os << variable;
const string str(os.str());
return os.str(); // Negate
if (str[0] == '-')
{
return str(1, str.size() - 1);
}
else
{
return '-' + str;
}
} }
else else
{ {