diff --git a/cvsdiffmin/.vimrc b/cvsdiffmin/.vimrc
new file mode 100644
index 0000000..9056a9a
--- /dev/null
+++ b/cvsdiffmin/.vimrc
@@ -0,0 +1,6 @@
+version 5.0
+map!  >I<yypa/O
+set autoindent
+set exrc
+set ruler
+set shiftwidth=4
diff --git a/cvsdiffmin/GNUmakefile b/cvsdiffmin/GNUmakefile
new file mode 100644
index 0000000..9a42834
--- /dev/null
+++ b/cvsdiffmin/GNUmakefile
@@ -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
diff --git a/cvsdiffmin/configure b/cvsdiffmin/configure
new file mode 100644
index 0000000..7b5b8ed
--- /dev/null
+++ b/cvsdiffmin/configure
@@ -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
+
diff --git a/cvsdiffmin/cvsdiffmin b/cvsdiffmin/cvsdiffmin
index 0e7404f..5569528 100755
--- a/cvsdiffmin/cvsdiffmin
+++ b/cvsdiffmin/cvsdiffmin
@@ -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;
diff --git a/cvsdiffmin/cvsdiffmin.pl b/cvsdiffmin/cvsdiffmin.pl
new file mode 100755
index 0000000..3ad2081
--- /dev/null
+++ b/cvsdiffmin/cvsdiffmin.pl
@@ -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
