STYLE: drop dubious string::expand recursion

- was used for on-the-fly, but not needed anymore
This commit is contained in:
Mark Olesen
2011-02-23 15:18:01 +01:00
parent 97a15a8b06
commit 5ab254d5b0
2 changed files with 6 additions and 15 deletions

View File

@ -93,8 +93,7 @@ Foam::string& Foam::string::replaceAll
} }
// Expand all occurences of environment variables and initial tilde sequences Foam::string& Foam::string::expand(const bool allowEmpty)
Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
{ {
size_type begVar = 0; size_type begVar = 0;
@ -134,20 +133,15 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
if (endVar != npos && endVar != begVar) if (endVar != npos && endVar != begVar)
{ {
string varName = substr const string varName = substr
( (
begVar + 1 + delim, begVar + 1 + delim,
endVar - begVar - 2*delim endVar - begVar - 2*delim
); );
string varValue = getEnv(varName); const string varValue = getEnv(varName);
if (varValue.size()) if (varValue.size())
{ {
if (recurse)
{
varValue.expand(recurse, allowEmptyVar);
}
std::string::replace std::string::replace
( (
begVar, begVar,
@ -156,7 +150,7 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
); );
begVar += varValue.size(); begVar += varValue.size();
} }
else if (allowEmptyVar) else if (allowEmpty)
{ {
std::string::replace std::string::replace
( (

View File

@ -180,13 +180,10 @@ public:
// - leading "~user" : home directory for specified user // - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory // - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
// //
// Any unknown entries are removed silently if allowEmpty is true
// \sa // \sa
// Foam::findEtcFile // Foam::findEtcFile
string& expand string& expand(const bool allowEmpty = false);
(
const bool recurse=false,
const bool allowEmptyVar = false
);
//- Remove repeated characters returning true if string changed //- Remove repeated characters returning true if string changed
bool removeRepeated(const char); bool removeRepeated(const char);