RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 10-Feb-2008 19:13:47
Branch: HEAD Handle: 2008021018134700
Modified files:
rpm/rpmio mire.c mire.h rpmgrep.c
Log:
- rpmgrep: use rpmmireReg{comp,exec}() for {include,exclude}Mire.
- mire: add mire->{table,offsets,noffsets} for pcre_exec usage.
Summary:
Revision Changes Path
1.14 +3 -3 rpm/rpmio/mire.c
1.10 +3 -0 rpm/rpmio/mire.h
1.6 +17 -14 rpm/rpmio/rpmgrep.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/rpmio/mire.c
============================================================================
$ cvs diff -u -r1.13 -r1.14 mire.c
--- rpm/rpmio/mire.c 10 Feb 2008 17:32:06 -0000 1.13
+++ rpm/rpmio/mire.c 10 Feb 2008 18:13:47 -0000 1.14
@@ -133,8 +133,8 @@
break;
#ifdef WITH_PCRE
case RPMMIRE_PCRE:
- rc = pcre_exec(mire->pcre, NULL, val, (int)strlen(val), 0,
- mire->eoptions, NULL, 0);
+ rc = pcre_exec(mire->pcre, mire->hints, val, (int)strlen(val), 0,
+ mire->eoptions, mire->offsets, mire->noffsets);
if (rc && rc != PCRE_ERROR_NOMATCH) {
rpmlog(RPMLOG_ERR, _("%s: pcre_exec failed: return %d\n"), rc);
rc = -1;
@@ -175,7 +175,7 @@
if (mire->coptions == 0)
mire->coptions = 0; /* XXX defaults? */
mire->pcre = pcre_compile2(mire->pattern, mire->coptions,
- &mire->errcode, &mire->errmsg, &mire->erroff, NULL);
+ &mire->errcode, &mire->errmsg, &mire->erroff, mire->table);
if (mire->pcre == NULL) {
rpmlog(RPMLOG_ERR,
_("%s: pcre_compile2 failed: %s(%d) at offset %d\n"),
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/mire.h
============================================================================
$ cvs diff -u -r1.9 -r1.10 mire.h
--- rpm/rpmio/mire.h 10 Feb 2008 17:32:06 -0000 1.9
+++ rpm/rpmio/mire.h 10 Feb 2008 18:13:47 -0000 1.10
@@ -63,6 +63,9 @@
void *pcre; /*!< pcre compiled pattern buffer. */
void *hints; /*!< pcre compiled pattern hints buffer. */
const char * errmsg; /*!< pcre error message. */
+ const unsigned char * table;/*!< pcre locale table. */
+ int * offsets; /*!< pcre substring offset table. */
+ int noffsets; /*!< pcre substring offset table count. */
int erroff; /*!< pcre error offset. */
int errcode; /*!< pcre error code. */
int fnflags; /*!< fnmatch(3) flags (0 uses FNM_PATHNAME|FNM_PERIOD)*/
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmgrep.c
============================================================================
$ cvs diff -u -r1.5 -r1.6 rpmgrep.c
--- rpm/rpmio/rpmgrep.c 10 Feb 2008 17:32:06 -0000 1.5
+++ rpm/rpmio/rpmgrep.c 10 Feb 2008 18:13:47 -0000 1.6
@@ -131,8 +131,8 @@
static char *include_pattern = NULL;
static char *exclude_pattern = NULL;
-static pcre *include_compiled = NULL;
-static pcre *exclude_compiled = NULL;
+static miRE includeMire = NULL;
+static miRE excludeMire = NULL;
static int after_context = 0;
static int before_context = 0;
@@ -1085,16 +1085,13 @@
}
while ((nextfile = readdirectory(dir)) != NULL) {
- int frc, blen;
+ int frc;
sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile);
- blen = strlen(buffer);
- if (exclude_compiled != NULL &&
- pcre_exec(exclude_compiled, NULL, buffer, blen, 0, 0, NULL, 0) >= 0)
+ if (excludeMire && mireRegexec(excludeMire, buffer) != PCRE_ERROR_NOMATCH)
continue;
- if (include_compiled != NULL &&
- pcre_exec(include_compiled, NULL, buffer, blen, 0, 0, NULL, 0) < 0)
+ if (includeMire && mireRegexec(includeMire, buffer) == PCRE_ERROR_NOMATCH)
continue;
frc = grep_or_recurse(buffer, dir_recurse, FALSE);
@@ -1973,9 +1970,11 @@
/* If there are include or exclude patterns, compile them. */
if (exclude_pattern != NULL) {
- exclude_compiled = pcre_compile(exclude_pattern, 0, &error, &errptr,
- pcretables);
- if (exclude_compiled == NULL) {
+ excludeMire = mireNew(RPMMIRE_PCRE, 0);
+ /* XXX save locale tables for use by pcre_compile2. */
+ excludeMire->table = pcretables;
+ xx = mireRegcomp(excludeMire, exclude_pattern);
+ if (xx) {
fprintf(stderr, "pcregrep: Error in 'exclude' regex at offset %d: %s\n",
errptr, error);
goto errorexit;
@@ -1983,9 +1982,11 @@
}
if (include_pattern != NULL) {
- include_compiled = pcre_compile(include_pattern, 0, &error, &errptr,
- pcretables);
- if (include_compiled == NULL) {
+ includeMire = mireNew(RPMMIRE_PCRE, 0);
+ /* XXX save locale tables for use by pcre_compile2. */
+ includeMire->table = pcretables;
+ xx = mireRegcomp(includeMire, include_pattern);
+ if (xx) {
fprintf(stderr, "pcregrep: Error in 'include' regex at offset %d: %s\n",
errptr, error);
goto errorexit;
@@ -2014,6 +2015,8 @@
}
exit:
+ includeMire = mireFree(includeMire);
+ excludeMire = mireFree(excludeMire);
pattern_list = mireFreeAll(pattern_list, pattern_count);
patterns = argvFree(patterns);
@@ .
Received on Sun Feb 10 19:13:47 2008