diff -Nru colordiff-1.0.10/BUGS colordiff-1.0.13/BUGS --- colordiff-1.0.10/BUGS 2007-11-05 20:51:10.000000000 +0000 +++ colordiff-1.0.13/BUGS 2012-10-17 20:17:46.000000000 +0000 @@ -1,6 +1,6 @@ Bugs and limitations -There is always the possibility of colour selections (either the defaults +There is always the possibility that colour selections (either the defaults or those chosen by a user) will result in output where the text 'disappears', because the foreground and background colours are the same. There is no way to detect terminal colours and so this is always a danger. See diff -Nru colordiff-1.0.10/CHANGES colordiff-1.0.13/CHANGES --- colordiff-1.0.10/CHANGES 2012-05-26 17:16:09.000000000 +0000 +++ colordiff-1.0.13/CHANGES 2012-11-14 09:36:31.000000000 +0000 @@ -58,7 +58,7 @@ colordiff returns the 'diff' return value correctly. Inclusion of separate 'cdiff' shell script for colouring compressed and -URL-based diffs, following contribution from Ville Skyttä +URL-based diffs, following contribution from Ville Skyttä Changes between version 1.0.5 and 1.0.6 @@ -102,5 +102,20 @@ Fix for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=459763 incorporated, thanks to Gergely Nagy for contributed code. +Changes between version 1.0.10 and 1.0.11 + +Support for xz in cdiff, patch by Ville Skyttä; code cleanup from Akim Demaille; +patch to provide custom diff command from Rainer Nagel. Improved wdiff support +inspired by patch from Peter van Dijk. Improved debdiff detection. + +Changes between version 1.0.11 and 1.0.12 + +Packaging refactoring and minor packaging fixes. + +Changes between version 1.0.12 and 1.0.13 + +Avoid accidentally identifying some diffs as side-by-side, handling colordiff +arguments better. Plus code refactoring, corrections to docs. + # vim: tw=72 diff -Nru colordiff-1.0.10/COPYING colordiff-1.0.13/COPYING --- colordiff-1.0.10/COPYING 2006-04-16 19:22:20.000000000 +0000 +++ colordiff-1.0.13/COPYING 2012-10-17 20:14:35.000000000 +0000 @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +15,7 @@ General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to +the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -55,8 +55,8 @@ The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +110,7 @@ License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -255,7 +255,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,4 +277,63 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff -Nru colordiff-1.0.10/README colordiff-1.0.13/README --- colordiff-1.0.10/README 2009-01-25 18:53:24.000000000 +0000 +++ colordiff-1.0.13/README 2012-11-14 09:50:32.000000000 +0000 @@ -4,7 +4,7 @@ Synopsis -colordiff [diff options] {file1} {file2} +colordiff [diff options] [colordiff options] {file1} {file2} Description @@ -24,7 +24,7 @@ Usage -Use colordiff wherever you would normally use diff, or pipe output to +Use colordiff wherever you would normally use diff, or instead pipe output to colordiff: For example: @@ -49,7 +49,15 @@ alias diff=colordiff -Any options passed to colordiff are passed through to diff. +Any options passed to colordiff are passed through to diff except for the +colordiff-specific option 'difftype', e.g. + +colordiff --difftype=debdiff file1 file2 + +Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; +these correspond to plain diffs, context diffs, unified diffs, side-by-side +diffs, wdiff output and debdiff output respectively. Use these overrides when +colordiff is not able to determine the diff-type automatically. Alternatively, a construct such as 'cvs diff SOMETHING | colordiff' can be included in ~/.bashrc as follows: @@ -62,16 +70,6 @@ Note that the function name, cvsdiff, can be customized. -Any options passed to colordiff are passed through to diff except for -the colordiff-specific option 'difftype', e.g. - -colordiff --difftype=debdiff file1 file2 - -Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff, debdiff; -these correspond to plain diffs, context diffs, unified diffs, side-by-side -diffs, wdiff output and debdiff output respectively. Use these overrides when -colordiff is not able to determine the diff-type automatically. - Files /etc/colordiffrc @@ -88,10 +86,3 @@ Bug reports and suggestions/patches to please. -Author - -colordiff is written and maintained by Dave Ewart . This -manual page and the source XML was written by Graham Wilson -for Debian and is maintained by the author. Dave Ewart maintains the Debian -package. - diff -Nru colordiff-1.0.10/TODO colordiff-1.0.13/TODO --- colordiff-1.0.10/TODO 2006-04-18 19:27:20.000000000 +0000 +++ colordiff-1.0.13/TODO 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -See BUGS :-) diff -Nru colordiff-1.0.10/cdiff.1 colordiff-1.0.13/cdiff.1 --- colordiff-1.0.10/cdiff.1 2009-01-25 11:18:59.000000000 +0000 +++ colordiff-1.0.13/cdiff.1 2012-11-14 09:50:31.000000000 +0000 @@ -1,31 +1,67 @@ +'\" t .\" Title: cdiff -.\" Author: -.\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 01/25/2009 -.\" Manual: -.\" Source: +.\" Author: Ville Skytt\(:a +.\" Generator: DocBook XSL Stylesheets v1.75.2 +.\" Date: 11/14/2012 +.\" Manual: User Commands +.\" Source: cdiff +.\" Language: English .\" -.TH "CDIFF" "1" "01/25/2009" "" "" +.TH "CDIFF" "1" "11/14/2012" "cdiff" "User Commands" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- .SH "NAME" cdiff \- a wrapper tool for colordiff .SH "SYNOPSIS" -.HP 6 -\fBcdiff\fR {\fIURL\fR} +.HP \w'\fBcdiff\fR\ 'u +\fBcdiff\fR {\fIURL|FILE\fR} .SH "DESCRIPTION" .PP cdiff -is a wrapper for colordiff and will add colour to a diff given in a URL, e\&.g\&. +is a wrapper for colordiff and will add colour to a diff given in a URL or a file, e\&.g\&. .sp +.if n \{\ .RS 4 +.\} .nf cdiff http://some\&.url\&.com/foo/thing\&.patch .fi +.if n \{\ .RE +.\} +.PP +It also adds support for reading gzip, bzip2, xz, and lzma compressed diffs, and like colordiff, also supports reading diffs from standard input if URL or a filename is not specified\&. +cdiff +pipes colordiff\*(Aqs output through less \-R\&. .SH "SEE ALSO" .PP cdiff is part of the colordiff package, which should be consulted for further reference\&. +.SH "AUTHORS" +.PP +\fBVille Skytt\(:a\fR +.RS 4 +cdiff author +.RE +.PP +\fBDave Ewart\fR +.RS 4 +colordiff author, packager for colordiff/cdiff +.RE diff -Nru colordiff-1.0.10/cdiff.sh colordiff-1.0.13/cdiff.sh --- colordiff-1.0.10/cdiff.sh 2009-01-26 20:17:47.000000000 +0000 +++ colordiff-1.0.13/cdiff.sh 2012-10-17 20:14:35.000000000 +0000 @@ -2,7 +2,7 @@ # cdiff.sh - Convenience wrapper for colordiff # -# Copyright (C) 2003-2004 Ville Skyttä +# Copyright (C) 2003-2009 Ville Skyttä # Based on cdiff version 1.4 by eivind@FreeBSD.org # # This program is free software; you can redistribute it and/or @@ -17,15 +17,15 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (if [ "$1" != "" ]; then while [ "$1" != "" ]; do file=`echo "$1" | perl -pe 's|^file:/+|/|i'` case "$file" in - *.bz2) cat="bzip2 -dcf" ;; - *.lzma) cat="lzma -dc" ;; - *) cat="gzip -dcf" ;; + *.bz2) cat="bzip2 -dcf" ;; + *.xz|*.lzma) cat="xz -dc" ;; + *) cat="gzip -dcf" ;; esac case `echo "$file" | perl -ne 'print lc $_'` in http:*|https:*|ftp:*) diff -Nru colordiff-1.0.10/cdiff.xml colordiff-1.0.13/cdiff.xml --- colordiff-1.0.10/cdiff.xml 2009-01-26 20:16:44.000000000 +0000 +++ colordiff-1.0.13/cdiff.xml 2012-10-17 20:14:35.000000000 +0000 @@ -1,4 +1,4 @@ - + diff"> @@ -9,9 +9,25 @@ by eric raymond --> + + + + Ville + Skyttä + cdiff author + + + Dave + Ewart + colordiff author, packager for colordiff/cdiff + + + cdiff + cdiff 1 + User Commands @@ -35,9 +51,9 @@ cdiff http://some.url.com/foo/thing.patch -It also adds support for reading gzip, bzip2 and lzma compressed diffs, -and like colordiff, also supports reading diffs from standard input if URL -or a filename is not specified. &cdiff; pipes colordiff's output through +It also adds support for reading gzip, bzip2, xz, and lzma compressed +diffs, and like colordiff, also supports reading diffs from standard input if +URL or a filename is not specified. &cdiff; pipes colordiff's output through less -R. diff -Nru colordiff-1.0.10/colordiff.1 colordiff-1.0.13/colordiff.1 --- colordiff-1.0.10/colordiff.1 2013-01-16 16:12:22.000000000 +0000 +++ colordiff-1.0.13/colordiff.1 2012-11-14 09:50:29.000000000 +0000 @@ -1,20 +1,37 @@ +'\" t .\" Title: colordiff -.\" Author: -.\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 01/25/2009 -.\" Manual: -.\" Source: +.\" Author: Dave Ewart +.\" Generator: DocBook XSL Stylesheets v1.75.2 +.\" Date: 11/14/2012 +.\" Manual: User Commands +.\" Source: colordiff +.\" Language: English .\" -.TH "COLORDIFF" "1" "01/25/2009" "" "" +.TH "COLORDIFF" "1" "11/14/2012" "colordiff" "User Commands" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- .SH "NAME" -colordiff \- a tool to colorize diff output +colordiff \- a tool to colorize \fBdiff\fR output .SH "SYNOPSIS" -.HP 10 -\fBcolordiff\fR [\fI\fBdiff\fR\fR\fI\ options\fR] [\fIcolordiff\fR\fI\ options\fR] {\fIfile1\fR} {\fIfile2\fR} +.HP \w'\fBcolordiff\fR\ 'u +\fBcolordiff\fR [\fIdiff\ options\fR] [\fIcolordiff\ options\fR] {\fIfile1\fR} {\fIfile2\fR} .SH "DESCRIPTION" .PP colordiff @@ -28,7 +45,7 @@ or Emacs with the appropriate syntax highlighting options enabled\&. The colour schemes can be read from a central configuration file or from a local user -\fI~/\&.colordiffrc\fR +~/\&.colordiffrc file\&. .PP colordiff @@ -41,105 +58,142 @@ Use colordiff wherever you would normally use -\fBdiff\fR, or pipe output to +\fBdiff\fR, or instead pipe output to colordiff: .PP For example: .sp +.if n \{\ .RS 4 +.\} .nf $ colordiff file1 file2 $ diff \-u file1 file2 | colordiff .fi +.if n \{\ .RE +.\} .PP -You can pipe the output to \'less\', using the \'\-R\' option (some systems or terminal types may get better results using \'\-r\' instead), which keeps the colour escape sequences, otherwise displayed incorrectly or discarded by \'less\': +You can pipe the output to \*(Aqless\*(Aq, using the \*(Aq\-R\*(Aq option (some systems or terminal types may get better results using \*(Aq\-r\*(Aq instead), which keeps the colour escape sequences, otherwise displayed incorrectly or discarded by \*(Aqless\*(Aq: .sp +.if n \{\ .RS 4 +.\} .nf $ diff \-u file1 file2 | colordiff | less \-R .fi +.if n \{\ .RE +.\} .PP If you have \fBwdiff\fR -installed, colordiff will correctly colourise the added and removed text, provided that the \'\-n\' option is given to +installed, colordiff will correctly colourise the added and removed text, provided that the \*(Aq\-n\*(Aq option is given to \fBwdiff\fR: .sp +.if n \{\ .RS 4 +.\} .nf $ wdiff \-n file1 file2 | colordiff .fi +.if n \{\ .RE +.\} .PP You may find it useful to make \fBdiff\fR automatically call \fBcolordiff\fR\&. Add the following line to -\fI~/\&.bashrc\fR +~/\&.bashrc (or equivalent): .sp +.if n \{\ .RS 4 +.\} .nf alias diff=colordiff .fi +.if n \{\ .RE +.\} .PP Any options passed to colordiff are passed through to \fBdiff\fR -except for the colordiff\-specific option \'difftype\', e\&.g\&. +except for the colordiff\-specific option \*(Aqdifftype\*(Aq, e\&.g\&. .sp +.if n \{\ .RS 4 +.\} .nf colordiff \-\-difftype=debdiff file1 file2 .fi +.if n \{\ .RE +.\} .PP -Valid values for \'difftype\' are: diff, diffc, diffu, diffy, wdiff, debdiff; these correspond to plain diffs, context diffs, unified diffs, side\-by\-side diffs, wdiff output and debdiff output respectively\&. Use these overrides when colordiff is not able to determine the diff\-type automatically\&. +Valid values for \*(Aqdifftype\*(Aq are: diff, diffc, diffu, diffy, wdiff, debdiff; these correspond to plain diffs, context diffs, unified diffs, side\-by\-side diffs, wdiff output and debdiff output respectively\&. Use these overrides when colordiff is not able to determine the diff\-type automatically\&. .PP -Alternatively, a construct such as \'cvs diff SOMETHING | colordiff\' can be included in -\fI~/\&.bashrc\fR +Alternatively, a construct such as \*(Aqcvs diff SOMETHING | colordiff\*(Aq can be included in +~/\&.bashrc as follows: .sp +.if n \{\ .RS 4 +.\} .nf function cvsdiff () { cvs diff $@ | colordiff; } .fi +.if n \{\ .RE +.\} .PP -Or, combining the idea above using \'less\': +Or, combining the idea above using \*(Aqless\*(Aq: .sp +.if n \{\ .RS 4 +.\} .nf function cvsdiff () { cvs diff $@ | colordiff |less \-R; } .fi +.if n \{\ .RE +.\} .PP Note that the function name, cvsdiff, can be customized\&. .SH "FILES" .PP -\fI/etc/colordiffrc\fR +/etc/colordiffrc .RS 4 Central configuration file\&. User\-specific settings can be enabled by copying this file to -\fI~/\&.colordiffrc\fR +~/\&.colordiffrc and making the appropriate changes\&. .RE .PP -\fIcolordiffrc\-lightbg\fR +colordiffrc\-lightbg .RS 4 Alternate configuration template for use with terminals having light backgrounds\&. Copy this to /etc/colordiffrc or ~/\&.colordiffrc and customize\&. .RE .SH "BUGS" .PP Bug reports and suggestions/patches to - +davee@sungate\&.co\&.uk please\&. -.SH "AUTHOR" +.SH "AUTHORS" .PP -colordiff -is written and maintained by Dave Ewart -\&. This manual page and the source XML was written by Graham Wilson - -for Debian and is maintained by the author\&. Dave Ewart maintains the Debian package. +\fBDave Ewart\fR +.RS 4 +colordiff author and Debian packager +.RE +.PP +\fBGraham Wilson\fR +.RS 4 +Manual page and XML source author +.RE +.PP +\fBColin Tuckley\fR +.RS 4 +Debian package sponsor +.RE diff -Nru colordiff-1.0.10/colordiff.pl colordiff-1.0.13/colordiff.pl --- colordiff-1.0.10/colordiff.pl 2012-05-26 17:14:47.000000000 +0000 +++ colordiff-1.0.13/colordiff.pl 2012-11-14 09:36:38.000000000 +0000 @@ -5,7 +5,7 @@ # ColorDiff - a wrapper/replacment for 'diff' producing # # colourful output # # # -# Copyright (C)2002-2009 Dave Ewart (davee@sungate.co.uk) # +# Copyright (C)2002-2012 Dave Ewart (davee@sungate.co.uk) # # # ######################################################################## # # @@ -22,17 +22,18 @@ ######################################################################## use strict; -use Getopt::Long qw(:config pass_through); +use Getopt::Long qw(:config pass_through no_auto_abbrev); use IPC::Open2; my $app_name = 'colordiff'; -my $version = '1.0.10'; +my $version = '1.0.13'; my $author = 'Dave Ewart'; my $author_email = 'davee@sungate.co.uk'; -my $app_www = 'http://colordiff.sourceforge.net/'; +my $app_www = 'http://www.colordiff.org/'; my $copyright = '(C)2002-2012'; my $show_banner = 1; my $color_patch = 0; +my $diff_cmd = "diff"; # ANSI sequences for colours my %colour; @@ -68,6 +69,19 @@ my @config_files = ("$etcdir/colordiffrc"); push (@config_files, "$ENV{HOME}/.colordiffrc") if (defined $ENV{HOME}); my $config_file; +my $diff_type = 'unknown'; + +# Convert tabs to spaces +sub expand_tabs_to_spaces ($) { + my ($s) = @_; + while ((my $i = index ($s, "\t")) > -1) { + substr ( + $s, $i, 1, # range to replace + (' ' x (8 - ($i % 8))), # string to replace with + ); + } + $s; +} sub check_for_file_arguments { my $nonopts = 0; @@ -85,10 +99,84 @@ if ($arg !~ /^-/) { $nonopts++; } + if ($arg eq "--help" || $arg eq "--version" || $arg eq "-v") { + $nonopts++; + } } return $nonopts; } +sub detect_diff_type { + # Two parameters: + # $isref is reference to @inputstream + # $allow_diffy is flag indicating whether diffy is a + # permitted diff type + my $isref = shift; + my $allow_diffy = shift; + my @is = @$isref; + + # This may not be perfect - should identify most reasonably + # formatted diffs and patches + + foreach my $record (@is) { + # Unified diffs are the only flavour having '+++ ' or '--- ' + # at the start of a line + if ($record =~ /^(\+\+\+ |--- |@@ )/) { + return 'diffu'; + } + # Context diffs are the only flavour having '***' + # at the start of a line + elsif ($record =~ /^\*\*\*/) { + return 'diffc'; + } + # Plain diffs have NcN, NdN and NaN etc. + elsif ($record =~ /^[0-9,]+[acd][0-9,]+$/) { + return 'diff'; + } + # FIXME - This is not very specific, since the regex matches could + # easily match non-diff output. + # However, given that we have not yet matched any of the *other* diff + # types, this might be good enough + # + # Only pick diffy if our flag parameter indicates so + elsif ( ($allow_diffy == 1) && ($record =~ /(\s\|\s|\s<$|\s>\s)/) ) { + return 'diffy'; + } + # wdiff deleted/added patterns + # should almost always be pairwise? + elsif ($record =~ /\[-.*?-\]/s + || $record =~ /\{\+.*?\+\}/s) { + return 'wdiff'; + } + # FIXME - This is a bit risky, but if we haven't matched any other + # diff type by this stage, this line usually indicates we have + # debdiff output + elsif ($record =~ /^Control files: lines which differ/) { + return 'debdiff'; + } + } + $diff_type = 'unknown'; +} + +my $enable_verifymode; +my $specified_difftype; +GetOptions( + # --enable-verifymode option is for testing behaviour of colordiff + # against standard test diffs + "verifymode" => \$enable_verifymode, + "difftype=s" => \$specified_difftype + # TODO - check that specified type is valid, issue warning if not +); + +if (defined $enable_verifymode) { + # When in verify mode, to ensure consistent output we don't source + # any external config files, so we use built-in defaults + # and we add colour to our patches + @config_files = (); + $color_patch = 1; + $show_banner = 0; +} + foreach $config_file (@config_files) { if (open (COLORDIFFRC, "<$config_file")) { while () { @@ -114,6 +202,10 @@ } next; } + if ($setting eq 'diff_cmd') { + $diff_cmd = $value; + next; + } $setting =~ tr/A-Z/a-z/; $value =~ tr/A-Z/a-z/; if (($value eq 'normal') || ($value eq 'none')) { @@ -173,11 +265,6 @@ $colour{off} = ''; } -my $specified_difftype; -GetOptions( - "difftype=s" => \$specified_difftype -); -# TODO - check that specified type is valid, issue warning if not # ---------------------------------------------------------------------------- @@ -199,7 +286,7 @@ my $exitcode = 0; if ($operating_methodology == 1) { # Run diff and then post-process the output - my $pid = open2(\*INPUTSTREAM, undef, "diff", @ARGV); + my $pid = open2(\*INPUTSTREAM, undef, "$diff_cmd", @ARGV); @inputstream = ; close INPUTSTREAM; waitpid $pid, 0; @@ -212,54 +299,16 @@ # Input stream has been read - need to examine it # to determine type of diff we have. -# -# This may not be perfect - should identify most reasonably -# formatted diffs and patches -my $diff_type = 'unknown'; my $record; my $longest_record = 0; -DIFF_TYPE: foreach $record (@inputstream) { - if (defined $specified_difftype) { - $diff_type = $specified_difftype; - last DIFF_TYPE; - } - # Unified diffs are the only flavour having '+++' or '---' - # at the start of a line - if ($record =~ /^(\+\+\+|---|@@)/) { - $diff_type = 'diffu'; - last DIFF_TYPE; - } - # Context diffs are the only flavour having '***' - # at the start of a line - elsif ($record =~ /^\*\*\*/) { - $diff_type = 'diffc'; - last DIFF_TYPE; - } - # Plain diffs have NcN, NdN and NaN etc. - elsif ($record =~ /^[0-9,]+[acd][0-9,]+$/) { - $diff_type = 'diff'; - last DIFF_TYPE; - } - # FIXME - This is not very specific, since the regex matches could - # easily match non-diff output. - # However, given that we have not yet matched any of the *other* diff - # types, this might be good enough - elsif ($record =~ /(\s\|\s|\s<$|\s>\s)/) { - $diff_type = 'diffy'; - last DIFF_TYPE; - } - # wdiff deleted/added patterns - # should almost always be pairwaise? - elsif ($record =~ /\[-.*?-\]/s) { - $diff_type = 'wdiff'; - last DIFF_TYPE; - } - elsif ($record =~ /\{\+.*?\+\}/s) { - $diff_type = 'wdiff'; - last DIFF_TYPE; - } +if (defined $specified_difftype) { + $diff_type = $specified_difftype; +} +else { + # Detect diff type, diffy is permitted + $diff_type = detect_diff_type(\@inputstream, 1); } my $inside_file_old = 1; @@ -280,14 +329,7 @@ # Not very elegant, but does the job # Unfortunately requires parsing the input stream multiple times foreach (@inputstream) { - # Convert tabs to spaces - while ((my $i = index ($_, "\t")) > -1) { - substr ( - $_, $i, 1, # range to replace - (' ' x (8 - ($i % 8))), # string to replace with - ); - } - $record = $_; + $record = expand_tabs_to_spaces $_; $longest_record = length ($record) if (length ($record) > $longest_record); } for (my $i = 0 ; $i <= $longest_record ; $i++) { @@ -296,25 +338,15 @@ } foreach (@inputstream) { - # Convert tabs to spaces - while ((my $i = index ($_, "\t")) > -1) { - substr ( - $_, $i, 1, # range to replace - (' ' x (8 - ($i % 8))), # string to replace with - ); - } + $_ = expand_tabs_to_spaces $_; for (my $i = 0 ; $i < (length ($_) - 2) ; $i++) { next if (!defined $separator_col{$i}); next if ($separator_col{$i} == 0); my $subsub = substr ($_, $i, 2); - if ( ($subsub ne ' ') - && ($subsub ne ' |') - && ($subsub ne ' >') - && ($subsub ne ' <')) - { + if ($subsub !~ / [ |<>]/) { $separator_col{$i} = 0; } - if (($subsub eq ' |') || ($subsub eq ' >') || ($subsub eq ' <')) { + if ($subsub =~ / [|<>]/) { $candidate_col{$i}++; } } @@ -328,6 +360,14 @@ } } } + # If we don't find a suitable separator column then + # we've probably misidentified the input as diffy + # Search stream again, this time excluding diffy + # as a possible outcome + if ($diffy_sep_col == 0) { + # Detect diff type, diffy is NOT permitted + $diff_type = detect_diff_type(\@inputstream, 0); + } } # ------------------------------------------------------------------------------ @@ -440,12 +480,12 @@ } } elsif ($diff_type eq 'wdiff') { - $_ =~ s/(\[-[^]]*?-\])/$file_old$1$colour{off}/g; - $_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g; + $_ =~ s/(\[-.+?-\])/$file_old$1$colour{off}/g; + $_ =~ s/(\{\+.+?\+\})/$file_new$1$colour{off}/g; } elsif ($diff_type eq 'debdiff') { - $_ =~ s/(\[-[^]]*?-\])/$file_old$1$colour{off}/g; - $_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g; + $_ =~ s/(\[-.+?-\])/$file_old$1$colour{off}/g; + $_ =~ s/(\{\+.+?\+\})/$file_new$1$colour{off}/g; } s/$/$colour{off}/; print "$_"; diff -Nru colordiff-1.0.10/colordiff.xml colordiff-1.0.13/colordiff.xml --- colordiff-1.0.10/colordiff.xml 2009-01-25 10:59:25.000000000 +0000 +++ colordiff-1.0.13/colordiff.xml 2012-10-17 20:14:35.000000000 +0000 @@ -1,4 +1,4 @@ - + diff"> @@ -9,9 +9,30 @@ by eric raymond --> + + + + Dave + Ewart + colordiff author and Debian packager + + + Graham + Wilson + Manual page and XML source author + + + Colin + Tuckley + Debian package sponsor + + + colordiff + colordiff 1 + User Commands @@ -22,8 +43,8 @@ colordiff - &diff; options - &colordiff; options + diff options + colordiff options file1 file2 @@ -50,8 +71,8 @@ Usage -Use &colordiff; wherever you would normally use &diff;, or pipe output -to &colordiff;: +Use &colordiff; wherever you would normally use &diff;, or instead +pipe output to &colordiff;: For example: @@ -148,15 +169,5 @@ -Author - -&colordiff; is written and maintained by Dave Ewart -davee@sungate.co.uk. This manual page and the -source XML was written by Graham Wilson graham@mknod.org for -Debian and is maintained by the author. Dave Ewart maintains the Debian -package, sponsored by Graham Wilson. - - - diff -Nru colordiff-1.0.10/colordiffrc colordiff-1.0.13/colordiffrc --- colordiff-1.0.10/colordiffrc 2006-07-31 18:36:22.000000000 +0000 +++ colordiff-1.0.13/colordiffrc 2012-10-17 20:14:35.000000000 +0000 @@ -8,6 +8,9 @@ # To make the patch file *include* colours, change the option # below to 'yes' color_patches=no +# Sometimes it can be useful to specify which diff command to +# use: that can be specified here +diff_cmd=diff # # available colours are: white, yellow, green, blue, # cyan, red, magenta, black, diff -Nru colordiff-1.0.10/colordiffrc-lightbg colordiff-1.0.13/colordiffrc-lightbg --- colordiff-1.0.10/colordiffrc-lightbg 2006-07-31 18:37:11.000000000 +0000 +++ colordiff-1.0.13/colordiffrc-lightbg 2012-10-17 20:14:35.000000000 +0000 @@ -8,6 +8,9 @@ # To make the patch file *include* colours, change the option # below to 'yes' color_patches=no +# Sometimes it can be useful to specify which diff command to +# use: that can be specified here +diff_cmd=diff # # available colours are: white, yellow, green, blue, # cyan, red, magenta, black, diff -Nru colordiff-1.0.10/debian/changelog colordiff-1.0.13/debian/changelog --- colordiff-1.0.10/debian/changelog 2013-01-16 16:12:22.000000000 +0000 +++ colordiff-1.0.13/debian/changelog 2013-01-16 16:12:22.000000000 +0000 @@ -1,4 +1,29 @@ -colordiff (1.0.10-1) unstable; urgency=low +colordiff (1.0.13-1~andre1) quantal; urgency=low + + * Backport from Ubuntu / Debian without changes + + -- Andre Klitzing Wed, 16 Jan 2013 16:57:31 +0100 + +colordiff (1.0.13-1) unstable; urgency=low + + * New upstream release + + -- Dave Ewart Wed, 14 Nov 2012 10:32:11 +0000 + +colordiff (1.0.12-1) UNRELEASED; urgency=low + + * New upstream release + + -- Dave Ewart Mon, 15 Oct 2012 20:13:11 +0100 + +colordiff (1.0.11-1) UNRELEASED; urgency=low + + * New upstream release + * Improved wdiff support (closes: #681019) + + -- Dave Ewart Sat, 05 Oct 2012 17:05:00 +0100 + +colordiff (1.0.10-1) UNRELEASED; urgency=low * New upstream release * Fixes use in pipe (closes: #459763) diff -Nru colordiff-1.0.10/debian/control colordiff-1.0.13/debian/control --- colordiff-1.0.10/debian/control 2013-01-16 16:12:22.000000000 +0000 +++ colordiff-1.0.13/debian/control 2013-01-16 16:12:22.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Dave Ewart Build-Depends: debhelper (>> 5.0.0) Standards-Version: 3.9.3 -Homepage: http://colordiff.sourceforge.net/ +Homepage: http://www.colordiff.org/ Package: colordiff Architecture: all diff -Nru colordiff-1.0.10/debian/copyright colordiff-1.0.13/debian/copyright --- colordiff-1.0.10/debian/copyright 2013-01-16 16:12:22.000000000 +0000 +++ colordiff-1.0.13/debian/copyright 2013-01-16 16:12:22.000000000 +0000 @@ -1,9 +1,10 @@ -Copyright (C)2002-2008 Dave Ewart (davee@sungate.co.uk) +Copyright (C)2002-2012 Dave Ewart (davee@sungate.co.uk) This package was debianized by Graham Wilson on Sun, 16 Mar 2003 23:30:30 +0000. -It was downloaded from: http://colordiff.sourceforge.net/ +It was downloaded from: http://colordiff.sourceforge.net/ - since version +1.0.12 from http://www.colordiff.org/ Upstream Author: Dave Ewart diff -Nru colordiff-1.0.10/debian/watch colordiff-1.0.13/debian/watch --- colordiff-1.0.10/debian/watch 2013-01-16 16:12:22.000000000 +0000 +++ colordiff-1.0.13/debian/watch 2013-01-16 16:12:22.000000000 +0000 @@ -1,2 +1,2 @@ version=2 -http://colordiff.sourceforge.net/colordiff-(.*)\.tar\.gz +http://www.colordiff.org/colordiff-(.*)\.tar\.gz