aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2004-07-17 01:39:54 +0000
committernyamatongwe <devnull@localhost>2004-07-17 01:39:54 +0000
commit42dc5eadfc23669ecc3ed9bbfdf7b48c08796fa6 (patch)
treec274f9d6223eaa37634cb979047d7ba0890ddfcd
parent9e70fe41ad43fda3c1fa1d554334938f9bc1b47f (diff)
downloadscintilla-mirror-42dc5eadfc23669ecc3ed9bbfdf7b48c08796fa6.tar.gz
Patch from Bruce Dodson to help with some recursive property definitions,
substituting a blank for the recursive reference rather than leaving it.
-rw-r--r--include/PropSet.h3
-rw-r--r--src/PropSet.cxx10
2 files changed, 8 insertions, 5 deletions
diff --git a/include/PropSet.h b/include/PropSet.h
index 2766b542a..afd076c28 100644
--- a/include/PropSet.h
+++ b/include/PropSet.h
@@ -39,6 +39,7 @@ protected:
return ret;
}
static bool IncludesVar(const char *value, const char *key);
+
public:
PropSet *superPS;
PropSet();
@@ -49,7 +50,7 @@ public:
void SetMultiple(const char *s);
SString Get(const char *key);
SString GetExpanded(const char *key);
- SString Expand(const char *withVars, int maxExpands=100);
+ SString Expand(const char *withVars, int maxExpands=100, const char *blankVar=NULL);
int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename);
SString GetNewExpand(const char *keybase, const char *filename="");
diff --git a/src/PropSet.cxx b/src/PropSet.cxx
index 6c7145f02..b2265c597 100644
--- a/src/PropSet.cxx
+++ b/src/PropSet.cxx
@@ -451,12 +451,10 @@ bool PropSet::IncludesVar(const char *value, const char *key) {
SString PropSet::GetExpanded(const char *key) {
SString val = Get(key);
- if (IncludesVar(val.c_str(), key))
- return val;
- return Expand(val.c_str());
+ return Expand(val.c_str(), 100, key);
}
-SString PropSet::Expand(const char *withVars, int maxExpands) {
+SString PropSet::Expand(const char *withVars, int maxExpands, const char *blankVar) {
char *base = StringDup(withVars);
char *cpvar = strstr(base, "$(");
while (cpvar && (maxExpands > 0)) {
@@ -466,6 +464,8 @@ SString PropSet::Expand(const char *withVars, int maxExpands) {
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
char *var = StringDup(cpvar + 2, lenvar);
SString val = Get(var);
+ if (blankVar && (0 == strcmp(var, blankVar)))
+ val.clear(); // treat blankVar as an empty string (e.g. to block self-reference)
if (IncludesVar(val.c_str(), var))
break;
size_t newlenbase = strlen(base) + val.length() - lenvar;
@@ -588,6 +588,8 @@ SString PropSet::GetNewExpand(const char *keybase, const char *filename) {
int lenvar = cpendvar - cpvar - 2; // Subtract the $()
char *var = StringDup(cpvar + 2, lenvar);
SString val = GetWild(var, filename);
+ if (0 == strcmp(var, keybase))
+ val.clear(); // Self-references evaluate to empty string
size_t newlenbase = strlen(base) + val.length() - lenvar;
char *newbase = new char[newlenbase];
strncpy(newbase, base, cpvar - base);