From 8588402376c57890deb7cd77f56bef4337f00b63 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 2 Jan 2007 03:12:24 +0000 Subject: don't escape regex metacharacters when writing apps file --- ChangeLog | 4 ++++ src/ClientPattern.cc | 7 +------ src/Remember.cc | 11 ++++++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e2ca91..93e13ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*07/01/02: + * Don't escape regular expression metacharacters in apps file, bug + #1595497 (Mark) + Remember.cc ClientPattern.cc *07/01/01: * Happy New Year! * Don't draw style's menu icon pixmap underneath the program's icon (Mark) diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index d2c809c..339092d 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc @@ -170,11 +170,6 @@ string ClientPattern::toString() const { for (; it != it_end; ++it) { pat.append(" ("); - // replace special chars like ( ) and [ ] with \( \) and \[ \] - string orig = FbTk::StringUtil::replaceString((*it)->orig, "(", "\\("); - orig = FbTk::StringUtil::replaceString(orig, ")", "\\)"); - orig = FbTk::StringUtil::replaceString(orig, "[", "\\["); - orig = FbTk::StringUtil::replaceString(orig, "]", "\\]"); switch ((*it)->prop) { case NAME: @@ -190,7 +185,7 @@ string ClientPattern::toString() const { pat.append("role="); } - pat.append(orig); + pat.append((*it)->orig); pat.append(")"); } diff --git a/src/Remember.cc b/src/Remember.cc index 6f41528..d39cd3e 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -302,8 +302,17 @@ Application* Remember::find(WinClient &winclient) { Application * Remember::add(WinClient &winclient) { ClientPattern *p = new ClientPattern(); Application *app = new Application(false); + // by default, we match against the WMClass of a window. - p->addTerm(p->getProperty(ClientPattern::NAME, winclient), ClientPattern::NAME); + string win_name = p->getProperty(ClientPattern::NAME, winclient); + + // replace special chars like ( ) and [ ] with \( \) and \[ \] + win_name = FbTk::StringUtil::replaceString(win_name, "(", "\\("); + win_name = FbTk::StringUtil::replaceString(win_name, ")", "\\)"); + win_name = FbTk::StringUtil::replaceString(win_name, "[", "\\["); + win_name = FbTk::StringUtil::replaceString(win_name, "]", "\\]"); + + p->addTerm(win_name, ClientPattern::NAME); m_clients[&winclient] = app; p->addMatch(); m_pats->push_back(make_pair(p, app)); -- cgit v0.11.2