RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/rpmio/ mire.c mire.h rpmgrep.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Mon 11 Feb 2008 - 01:30:29 CET
Message-Id: <20080211003029.DA609348460@rpm5.org>
  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:   11-Feb-2008 01:30:29
  Branch: HEAD                             Handle: 2008021100302900

  Modified files:
    rpm/rpmio               mire.c mire.h rpmgrep.c

  Log:
    - rpmgrep: fix: vallen=0 to mireRegexec means use strlen, not return nomatch.
    - mire: collect the complete set of all possible pcre_exec args.

  Summary:
    Revision    Changes     Path
    1.18        +1  -1      rpm/rpmio/mire.c
    1.12        +1  -0      rpm/rpmio/mire.h
    1.10        +8  -2      rpm/rpmio/rpmgrep.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mire.c
  ============================================================================
  $ cvs diff -u -r1.17 -r1.18 mire.c
  --- rpm/rpmio/mire.c	10 Feb 2008 23:12:15 -0000	1.17
  +++ rpm/rpmio/mire.c	11 Feb 2008 00:30:29 -0000	1.18
  @@ -135,7 +135,7 @@
   #ifdef	WITH_PCRE
   	if (vallen == 0)
   	    vallen = strlen(val);
  -	rc = pcre_exec(mire->pcre, mire->hints, val, vallen, 0,
  +	rc = pcre_exec(mire->pcre, mire->hints, val, vallen, mire->startoff,
   		mire->eoptions, mire->offsets, mire->noffsets);
   	if (rc < 0 && rc != PCRE_ERROR_NOMATCH) {
   	    rpmlog(RPMLOG_ERR, _("pcre_exec failed: return %d\n"), rc);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mire.h
  ============================================================================
  $ cvs diff -u -r1.11 -r1.12 mire.h
  --- rpm/rpmio/mire.h	10 Feb 2008 18:32:33 -0000	1.11
  +++ rpm/rpmio/mire.h	11 Feb 2008 00:30:29 -0000	1.12
  @@ -72,6 +72,7 @@
       int	cflags;		/*!< regcomp(3) flags (0 uses REG_EXTENDED|REG_NOSUB) */
       int	eflags;		/*!< regexec(3) flags */
       int coptions;	/*!< pcre_compile2(3) options. */
  +    int startoff;	/*!< pcre_exec(3) starting offset. */
       int eoptions;	/*!< pcre_exec(3) options. */
       int notmatch;		/*!< non-zero: negative match, like "grep -v" */
       int tag;			/*!< sort identifier (e.g. an rpmTag) */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmgrep.c
  ============================================================================
  $ cvs diff -u -r1.9 -r1.10 rpmgrep.c
  --- rpm/rpmio/rpmgrep.c	10 Feb 2008 23:12:15 -0000	1.9
  +++ rpm/rpmio/rpmgrep.c	11 Feb 2008 00:30:29 -0000	1.10
  @@ -648,10 +648,13 @@
   
             for (i = 0; i < jfriedl_XR; i++) {
                 miRE mire = pattern_list;
  +              mire->startoff = 0;	/* XXX needed? */
  +              mire->eoptions = 0;	/* XXX needed? */
                 /* XXX save offsets for use by pcre_exec. */
                 mire->offsets = offsets;
                 mire->noffsets = 99;
  -              match = (mireRegexec(mire, ptr, length) >= 0);
  +              /* XXX WATCHOUT: mireRegexec w length=0 does strlen(matchptr)! */
  +              match = ((length > 0 ? mireRegexec(mire, matchptr, length) : PCRE_ERROR_NOMATCH) >= 0);
             }
   
             if (gettimeofday(&end_time, &dummy) != 0)
  @@ -674,10 +677,13 @@
         the final newline in the subject string. */
         for (i = 0; i < pattern_count; i++) {
           miRE mire = pattern_list + i;
  +        mire->startoff = 0;	/* XXX needed? */
  +        mire->eoptions = 0;	/* XXX needed? */
           /* XXX save offsets for use by pcre_exec. */
           mire->offsets = offsets;
           mire->noffsets = 99;
  -        mrc = mireRegexec(mire, matchptr, length);
  +        /* XXX WATCHOUT: mireRegexec w length=0 does strlen(matchptr)! */
  +        mrc = (length > 0 ? mireRegexec(mire, matchptr, length) : PCRE_ERROR_NOMATCH);
           if (mrc >= 0) { match = TRUE; break; }
           if (mrc != PCRE_ERROR_NOMATCH) {
             fprintf(stderr, "pcregrep: mireRegexec() error %d while matching ", mrc);
  @@ .
Received on Mon Feb 11 01:30:29 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.