]> git.saurik.com Git - wxWidgets.git/blob - difflast.pl
check for strtok_r() using C++ compiler
[wxWidgets.git] / difflast.pl
1 #!/usr/bin/perl -w
2
3 ###############################################################################
4 # Name: difflast.pl
5 # Purpose: Shows the difference between the current local version of the file
6 # and the last cvs revision
7 # Version: $Id$
8 # Author: VZ
9 # Created: 23.12.99
10 # Copyright:(c) Vadim Zeitlin 1999
11 ###############################################################################
12
13 use strict;
14
15 my $CVS = "cvs -z3"; # the cvs command
16
17 sub dec_rev($)
18 {
19 my $rev = $_[0];
20
21 # decrement the revision number to get the previos one
22 # (FIXME this is totally bogus, won't work with branches)
23 my $revlen = length($rev) - rindex($rev, '.') - 1;
24 my $m = 10**$revlen;
25
26 return int($rev) . "." . ($rev*$m - int($rev)*$m - 1)
27 }
28
29 sub get_last_rev($)
30 {
31 my $file = $_[0];
32
33 my $basename = $file;
34 $basename =~ s@^.*/([^/]\+)@$1@;
35
36 # first get the current version: try the Id RCS tag in the file itself
37 # first, use "cvs status" if this fails
38 if ( open(INPUT, $file) ) {
39 while (<INPUT>) {
40 # notice that we shouldn't have '$' followed by 'Id' or cvs will
41 # substitute it!
42 if ( /\$(Id): $basename,v (\d+\.\d+)/ ) {
43 return &dec_rev($2);
44 }
45 }
46 }
47
48 open(INPUT, "$CVS -q status $file |") or return 0;
49
50 while (<INPUT>) {
51 if ( /Working revision:\s+(\d+\.\d+)/ ) {
52 return &dec_rev($1);
53 }
54 }
55
56 return 0;
57 }
58
59 sub process_file($)
60 {
61 my $file = $_[0];
62 my $revlast = &get_last_rev($file);
63
64 if ( !$revlast ) {
65 warn "Failed to get the last revision for $file, skipping.\n"
66 }
67 elsif ( $revlast =~ "\.0" ) {
68 warn "No previous revision of the file $file.\n"
69 }
70 else {
71 print `$CVS diff -b -kk -r $revlast $file`;
72 }
73 }
74
75 # entry point
76
77 die "Usage: $0 <filenames...>\n" if ( $#ARGV == -1 );
78
79 foreach my $file (@ARGV) { process_file($file); }
80
81 exit 0;