summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ec5c3ee)
raw | patch | inline | side by side (parent: ec5c3ee)
author | Max Kellermann <max@duempel.org> | |
Wed, 10 Dec 2008 18:47:25 +0000 (19:47 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 10 Dec 2008 18:47:25 +0000 (19:47 +0100) |
Provide the new function match_line() which searches a string for a
needle (ignoring case). This wraps the non-standard function
strcasestr().
needle (ignoring case). This wraps the non-standard function
strcasestr().
src/Makefile.am | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/match.c | [new file with mode: 0644] | patch | blob |
src/match.h | [new file with mode: 0644] | patch | blob |
diff --git a/src/Makefile.am b/src/Makefile.am
index ac34b856b3a5fd97192a806bed4955eab6d9bed1..a53e5d0cadf4b3d8a0f83cb50a02cb0b71d2834c 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
colors.h\
support.h\
charset.h \
+ match.h \
wreadln.h\
strfsong.h\
utils.h\
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 ea4b3c28e9366edbb8fe09ddcec0548dab305ef2..010deb86002916951dbee3572d35112f9d13ee9d 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
#include "config.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
+#include "match.h"
#include "command.h"
#include "colors.h"
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;
}
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
--- /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
--- /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