aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib
diff options
context:
space:
mode:
Diffstat (limited to 'lexlib')
-rw-r--r--lexlib/PropSetSimple.cxx23
-rw-r--r--lexlib/PropSetSimple.h1
2 files changed, 7 insertions, 17 deletions
diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx
index c0ec59459..9197fb642 100644
--- a/lexlib/PropSetSimple.cxx
+++ b/lexlib/PropSetSimple.cxx
@@ -141,30 +141,21 @@ static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, i
return maxExpands;
}
-char *PropSetSimple::Expanded(const char *key) const {
+int PropSetSimple::GetExpanded(const char *key, char *result) const {
std::string val = Get(key);
ExpandAllInPlace(*this, val, 100, VarChain(key));
- char *ret = new char [val.size() + 1];
- strcpy(ret, val.c_str());
- return ret;
-}
-
-int PropSetSimple::GetExpanded(const char *key, char *result) const {
- char *val = Expanded(key);
- const int n = static_cast<int>(strlen(val));
+ const int n = static_cast<int>(val.size());
if (result) {
- strcpy(result, val);
+ strcpy(result, val.c_str());
}
- delete []val;
return n; // Not including NUL
}
int PropSetSimple::GetInt(const char *key, int defaultValue) const {
- char *val = Expanded(key);
- if (val) {
- int retVal = val[0] ? atoi(val) : defaultValue;
- delete []val;
- return retVal;
+ std::string val = Get(key);
+ ExpandAllInPlace(*this, val, 100, VarChain(key));
+ if (!val.empty()) {
+ return atoi(val.c_str());
}
return defaultValue;
}
diff --git a/lexlib/PropSetSimple.h b/lexlib/PropSetSimple.h
index b79873720..8ca741f03 100644
--- a/lexlib/PropSetSimple.h
+++ b/lexlib/PropSetSimple.h
@@ -21,7 +21,6 @@ public:
void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void SetMultiple(const char *);
const char *Get(const char *key) const;
- char *Expanded(const char *key) const;
int GetExpanded(const char *key, char *result) const;
int GetInt(const char *key, int defaultValue=0) const;
};