vercmp with "-" [SOLVED]

Ryan Schmidt ryandesign at macports.org
Sat Dec 17 00:20:49 PST 2011


On Dec 17, 2011, at 01:49, Ryan Schmidt wrote:

> I have not yet installed the new version, but just looking at the livecheck.regex dnsupdate uses, and looking at the contents of its livecheck.url, I don't see why it should have any problem with the change as described. Guess I should install it and try it out for myself.

Ok, continuing with dnsupdate as an example, here's the before:

DEBUG: Port (livecheck) version is 2.8
DEBUG: Fetching http://ju.jalon.free.fr/DNSUpdateProject/
DEBUG: The regex is "DNSUpdate([0-9]+(\.\w+)+)s.tgz"
DEBUG: The regex matched "DNSUpdate2.8s.tgz", extracted "2.8"
dnsupdate seems to be up to date

Here's the after:

DEBUG: Port (livecheck) version is 2.8
DEBUG: Fetching http://ju.jalon.free.fr/DNSUpdateProject/
DEBUG: The regex is "DNSUpdate([0-9]+(\.\w+)+)s.tgz"
DEBUG: The regex matched "DNSUpdate2.8s.tgz", extracted "2.8"
DEBUG: The regex matched ".8", extracted "DNSUpdate2.8s.tgz"
DEBUG: The regex matched "2.8", extracted ".8"
dnsupdate seems to have been updated (port version: 2.8, new version: .8)

I would say base is clearly wrong here. The proposed change is good *as described*, but what got implemented doesn't seem to match what we wanted.

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.

The new code does this:

+                        set matches [regexp -all -inline $the_re $line]
+                        foreach {matched upver} $matches {

The documentation for `-all -inline` [1] says that for each match, the list returned from [regexp] will contain the entire string matched, and then an entry for each parenthesized expression. I don't see a flag that would let us explain that we only want the first parenthesized expression and the rest ignored.

Ideally the regexp in the port would have been specified not as:

	DNSUpdate([0-9]+(\.\w+)+)s.tgz

but as:

	DNSUpdate([0-9]+(?:\.\w+)+)s.tgz

That is, using "?:" to indicate that the additional parentheses are not to be counted as matches, only as grouping. But I'll bet we have a lot of ports doing this, since it didn't matter before.

Perhaps we can cleverly transform the regexp in the livecheck proc to automatically add "?:" where needed. "Where needed" would probably be after any "(" that doesn't have a "\" before it nor a "?:" after it. Lookahead and lookbehind assertions could be helpful in making that transformation. I'll try it...


[1] http://www.tcl.tk/man/tcl8.4/TclCmd/regexp.htm#M12




More information about the macports-dev mailing list