aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/list_window.c6
-rw-r--r--src/match.c28
-rw-r--r--src/match.h31
4 files changed, 64 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ac34b856b..a53e5d0ca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ ncmpc_headers = \
colors.h\
support.h\
charset.h \
+ match.h \
wreadln.h\
strfsong.h\
utils.h\
@@ -67,6 +68,7 @@ ncmpc_SOURCES = \
colors.c\
support.c\
charset.c \
+ match.c \
wreadln.c\
strfsong.c\
utils.c\
diff --git a/src/list_window.c b/src/list_window.c
index ea4b3c28e..010deb860 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -20,7 +20,7 @@
#include "config.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
+#include "match.h"
#include "command.h"
#include "colors.h"
@@ -223,7 +223,7 @@ list_window_find(struct list_window *lw,
do {
while ((label = callback(i,&h,callback_data))) {
- if (str && label && strcasestr(label, str)) {
+ if (str && label && match_line(label, str)) {
lw->selected = i;
return true;
}
@@ -259,7 +259,7 @@ list_window_rfind(struct list_window *lw,
do {
while (i >= 0 && (label = callback(i,&h,callback_data))) {
- if( str && label && strcasestr(label, str) ) {
+ if( str && label && match_line(label, str) ) {
lw->selected = i;
return true;
}
diff --git a/src/match.c b/src/match.c
new file mode 100644
index 000000000..e414d859d
--- /dev/null
+++ b/src/match.c
@@ -0,0 +1,28 @@
+/*
+ * (c) 2008 Max Kellermann <max@duempel.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "match.h"
+#include "support.h"
+
+#include <string.h>
+
+bool
+match_line(const char *line, const char *needle)
+{
+ return strcasestr(line, needle) != NULL;
+}
diff --git a/src/match.h b/src/match.h
new file mode 100644
index 000000000..1bb6ca33d
--- /dev/null
+++ b/src/match.h
@@ -0,0 +1,31 @@
+/*
+ * (c) 2008 Max Kellermann <max@duempel.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef MATCH_H
+#define MATCH_H
+
+#include <stdbool.h>
+
+/**
+ * Checks whether the specified line matches the search string. Case
+ * is ignored.
+ */
+bool
+match_line(const char *line, const char *needle);
+
+#endif