RPM Community Forums

Mailing List Message of <rpm-devel>

Re: Generalizing EVR comparison precedence, preliminaries

From: Ralf S. Engelschall <rse+rpm-devel@rpm5.org>
Date: Fri 02 Jan 2009 - 10:46:04 CET
Message-ID: <20090102094604.GA31417@engelschall.com>
On Thu, Jan 01, 2009, Jeff Johnson wrote:

> On Jan 1, 2009, at 1:04 PM, Ralf S. Engelschall wrote:
>>>
>>> A little help vetting the RE's please ;-) My eyes are already tired
>>> from writing the toy script, RE's are more effective than XML at eye
>>> gouging.
>>
>> I propose the following three entries in "macros"...
>>
>>    # STEP 1: Match the string and capture regex parts
>>    #                      1          2           3             4
>>    #                      X     ":"  X        "-"X          ":"X
>>    %evr_tuple_match  ^(?:([^:-]+):)?([^:-]+)(?:-([^:-]+))?(?::([^:-]
>> +))?$
>
> A little more help please.
>
> I'm using POSIX extended RE's.

Oh, sorry. I silemtly assumed PCRE! But ok, a non-PCRE version is also
possible: we just have to replace the non-capturing parenthesis (?:..)
with regular ones and then just ignore them in the selection phase:

    # STEP 1: Match the string and capture regex parts
    #                      2          3           5             7
    #                      X     ":"  X        "-"X          ":"X
    %evr_tuple_match  ^(([^:-]+):)?([^:-]+)(-([^:-]+))?(:([^:-]+))?$

    # STEP 2: Assemble <E,V,R,D> tuple from regex parts
    # <E,V,R,D>       case 1:  case 2:  case 3:  case 4:  case 5:  case 6:
    #                 X:X-X:X  X:X-X    X:X      X:       X-X      X
    %evr_tuple_select 2357     237_     23__     2___     _23_     __5_

    # STEP 3: Configure the comparison order of the <E,V,R,D> tuple elements
    %evr_tuple_order  EVRD

This should do the trick with regular POSIX regular expressions, too.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Received on Fri Jan 2 10:50:12 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.