diff options
| author | nyamatongwe <unknown> | 2001-02-03 01:44:58 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2001-02-03 01:44:58 +0000 | 
| commit | 42498c7486b343ea84ca1f677934f9c6095b8071 (patch) | |
| tree | 550b020541e503de0ee78d7692dbe90677afed56 | |
| parent | e0f60300ff7bc4d06f863ba084e6be80bb8faae8 (diff) | |
| download | scintilla-mirror-42498c7486b343ea84ca1f677934f9c6095b8071.tar.gz | |
Refactored detection of self reference within variable to separate function
and added a comment.
| -rw-r--r-- | src/PropSet.cxx | 31 | 
1 files changed, 20 insertions, 11 deletions
| diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 61aa7e169..368d2a484 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -94,19 +94,26 @@ SString PropSet::Get(const char *key) {  	}  } +static bool IncludesVar(const char *value, const char *key) { +	const char *var = strstr(value, "$("); +	while (var) { +		if (isprefix(var+2, key) && (var[2 + strlen(key)] == ')')) { +			// Found $(key) which would lead to an infinite loop so exit +			return true; +		} +		var = strstr(var + 2, ")"); +		if (var) +			var = strstr(var + 1, "$("); +	} +	return false; +} +  SString PropSet::GetExpanded(const char *key) {  	SString val = Get(key); -    const char *var = strstr(val.c_str(), "$("); -    while (var) { -        if (isprefix(var+2, key) && (var[2 + strlen(key)] == ')')) { -            // Found $(key) which would lead to an infinite loop so exit -            return val; -        } -        var = strstr(var + 2, ")"); -        if (var) -            var = strstr(var + 1, "$("); -    } -	return Expand(val.c_str()); +	if (IncludesVar(val.c_str(), key))  +		return val; +	else +		return Expand(val.c_str());  }  SString PropSet::Expand(const char *withvars) { @@ -226,6 +233,8 @@ SString PropSet::GetWild(const char *keybase, const char *filename) {  	}  } +// GetNewExpand does not use Expand as it has to use GetWild with the filename for each  +// variable reference found.  SString PropSet::GetNewExpand(const char *keybase, const char *filename) {  	char *base = StringDup(GetWild(keybase, filename).c_str());  	char *cpvar = strstr(base, "$("); | 
