From d12e0838a2fd9622f3aac8c1cc7646ddbdc3aea1 Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 7 Dec 2010 21:06:26 +0000 Subject: [PATCH] compatibility with wxWdigets 2.9+: work around a bug in wx 2.9.1 (should be fixed in newer releases) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1531 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/util/string.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/string.cpp b/src/util/string.cpp index a24d8c39..8b02ace6 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -141,7 +141,7 @@ bool is_word_end_punctuation(Char c) { // ----------------------------------------------------------------------------- : Caseing /// Quick check to see if the substring starting at the given iterator is equal to some given string -bool is_substr(const String& s, String::iterator it, const Char* cmp) { +bool is_substr(const String& s, String::const_iterator it, const Char* cmp) { while (it != s.end() && *cmp != 0) { if (*it++ != *cmp++) return false; } @@ -156,7 +156,9 @@ String capitalize(const String& s) { after_space = true; } else if (after_space) { after_space = false; - if (it != s.begin() && + // See http://trac.wxwidgets.org/ticket/12594 + //if (it != s.begin() && + if (s.begin() != it && (is_substr(result,it,_("is ")) || is_substr(result,it,_("the ")) || is_substr(result,it,_("in ")) || is_substr(result,it,_("of ")) || is_substr(result,it,_("to ")) || is_substr(result,it,_("at ")) || @@ -390,7 +392,7 @@ bool is_substr(const String& str, size_t pos, const Char* cmp) { return *cmp == _('\0'); } bool is_substr(const String& str, size_t pos, const String& cmp) { - return is_substr(str, pos, cmp.c_str()); + return str.size() >= cmp.size() + pos && str.compare(pos, cmp.size(), cmp) == 0; } @@ -401,7 +403,7 @@ bool is_substr_i(const String& str, size_t pos, const Char* cmp) { return *cmp == _('\0'); } bool is_substr_i(const String& str, size_t pos, const String& cmp) { - return is_substr_i(str, pos, cmp.c_str()); + return is_substr_i(str, pos, static_cast(cmp.c_str())); } bool cannocial_name_compare(const String& as, const Char* b) { @@ -437,7 +439,7 @@ String regex_escape(Char c) { /// Escape a string for use in regular expressions String regex_escape(const String& s) { String ret; - FOR_EACH_CONST(c,s) ret += regex_escape(c); + FOR_EACH_CONST(c,s) ret += regex_escape(static_cast(c)); return ret; }