diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index c958b8f94961999611ed53e64edc63395107c1e0..bc0ffb9c09bbb0cc068072180ee72282bac25b1a 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -117,11 +117,12 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) if (keyword.size() > 2 && keyword[1] == token::BEGIN_BLOCK) { // Recursive substitution mode. Replace between {} with - // expansion. + // expansion and then let standard variable expansion deal + // with rest. string s(keyword(2, keyword.size()-3)); - // Substitute dictionary and environment variables. Allow + // Substitute dictionary and environment variables. Do not allow // empty substitutions. - stringOps::inplaceExpand(s, parentDict, true, true); + stringOps::inplaceExpand(s, parentDict, true, false); keyword.std::string::replace(1, keyword.size()-1, s); } parentDict.substituteScopedKeyword(keyword); diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 0566b8f350463d8cf0873f8c3c831a5156f10aad..779709e4a06b326abd2bc549e05045e79615adbc 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -47,13 +47,11 @@ bool Foam::primitiveEntry::expandVariable { if (w.size() > 2 && w[0] == '$' && w[1] == token::BEGIN_BLOCK) { - // Recursive substitution mode. Replace between {} with - // expansion. + // Recursive substitution mode. Replace between {} with expansion. string s(w(2, w.size()-3)); - // Substitute dictionary and environment variables. Allow + // Substitute dictionary and environment variables. Do not allow // empty substitutions. - stringOps::inplaceExpand(s, dict, true, true); - + stringOps::inplaceExpand(s, dict, true, false); string newW(w); newW.std::string::replace(1, newW.size()-1, s); @@ -83,6 +81,15 @@ bool Foam::primitiveEntry::expandVariable if (envStr.empty()) { + FatalIOErrorIn + ( + "primitiveEntry::expandVariable" + "(const string&, const dictionary&", + dict + ) << "Illegal dictionary entry or environment variable name " + << varName << endl << "Valid dictionary entries are " + << dict.toc() << exit(FatalIOError); + return false; } append(tokenList(IStringStream('(' + envStr + ')')()));