projects
/
platform
/
upstream
/
libsolv.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ff7d592
)
- support SEARCH_STRINGSTART and SEARCH_STRINGEND
author
Michael Schroeder
<mls@suse.de>
Wed, 15 Jul 2009 13:12:47 +0000
(15:12 +0200)
committer
Michael Schroeder
<mls@suse.de>
Wed, 15 Jul 2009 13:12:47 +0000
(15:12 +0200)
src/repo.h
patch
|
blob
|
history
src/repodata.c
patch
|
blob
|
history
diff --git
a/src/repo.h
b/src/repo.h
index
2f7c49a
..
b66631b
100644
(file)
--- a/
src/repo.h
+++ b/
src/repo.h
@@
-153,12
+153,14
@@
typedef struct _KeyValue {
} KeyValue;
/* search matcher flags */
} 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 */
#define SEARCH_NOCASE (1<<7)
/* iterator control */
diff --git
a/src/repodata.c
b/src/repodata.c
index
61dfe12
..
5178fe0
100644
(file)
--- 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
datamatcher_match(Datamatcher *ma, const char *str)
{
+ int l;
switch ((ma->flags & SEARCH_STRINGMASK))
{
case SEARCH_SUBSTRING:
switch ((ma->flags & SEARCH_STRINGMASK))
{
case SEARCH_SUBSTRING:
@@
-957,6
+958,33
@@
datamatcher_match(Datamatcher *ma, const char *str)
return 0;
}
break;
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;
case SEARCH_GLOB:
if (fnmatch(ma->match, str, (ma->flags & SEARCH_NOCASE) ? FNM_CASEFOLD : 0))
return 0;