X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35e20db0ee72655b698dc9fcaca1705c009254ee..5b2f31eb30be576374064413b9d0f63a1bf8c110:/difflast.pl?ds=inline
diff --git a/difflast.pl b/difflast.pl
index 1e724c768f..d1473e627a 100755
--- a/difflast.pl
+++ b/difflast.pl
@@ -14,16 +14,17 @@ use strict;
my $CVS = "cvs -z3"; # the cvs command
+# the regexp for cvs revision number
+my $RE_CVS_REV = "\\d+(?:\\.\\d+)+";
+
sub dec_rev($)
{
my $rev = $_[0];
# decrement the revision number to get the previos one
- # (FIXME this is totally bogus, won't work with branches)
- my $revlen = length($rev) - rindex($rev, '.') - 1;
- my $m = 10**$revlen;
+ $rev =~ s/(\d+)$/$1 - 1/e;
- return int($rev) . "." . ($rev*$m - int($rev)*$m - 1)
+ return $rev;
}
sub get_last_rev($)
@@ -31,14 +32,16 @@ sub get_last_rev($)
my $file = $_[0];
my $basename = $file;
- $basename =~ s@^.*/([^/]\+)@$1@;
+ $basename =~ s@^.*/@@;
# first get the current version: try the Id RCS tag in the file itself
# first, use "cvs status" if this fails
if ( open(INPUT, $file) ) {
while () {
- if ( /\$Id$basename,v (\d+\.\d+)/ ) {
- return &dec_rev($1);
+ # notice that we shouldn't have '$' followed by 'Id' or cvs will
+ # substitute it!
+ if ( /\$(Id): $basename,v ($RE_CVS_REV)/ ) {
+ return &dec_rev($2);
}
}
}
@@ -46,7 +49,7 @@ sub get_last_rev($)
open(INPUT, "$CVS -q status $file |") or return 0;
while () {
- if ( /Working revision:\s+(\d+\.\d+)/ ) {
+ if ( /Working revision:\s+($RE_CVS_REV)/ ) {
return &dec_rev($1);
}
}
@@ -62,6 +65,9 @@ sub process_file($)
if ( !$revlast ) {
warn "Failed to get the last revision for $file, skipping.\n"
}
+ elsif ( $revlast =~ '\.0' ) {
+ warn "No previous revision of the file $file.\n"
+ }
else {
print `$CVS diff -b -kk -r $revlast $file`;
}