ref: refs/heads/master
commit 898ea389d17bd247ee48f02269d9b0ddd45773af
Author: Michael Schroeder
Date: Wed Jul 15 15:12:47 2009 +0200
- support SEARCH_STRINGSTART and SEARCH_STRINGEND
---
src/repo.h | 14 ++++++++------
src/repodata.c | 28 ++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/src/repo.h b/src/repo.h
index 2f7c49a..b66631b 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -153,12 +153,14 @@ typedef struct _KeyValue {
} KeyValue;
/* search matcher flags */
-#define SEARCH_STRINGMASK 15
-#define SEARCH_STRING 1
-#define SEARCH_SUBSTRING 2
-#define SEARCH_GLOB 3
-#define SEARCH_REGEX 4
-#define SEARCH_ERROR 5
+#define SEARCH_STRINGMASK 15
+#define SEARCH_STRING 1
+#define SEARCH_STRINGSTART 2
+#define SEARCH_STRINGEND 3
+#define SEARCH_SUBSTRING 4
+#define SEARCH_GLOB 5
+#define SEARCH_REGEX 6
+#define SEARCH_ERROR 15
#define SEARCH_NOCASE (1<<7)
/* iterator control */
diff --git a/src/repodata.c b/src/repodata.c
index 61dfe12..5178fe0 100644
--- a/src/repodata.c
+++ b/src/repodata.c
@@ -931,6 +931,7 @@ datamatcher_free(Datamatcher *ma)
int
datamatcher_match(Datamatcher *ma, const char *str)
{
+ int l;
switch ((ma->flags & SEARCH_STRINGMASK))
{
case SEARCH_SUBSTRING:
@@ -957,6 +958,33 @@ datamatcher_match(Datamatcher *ma, const char *str)
return 0;
}
break;
+ case SEARCH_STRINGSTART:
+ if (ma->flags & SEARCH_NOCASE)
+ {
+ if (strncasecmp(ma->match, str, strlen(ma->match)))
+ return 0;
+ }
+ else
+ {
+ if (strncmp(ma->match, str, strlen(ma->match)))
+ return 0;
+ }
+ break;
+ case SEARCH_STRINGEND:
+ l = strlen(str) - strlen(ma->match);
+ if (l < 0)
+ return 0;
+ if (ma->flags & SEARCH_NOCASE)
+ {
+ if (strcasecmp(ma->match, str + l))
+ return 0;
+ }
+ else
+ {
+ if (strcmp(ma->match, str + l))
+ return 0;
+ }
+ break;
case SEARCH_GLOB:
if (fnmatch(ma->match, str, (ma->flags & SEARCH_NOCASE) ? FNM_CASEFOLD : 0))
return 0;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org