Commit c935793a authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: no dictionary variable and function expansion when discarding entry

- the 'protect' inputMode is used to supply defaults.
  If an entry already exists, it should act as a no-op without any
  side-effects whatsoever.
parent 4eb178be
......@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
<< endl;
}
int oldFlag = entry::disableFunctionEntries;
const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
......
......@@ -464,7 +464,7 @@ int main(int argc, char *argv[])
<< endl;
}
int oldFlag = entry::disableFunctionEntries;
const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
......
......@@ -500,7 +500,7 @@ int main(int argc, char *argv[])
IOobjectList objects(runTime, runTime.timeName());
int oldFlag = entry::disableFunctionEntries;
const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
......
......@@ -283,15 +283,21 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
}
else if (functionEntries::inputModeEntry::protect())
{
// read and discard the entry
// Read and discard the entry.
// Disable function/variable expansion to avoid side-effects
const int oldFlag = entry::disableFunctionEntries;
entry::disableFunctionEntries = 1;
if (nextToken == token::BEGIN_BLOCK)
{
dictionaryEntry dummy(keyword, parentDict, is);
dictionaryEntry dummy("dummy", parentDict, is);
}
else
{
primitiveEntry dummy(keyword, parentDict, is);
primitiveEntry dummy("dummy", parentDict, is);
}
entry::disableFunctionEntries = oldFlag;
return true;
}
else if (functionEntries::inputModeEntry::error())
......
Supports Markdown
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