aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Remember.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 80de7ae..f70217e 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -224,19 +224,24 @@ void Application::reset() {
224namespace { 224namespace {
225 225
226// replace special chars like ( ) and [ ] with \( \) and \[ \] 226// replace special chars like ( ) and [ ] with \( \) and \[ \]
227static string escapeRememberChars(string str) { 227string escapeRememberChars(const string& str) {
228 if (str.empty()) 228 if (str.empty())
229 return str; 229 return str;
230 230
231 str = FbTk::StringUtil::replaceString(str, "(", "\\("); 231 string escaped_str;
232 str = FbTk::StringUtil::replaceString(str, ")", "\\)"); 232 escaped_str.reserve(str.capacity());
233 str = FbTk::StringUtil::replaceString(str, "[", "\\["); 233
234 str = FbTk::StringUtil::replaceString(str, "]", "\\]"); 234 string::const_iterator i;
235 return str; 235 for (i = str.begin(); i != str.end(); i++) {
236} 236 switch (*i) {
237 case '(': case ')': case '[': case ']':
238 escaped_str += '\\';
239 default:
240 escaped_str += *i;
241 }
242 }
237 243
238bool getuint(const char *val, unsigned int &ret) { 244 return escaped_str;
239 return (sscanf(val, "%u", &ret) == 1);
240} 245}
241 246
242class RememberMenuItem : public FbTk::MenuItem { 247class RememberMenuItem : public FbTk::MenuItem {