vercmp with "-" [SOLVED]

Bradley Giesbrecht pixilla at macports.org
Sun Dec 18 10:55:51 PST 2011


On Dec 18, 2011, at 9:47 AM, Bradley Giesbrecht wrote:

> On Dec 18, 2011, at 7:41 AM, Rainer Müller wrote:
> 
>>> The code that before worked did this:
>>> 
>>> -                        if {[regexp $the_re $line matched upver]} {
>>> 
>>> "matched" is the entire string matched, and "upver" is the first
>>> parenthesized expression. Any additional parenthesized expressions
>>> are ignored.
>> 
>> Okay, that's the problem. I did not think of a regex with multiple
>> groups. Thanks for chasing this one down.
> 
> ...
>> So, if
>> we find out how many parentheses the regex will produce, we can remove
>> this many items from the returned list in each loop iteration but only
>> use the first one as the matched version. This would be easier than
>> algorithmically modifying the regex.
>> 
>> An alternative would be to use the -indices option of regexp which
>> returns the position of the match in the string. Then the regex could be
>> applied multiple times using -start to begin matching where the previous
>> match ended.
> 
> With the -indices option, would the intent of the code be more obvious?

portlivecheck.tcl:172
                        set lastoff 0
                        while {[regexp -start $lastoff -indices $the_re $line offsets]} {
                            regexp -start $lastoff $the_re $line matched upver
                            set foundmatch 1
                            if {$updated_version == 0 || [vercmp $upver $updated_version] > 0} {
                                set updated_version $upver
                            }
                            ui_debug "The regex matched \"$matched\", extracted \"$upver\""
                            lassign $offsets firstoff lastoff
                        }

Works with my original multiple version on single line string and with the three examples Joshua reported broke after r88031.

Should I commit this?


Regards,
Bradley Giesbrecht (pixilla)






More information about the macports-dev mailing list