Author: jkupec
Date: Wed Apr 9 16:09:26 2008
New Revision: 9481
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9481&view=rev
Log:
- enable regex matching in Dataiterator
Modified:
trunk/sat-solver/src/repo.h
trunk/sat-solver/src/repodata.c
Modified: trunk/sat-solver/src/repo.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.h?rev=9481&r1=9480&r2=9481&view=diff
==============================================================================
--- trunk/sat-solver/src/repo.h (original)
+++ trunk/sat-solver/src/repo.h Wed Apr 9 16:09:26 2008
@@ -13,6 +13,8 @@
#ifndef SATSOLVER_REPO_H
#define SATSOLVER_REPO_H
+#include
+
#include "pooltypes.h"
#include "pool.h"
#if 0
@@ -188,6 +190,8 @@
unsigned flags;
unsigned state;
KeyValue kv;
+ regex_t regex;
+ int regex_err;
} Dataiterator;
/* Use these like:
Modified: trunk/sat-solver/src/repodata.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repodata.c?rev=9481&r1=9480&r2=9481&view=diff
==============================================================================
--- trunk/sat-solver/src/repodata.c (original)
+++ trunk/sat-solver/src/repodata.c Wed Apr 9 16:09:26 2008
@@ -667,7 +667,35 @@
di->data = repo->repodata + repo->nrepodata - 1;
di->state = 0;
}
+
di->match = match;
+ if ((di->flags & SEARCH_STRINGMASK) == SEARCH_REGEX)
+ {
+ if (di->match)
+ {
+ /* We feed multiple lines eventually (e.g. authors or descriptions),
+ so set REG_NEWLINE. */
+ di->regex_err =
+ regcomp(&di->regex, di->match,
+ REG_EXTENDED | REG_NOSUB | REG_NEWLINE
+ | ((di->flags & SEARCH_NOCASE) ? REG_ICASE : 0));
+#if 0
+ if (di->regex_err != 0)
+ {
+ fprintf(stderr, "Given regex failed to compile: %s\n", di->match);
+ fprintf(stderr, "regcomp error code: %d\n", di->regex_err);
+ exit(1);
+ }
+#else
+ }
+ else
+ {
+ di->flags |= (di->flags & SEARCH_STRINGMASK) | SEARCH_STRING;
+ di->regex_err = 0;
+#endif
+ }
+ }
+
di->keyname = keyname;
static Id zeroid = 0;
di->keyp = &zeroid;
@@ -728,11 +756,10 @@
if (fnmatch(match, kv->str, (flags & SEARCH_NOCASE) ? FNM_CASEFOLD : 0))
return 0;
break;
-#if 0
case SEARCH_REGEX:
if (regexec((const regex_t *)vmatch, kv->str, 0, NULL, 0))
return 0;
-#endif
+ break;
default:
return 0;
}
@@ -743,7 +770,10 @@
static int
dataiterator_match_int(Dataiterator *di)
{
- return dataiterator_match_int_real(di, di->flags, di->match);
+ if ((di->flags & SEARCH_STRINGMASK) == SEARCH_REGEX)
+ return dataiterator_match_int_real(di, di->flags, &di->regex);
+ else
+ return dataiterator_match_int_real(di, di->flags, di->match);
}
int
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org