diff options
-rw-r--r-- | lexlib/LexerBase.cxx | 2 | ||||
-rw-r--r-- | lexlib/PropSetSimple.cxx | 28 | ||||
-rw-r--r-- | lexlib/PropSetSimple.h | 2 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 2 |
4 files changed, 19 insertions, 15 deletions
diff --git a/lexlib/LexerBase.cxx b/lexlib/LexerBase.cxx index 80558504f..f9e6292a1 100644 --- a/lexlib/LexerBase.cxx +++ b/lexlib/LexerBase.cxx @@ -62,7 +62,7 @@ const char * SCI_METHOD LexerBase::DescribeProperty(const char *) { Sci_Position SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) { const char *valOld = props.Get(key); if (strcmp(val, valOld) != 0) { - props.Set(key, val); + props.Set(key, val, strlen(key), strlen(val)); return 0; } else { return -1; diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx index cbcbac5bd..ba76019be 100644 --- a/lexlib/PropSetSimple.cxx +++ b/lexlib/PropSetSimple.cxx @@ -17,27 +17,31 @@ using namespace Scintilla; +namespace { + typedef std::map<std::string, std::string> mapss; +mapss *PropsFromPointer(void *impl) { + return static_cast<mapss *>(impl); +} + +} + PropSetSimple::PropSetSimple() { mapss *props = new mapss; impl = static_cast<void *>(props); } PropSetSimple::~PropSetSimple() { - mapss *props = static_cast<mapss *>(impl); + mapss *props = PropsFromPointer(impl); delete props; impl = 0; } -void PropSetSimple::Set(const char *key, const char *val, int lenKey, int lenVal) { - mapss *props = static_cast<mapss *>(impl); +void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) { + mapss *props = PropsFromPointer(impl); if (!*key) // Empty keys are not supported return; - if (lenKey == -1) - lenKey = static_cast<int>(strlen(key)); - if (lenVal == -1) - lenVal = static_cast<int>(strlen(val)); (*props)[std::string(key, lenKey)] = std::string(val, lenVal); } @@ -53,10 +57,10 @@ void PropSetSimple::Set(const char *keyVal) { endVal++; const char *eqAt = strchr(keyVal, '='); if (eqAt) { - Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal), - static_cast<int>(endVal - eqAt - 1)); + Set(keyVal, eqAt + 1, eqAt-keyVal, + endVal - eqAt - 1); } else if (*keyVal) { // No '=' so assume '=1' - Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1); + Set(keyVal, "1", endVal-keyVal, 1); } } @@ -71,7 +75,7 @@ void PropSetSimple::SetMultiple(const char *s) { } const char *PropSetSimple::Get(const char *key) const { - mapss *props = static_cast<mapss *>(impl); + mapss *props = PropsFromPointer(impl); mapss::const_iterator keyPos = props->find(std::string(key)); if (keyPos != props->end()) { return keyPos->second.c_str(); @@ -86,7 +90,7 @@ const char *PropSetSimple::Get(const char *key) const { // for that, through a recursive function and a simple chain of pointers. struct VarChain { - VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} + VarChain(const char *var_=nullptr, const VarChain *link_= nullptr): var(var_), link(link_) {} bool contains(const char *testVar) const { return (var && (0 == strcmp(var, testVar))) diff --git a/lexlib/PropSetSimple.h b/lexlib/PropSetSimple.h index 91b170df3..ba4e42446 100644 --- a/lexlib/PropSetSimple.h +++ b/lexlib/PropSetSimple.h @@ -16,7 +16,7 @@ class PropSetSimple { public: PropSetSimple(); virtual ~PropSetSimple(); - void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1); + void Set(const char *key, const char *val, size_t lenKey, size_t lenVal); void SetMultiple(const char *); const char *Get(const char *key) const; int GetExpanded(const char *key, char *result) const; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 302c178e2..ad6366097 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -703,7 +703,7 @@ const char *LexState::DescribeProperty(const char *name) { } void LexState::PropSet(const char *key, const char *val) { - props.Set(key, val); + props.Set(key, val, strlen(key), strlen(val)); if (instance) { const Sci_Position firstModification = instance->PropertySet(key, val); if (firstModification >= 0) { |