diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-09-08 19:45:33 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-09-08 19:45:33 (GMT) |
commit | 7a149626e60ef089ab3dcdd9b4fceb07250f8e13 (patch) | |
tree | 3cfd78c84d0137da40b7d5286e7f56ef71327a35 | |
parent | 48cc67965b22801b920317b2778639adeeb5c9ac (diff) | |
download | fluxbox_paul-7a149626e60ef089ab3dcdd9b4fceb07250f8e13.zip fluxbox_paul-7a149626e60ef089ab3dcdd9b4fceb07250f8e13.tar.bz2 |
improved 'escapeRememberChars()' routine by traversing the string only once
removed obsolete 'getuint()' function
-rw-r--r-- | src/Remember.cc | 23 |
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() { | |||
224 | namespace { | 224 | namespace { |
225 | 225 | ||
226 | // replace special chars like ( ) and [ ] with \( \) and \[ \] | 226 | // replace special chars like ( ) and [ ] with \( \) and \[ \] |
227 | static string escapeRememberChars(string str) { | 227 | string 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 | ||
238 | bool getuint(const char *val, unsigned int &ret) { | 244 | return escaped_str; |
239 | return (sscanf(val, "%u", &ret) == 1); | ||
240 | } | 245 | } |
241 | 246 | ||
242 | class RememberMenuItem : public FbTk::MenuItem { | 247 | class RememberMenuItem : public FbTk::MenuItem { |