Commit f304c7e8 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 e082be56
...@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) ...@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
<< endl; << endl;
} }
int oldFlag = entry::disableFunctionEntries; const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries) if (!enableEntries)
{ {
// By default disable dictionary expansion for fields // By default disable dictionary expansion for fields
......
...@@ -464,7 +464,7 @@ int main(int argc, char *argv[]) ...@@ -464,7 +464,7 @@ int main(int argc, char *argv[])
<< endl; << endl;
} }
int oldFlag = entry::disableFunctionEntries; const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries) if (!enableEntries)
{ {
// By default disable dictionary expansion for fields // By default disable dictionary expansion for fields
......
...@@ -500,7 +500,7 @@ int main(int argc, char *argv[]) ...@@ -500,7 +500,7 @@ int main(int argc, char *argv[])
IOobjectList objects(runTime, runTime.timeName()); IOobjectList objects(runTime, runTime.timeName());
int oldFlag = entry::disableFunctionEntries; const int oldFlag = entry::disableFunctionEntries;
if (!enableEntries) if (!enableEntries)
{ {
// By default disable dictionary expansion for fields // By default disable dictionary expansion for fields
......
...@@ -283,15 +283,21 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) ...@@ -283,15 +283,21 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
} }
else if (functionEntries::inputModeEntry::protect()) 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) if (nextToken == token::BEGIN_BLOCK)
{ {
dictionaryEntry dummy(keyword, parentDict, is); dictionaryEntry dummy("dummy", parentDict, is);
} }
else else
{ {
primitiveEntry dummy(keyword, parentDict, is); primitiveEntry dummy("dummy", parentDict, is);
} }
entry::disableFunctionEntries = oldFlag;
return true; return true;
} }
else if (functionEntries::inputModeEntry::error()) 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