Works now.

Added GNUmakefile and configure script.
This commit is contained in:
hjp 2000-02-08 16:58:28 +00:00
parent 2b98426a4e
commit ea6520357a
5 changed files with 183 additions and 10 deletions

6
cvsdiffmin/.vimrc Normal file
View File

@ -0,0 +1,6 @@
version 5.0
map!  >I<yypa/O
set autoindent
set exrc
set ruler
set shiftwidth=4

24
cvsdiffmin/GNUmakefile Normal file
View File

@ -0,0 +1,24 @@
include GNUmakevars
all: cvsdiffmin
clean:
rm cvsdiffmin customize
install: $(BINDIR) $(BINDIR)/cvsdiffmin
%: %.pl customize
sh ./customize < $< > $@
chmod +x $@
%: %.sh customize
sh ./customize < $< > $@
chmod +x $@
customize: configure
sh ./configure
$(BINDIR):
mkdir -p $@
include GNUmakerules

68
cvsdiffmin/configure vendored Normal file
View File

@ -0,0 +1,68 @@
#!/bin/sh
#
echo "#!/bin/sh" > customize.$$
echo "sed \\" > customize.$$
chmod +x customize.$$
################################################################
# find a working perl:
#
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
do
if $i -e 'exit ($] < 5.000)'
then
echo $i works
perl="$i"
break
fi
done
if [ -z "$perl" ]
then
could not find a working perl command, sorry.
exit 1
fi
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
################################################################
# find a diff which understands --changed-group-format
# and related options (like gnu diff)
#
echo 'a
b
c' > diff_format-test.$$.1
echo 'a
B
c' > diff_format-test.$$.2
wanted="<b
=B
>"
for i in /usr/bin/diff /usr/local/bin/diff
do
a="`$i --unchanged-group-format='' --changed-group-format='<%<=%>>' diff_format-test.$$.1 diff_format-test.$$.2`"
echo "$a"
if [ "x$a" = "x$wanted" ]
then
echo $i works
diff_format="$i"
fi
done
if [ -z "$diff_format" ]
then
echo could not find a working diff_format command, sorry.
exit 1
fi
echo " -e 's,@@@diff_format@@@,$diff_format,g' \\" >> customize.$$
rm diff_format-test.$$.?
################################################################
# finish
# Add trailing newline and rename temp file to final name
#
echo >> customize.$$
mv customize.$$ customize

View File

@ -1,6 +1,6 @@
#!/usr/local/bin/perl -w
#
# $Id: cvsdiffmin,v 1.1 2000-02-08 16:13:55 hjp Exp $
# $Id: cvsdiffmin,v 1.2 2000-02-08 16:58:28 hjp Exp $
#
# cvsdiffmin - minimize output of cvs diff
#
@ -19,33 +19,39 @@ my $count = 0;
local $| = 1;
while (<>) {
print STDERR;
if ($state eq 'EQ' && /^\<{7} /) {
print STDERR "-> V1\n";
$state = 'V1';
$text{$state} = "";
s/'/_/g;
$cap{$state} = $_;
next;
}
if ($state eq 'V1' && /^\={7}$/) {
print STDERR "-> V2\n";
$state = 'V2';
$text{$state} = "";
next;
}
if ($state eq 'V2' && /^\>{7} /) {
s/'/_/g;
$cap{$state} = $_;
write_file("cvsdiffmin.$$.$count.1", $text{V1});
write_file("cvsdiffmin.$$.$count.2", $text{V2});
system ($diff,
"--unchanged-group-format=\%=\n",
"--changed-group-format=${cap{V1}}\n\%<\n=======\n\%>\n${cap{V2}}\n",
"cvsdiffmin.$$.$count.1",
"cvsdiffmin.$$.$count.2");
open (DIFF,
"$diff " .
" --unchanged-group-format='\%='" .
" --changed-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --old-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --new-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" cvsdiffmin.$$.$count.1" .
" cvsdiffmin.$$.$count.2" .
"|") or die "cannot invoke diff: $!";
while (<DIFF>) {
print;
}
close(DIFF);
print STDERR "-> EQ\n";
$state = 'EQ';
$count++;
next;

69
cvsdiffmin/cvsdiffmin.pl Executable file
View File

@ -0,0 +1,69 @@
#!@@@perl@@@ -w
#
# $Id: cvsdiffmin.pl,v 1.1 2000-02-08 16:58:28 hjp Exp $
#
# cvsdiffmin - minimize output of cvs diff
#
use strict;
use File::Slurp;
my $diff = "@@@diff_format@@@";
my $state = 'EQ';
my %text = ();
my %cap = ();
my $count = 0;
local $| = 1;
while (<>) {
if ($state eq 'EQ' && /^\<{7} /) {
$state = 'V1';
$text{$state} = "";
s/'/_/g;
$cap{$state} = $_;
next;
}
if ($state eq 'V1' && /^\={7}$/) {
$state = 'V2';
$text{$state} = "";
next;
}
if ($state eq 'V2' && /^\>{7} /) {
s/'/_/g;
$cap{$state} = $_;
write_file("cvsdiffmin.$$.$count.1", $text{V1});
write_file("cvsdiffmin.$$.$count.2", $text{V2});
open (DIFF,
"$diff " .
" --unchanged-group-format='\%='" .
" --changed-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --old-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --new-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" cvsdiffmin.$$.$count.1" .
" cvsdiffmin.$$.$count.2" .
"|") or die "cannot invoke diff: $!";
while (<DIFF>) {
print;
}
close(DIFF);
$state = 'EQ';
$count++;
next;
}
if ($state eq 'EQ') {
print;
} else {
$text{$state} .= $_;
}
}
print "$state\n";
# vim:sw=4