From 2f68c48eb0815d89447841a06f05b43adf115101 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 9 Mar 2009 11:23:55 +0100 Subject: [PATCH] make SearchEngine::CaseSensitive regex flag --- src/search_engine.cpp | 28 ++++++++++++++-------------- src/search_engine.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/search_engine.cpp b/src/search_engine.cpp index be56f070..5d8b4429 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -40,7 +40,7 @@ size_t SearchEngine::SearchButton = 15; size_t SearchEngine::ResetButton = 16; bool SearchEngine::MatchToPattern = 1; -bool SearchEngine::CaseSensitive = 0; +int SearchEngine::CaseSensitive = REG_ICASE; void SearchEngine::Init() { @@ -178,8 +178,8 @@ void SearchEngine::EnterPressed() } case 13: { - CaseSensitive = !CaseSensitive; - *w->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (CaseSensitive ? "Yes" : "No"); + CaseSensitive = !CaseSensitive * REG_ICASE; + *w->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No"); break; } case 15: @@ -371,7 +371,7 @@ void SearchEngine::Prepare() *w->at(11).first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist"); *w->at(12).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (MatchToPattern ? NormalMode : StrictMode); - *w->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (CaseSensitive ? "Yes" : "No"); + *w->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (!CaseSensitive ? "Yes" : "No"); *w->at(15).first << "Search"; *w->at(16).first << "Reset"; @@ -484,7 +484,7 @@ void SearchEngine::Search() if (!s.Any().empty()) { - if (regcomp(&rx, s.Any().c_str(), ((CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) | Config.regex_type) == 0) + if (regcomp(&rx, s.Any().c_str(), CaseSensitive | Config.regex_type) == 0) { any_found = regexec(&rx, copy.GetArtist().c_str(), 0, 0, 0) == 0 @@ -502,55 +502,55 @@ void SearchEngine::Search() if (found && !s.GetArtist().empty()) { - if (regcomp(&rx, s.GetArtist().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetArtist().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetArtist().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetTitle().empty()) { - if (regcomp(&rx, s.GetTitle().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetTitle().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetTitle().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetAlbum().empty()) { - if (regcomp(&rx, s.GetAlbum().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetAlbum().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetAlbum().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetFile().empty()) { - if (regcomp(&rx, s.GetFile().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetFile().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetName().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetComposer().empty()) { - if (regcomp(&rx, s.GetComposer().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetComposer().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetComposer().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetPerformer().empty()) { - if (regcomp(&rx, s.GetPerformer().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetPerformer().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetPerformer().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetGenre().empty()) { - if (regcomp(&rx, s.GetGenre().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetGenre().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetGenre().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetYear().empty()) { - if (regcomp(&rx, s.GetYear().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetYear().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetYear().c_str(), 0, 0, 0) == 0; regfree(&rx); } if (found && !s.GetComment().empty()) { - if (regcomp(&rx, s.GetComment().c_str(), (CaseSensitive ? 0 : REG_ICASE) | Config.regex_type) == 0) + if (regcomp(&rx, s.GetComment().c_str(), CaseSensitive | Config.regex_type) == 0) found = regexec(&rx, copy.GetComment().c_str(), 0, 0, 0) == 0; regfree(&rx); } diff --git a/src/search_engine.h b/src/search_engine.h index 67410d76..8f049f79 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -77,7 +77,7 @@ class SearchEngine : public Screen< Menu< std::pair > > SearchPattern itsPattern; static bool MatchToPattern; - static bool CaseSensitive; + static int CaseSensitive; }; extern SearchEngine *mySearcher;