colordiff-1.0.16.orig/0000755000000000000000000000000012613167675011411 5ustar colordiff-1.0.16.orig/CHANGES0000644000000000000000000001247112613167541012401 0ustar Changes between version 1.0 and 1.0.1 Addition of support for 'context' diffs and fixed 'colour over-run' problem when shell prompt has no colours defined, thanks to Matthew Gatto Changes between version 1.0.1 and 1.0.2 The entire input stream is received before being examined for the type of diff information it contains, the stream is no longer coloured 'on the fly'. This step improves identification of some types of diffs, where seeing the whole output is required to determine the type of diff being used. Diffs generated by 'subversion' are now recognised, in addition to plain diffs and CVS diffs. Thanks to Graham Wilson for helping to troubleshoot the subversion diffs. The colour 'black' can now also be specified in ~/.colordiffrc for use by those with light-coloured backgrounds. Thanks to Steven W Orr for helping to troubleshoot light-coloured backgrounds. Changes between version 1.0.2 and 1.0.3 More tolerance of whitespace in config file. More elegant handling of directories other than '/etc' being the location for the central colordiffrc and preserving a backup of an existing /etc/colordiffrc at installation - thanks to Bernhard Bablok Extra documenation for 'less' options provided by Niklas Vainio Changes between version 1.0.3 and 1.0.4 Added support for 'dark' colours, courtesy of patch from Michael Piefel. Also added support for long, command-line options to change colours on the fly, courtesy of patch from Nathan Tenney Bug fix for inconsistent handling of arguments in the input stream - fix received with thanks from Michal Maruska Changes between version 1.0.4 and 1.0.5 Improved efficiency for diff-type detection and addition of a new colour area, called 'cvsstuff' which allows an additional colour definition for this type of output. All these changes courtesy of a patch from Cory Tusar . Other minor code 'tidying'. Also included code tidying from Kevin Ballard Removed 'long colordiff colour options', originally contributed by Nathan Tenney, since it appears to conflict with the use of additional diff command-line options. A proper fix is needed, but this change was made to fix a bug at the expense of a probably little used (?) functionality? This change also fixes the bug which means that 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ä Changes between version 1.0.5 and 1.0.6 Finally(!) introduced support for 'side-by-side' diffs, including some contributed code by Andrew Chadwick . Also added support for colour specifier 'off' (or 'normal' or 'none') to the config file following feature request and patch from Wouter Bolsterlee , to allow colour highlighting to be switched off for some elements. Now by default, when colordiff is redirecting output to a file, the colours are switched off. This relates to bugs raised by Adam Borowski and Wang Jian. For users wishing to retain this behaviour, the new option "color_patches" has been introduced, which defaults to 'no'. Some changes have been made to the default colours used, to help visibility on as many different coloured terminals by default. Changes between version 1.0.6 and 1.0.7 Support introduced for 'wdiff' colourising (thanks to Tom Regner); also correctly handles undefined HOME (patches from various people). Support for p4 diffs added by Alexis Layton, plus bug fix for blank first lines. Changes between version 1.0.7 and 1.0.8 Support for numeric colours added, for 256-colour terminals (thanks to Gautam Iyer). Diff-types can now be specified explicitly, for use when diff-type detection doesn't work or isn't possible. Return diff's exit code, patch from Tim Connors. Allow extraneous diff text to be coloured separately. Changes between version 1.0.8 and 1.0.9 Fix for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513313 incorporated Changes between version 1.0.9 and 1.0.10 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. Changes between version 1.0.13 and 1.0.14 Big improvements to side-by-side diff detection, thanks Peter Wu. Additional colordiffrc example colour scheme file to match 'git diff'. Misc fixes thanks to John Szakmeister, Matthew Wang. Changes between 1.0.14 and 1.0.15 Missed gitdiff file from tarball, bumping version number for clarity. Changes between 1.0.15 and 1.0.16 Support for XDG_CONFIG_HOME (thanks Zhiming Wang), fewer deps for cdiff.sh and fixes for diffy and diff-type specification (thanks Peter Wu). # vim: tw=72 colordiff-1.0.16.orig/BUGS0000644000000000000000000000125312037611152012055 0ustar Bugs and limitations 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 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=368973 - The standard workaround is to choose either colordiffrc or colordiffrc-lightbg, as appropriate for the colour scheme in use. Colourising of 'wdiff' output requires that the '-n' option is given, i.e. 'wdiff -n', which avoids spanning the end of line while showing deleted or inserted text. See 'man wdiff' colordiff-1.0.16.orig/INSTALL0000644000000000000000000000243312037610653012431 0ustar PREREQUISITES To use colordiff, you need Perl and an ANSI-colour enabled terminal. To install as per the instructions below, you also need GNU Make. INSTALLATION (Debian) All branches of Debian now include the colordiff package, so the easiest way to install is simply by doing: apt-get install colordiff You should then setup your colour preferences (see below). INSTALLATION (Other systems) 1. (Optional) Edit the Makefile to change the preferred installation locations - default is /usr/local/bin for the script itself, and /etc for the central colour configuration file. 2. As root, type 'make install'. If 'make' is unavailable, simply copy colordiff.pl to /usr/local/bin and colordiffrc to /etc by hand. 3. The central colour configuration file, by default /etc/colordiffrc is read by each instance of the script. User-specific settings can be enabled by copying this file to ~/.colordiffrc and making the appropriate changes. Note that by default, colordiff is configured to work in an environment where the default background is generally 'dark'. If you are using a light-coloured background, the default colours in colordiffrc won't work very well - in that case, manually copy the file colordiffrc-lightbg to either /etc/colordiffrc or ~/.colordiffrc as appropriate. # vim: tw=72 colordiff-1.0.16.orig/COPYING0000644000000000000000000004325412037610653012441 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 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 The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This 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 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 price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this 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 themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent 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 void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 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 may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 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 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 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. colordiff-1.0.16.orig/colordiff.xml0000644000000000000000000001423712527321305014073 0ustar diff"> colordiff"> ]> 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 colordiff a tool to colorize &diff; output colordiff diff options colordiff options file1 file2 Description &colordiff; is a wrapper for &diff; and produces the same output as &diff; but with coloured syntax highlighting at the command line to improve readability. The output is similar to how a &diff;-generated patch might appear in Vim 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 ~/.colordiffrc file. &colordiff; makes use of ANSI colours and as such will only work when ANSI colours can be used - typical examples are xterms and Eterms, as well as console sessions. &colordiff; has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems. Usage Use &colordiff; wherever you would normally use &diff;, or instead pipe output to &colordiff;: For example: $ colordiff file1 file2 $ diff -u file1 file2 | colordiff 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': $ diff -u file1 file2 | colordiff | less -R If you want to force disable colour escape sequences (for example pipe the output to patch), you can use option '--color=no' to do so: $ diff -u file1 file2 | colordiff --color=no | patch -p0 -d another-working-dir If you have wdiff installed, colordiff will correctly colourise the added and removed text, provided that the '-n' option is given to wdiff: $ wdiff -n file1 file2 | colordiff You may find it useful to make &diff; automatically call colordiff. Add the following line to ~/.bashrc (or equivalent): alias diff=colordiff 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: function cvsdiff () { cvs diff $@ | colordiff; } Or, combining the idea above using 'less': function cvsdiff () { cvs diff $@ | colordiff |less -R; } Note that the function name, cvsdiff, can be customized. By default colordiff returns the exit code of the underlying diff invocation (if there is one), but there are some circumstances where it is useful to force colordiff's exit code to be zero: to do this use the option '--fakeexitcode': colordiff --fakeexitcode ... Files /etc/colordiffrc Central configuration file. User-specific settings can be enabled by copying this file to ~/.colordiffrc and making the appropriate changes. colordiffrc-lightbg Alternate configuration template for use with terminals having light backgrounds. Copy this to /etc/colordiffrc or ~/.colordiffrc and customize. colordiffrc-gitdiff Alternate configuration template for use with terminals having dark backgrounds, with colour defaults set to match the output of 'git diff'. Copy this to /etc/colordiffrc or ~/.colordiffrc and customize. Bugs Bug reports and suggestions/patches to davee@sungate.co.uk please. colordiff-1.0.16.orig/colordiff.10000644000000000000000000001316712527321311013431 0ustar '\" t .\" Title: colordiff .\" Author: Dave Ewart .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 05/21/2015 .\" Manual: User Commands .\" Source: colordiff .\" Language: English .\" .TH "COLORDIFF" "1" "05/21/2015" "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 \fBdiff\fR output .SH "SYNOPSIS" .HP \w'\fBcolordiff\fR\ 'u \fBcolordiff\fR [\fIdiff\ options\fR] [\fIcolordiff\ options\fR] {\fIfile1\fR} {\fIfile2\fR} .SH "DESCRIPTION" .PP colordiff is a wrapper for \fBdiff\fR and produces the same output as \fBdiff\fR but with coloured syntax highlighting at the command line to improve readability\&. The output is similar to how a \fBdiff\fR\-generated patch might appear in Vim 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 ~/\&.colordiffrc file\&. .PP colordiff makes use of ANSI colours and as such will only work when ANSI colours can be used \- typical examples are xterms and Eterms, as well as console sessions\&. .PP colordiff has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems\&. .SH "USAGE" .PP Use colordiff wherever you would normally use \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 \*(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 want to force disable colour escape sequences (for example pipe the output to \fBpatch\fR), you can use option \*(Aq\-\-color=no\*(Aq to do so: .sp .if n \{\ .RS 4 .\} .nf $ diff \-u file1 file2 | colordiff \-\-color=no | patch \-p0 \-d another\-working\-dir .fi .if n \{\ .RE .\} .PP If you have \fBwdiff\fR 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 ~/\&.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 \*(Aqdifftype\*(Aq, e\&.g\&. .sp .if n \{\ .RS 4 .\} .nf colordiff \-\-difftype=debdiff file1 file2 .fi .if n \{\ .RE .\} .PP 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 \*(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 \*(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\&. .PP By default colordiff returns the exit code of the underlying diff invocation (if there is one), but there are some circumstances where it is useful to force colordiff\*(Aqs exit code to be zero: to do this use the option \*(Aq\-\-fakeexitcode\*(Aq: .sp .if n \{\ .RS 4 .\} .nf colordiff \-\-fakeexitcode \&.\&.\&. .fi .if n \{\ .RE .\} .sp .SH "FILES" .PP /etc/colordiffrc .RS 4 Central configuration file\&. User\-specific settings can be enabled by copying this file to ~/\&.colordiffrc and making the appropriate changes\&. .RE .PP colordiffrc\-lightbg .RS 4 Alternate configuration template for use with terminals having light backgrounds\&. Copy this to /etc/colordiffrc or ~/\&.colordiffrc and customize\&. .RE .PP colordiffrc\-gitdiff .RS 4 Alternate configuration template for use with terminals having dark backgrounds, with colour defaults set to match the output of \*(Aqgit diff\*(Aq\&. 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 "AUTHORS" .PP \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 colordiff-1.0.16.orig/cdiff.sh0000755000000000000000000000422412543002062013001 0ustar #!/bin/sh # cdiff.sh - Convenience wrapper for colordiff # # Copyright (C) 2003-2015 Ville Skyttä # Based on cdiff version 1.4 by eivind@FreeBSD.org # # 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. (if [ "$1" != "" ]; then while [ "$1" != "" ]; do file=`echo "$1" | perl -pe 's|^file:/+|/|i'` case "$file" in *.bz2) cat="bzip2 -dcf" ;; *.xz|*.lzma) cat="xz -dc" ;; *) cat="gzip -dcf" ;; esac case `echo "$file" | perl -ne 'print lc $_'` in http:*|https:*|ftp:*) if [ -z "$CDIFF_FETCH" ]; then if type curl >/dev/null 2>&1; then CDIFF_FETCH="curl -s" elif type wget >/dev/null 2>&1; then CDIFF_FETCH="wget -e timestamping=off -qO -" elif type lwp-request >/dev/null 2>&1; then CDIFF_FETCH="lwp-request -m GET" elif type lynx >/dev/null 2>&1; then CDIFF_FETCH="lynx -source" elif type elinks >/dev/null 2>&1; then CDIFF_FETCH="elinks -source" fi if [ -z "$CDIFF_FETCH" ]; then echo "Error: no program to fetch from URLs found." exit 1 fi fi $CDIFF_FETCH "$file" | $cat ;; *) $cat "$file" ;; esac shift; done else cat fi) | colordiff | less -R colordiff-1.0.16.orig/colordiffrc-gitdiff0000644000000000000000000000176312527320635015240 0ustar # Example colordiffrc file for dark backgrounds with colour # defaults set to match 'git diff' # # Set banner=no to suppress authorship info at top of # colordiff output banner=no # By default, when colordiff output is being redirected # to a file, it detects this and does not colour-highlight # 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, # darkwhite, darkyellow, darkgreen, # darkblue, darkcyan, darkred, # darkmagenta, darkblack # # Can also specify 'none', 'normal' or 'off' which are all # aliases for the same thing, namely "don't colour highlight # this, use the default output colour" # plain=off newtext=darkgreen oldtext=darkred diffstuff=darkcyan cvsstuff=white colordiff-1.0.16.orig/Makefile0000644000000000000000000000403112542341370013032 0ustar INSTALL_DIR=/usr/local/bin MAN_DIR=/usr/local/man/man1 ETC_DIR=/etc VERSION=$(shell egrep '^my .version' colordiff.pl |cut -f 2 -d "'") DIST_FILES=COPYING INSTALL Makefile README \ colordiff.pl colordiffrc colordiffrc-lightbg cdiff.sh BUGS CHANGES colordiff.1 \ colordiff.xml cdiff.xml cdiff.1 colordiffrc-gitdiff TMPDIR=colordiff-${VERSION} TARBALL=${TMPDIR}.tar.gz .PHONY: doc doc: colordiff.xml cdiff.xml xmlto -vv man colordiff.xml xmlto -vv man cdiff.xml xmlto -vv txt colordiff.xml xmlto -vv html-nochunks colordiff.xml mv colordiff.txt README perl -p -i -e 's###' colordiff.html perl -p -i -e 's###' colordiff.html perl -p -i -e 's#
\ ${DESTDIR}${INSTALL_DIR}/colordiff chmod +x ${DESTDIR}${INSTALL_DIR}/colordiff if [ ! -f ${DESTDIR}${INSTALL_DIR}/cdiff ] ; then \ install cdiff.sh ${DESTDIR}${INSTALL_DIR}/cdiff; \ fi install -Dm 644 colordiff.1 ${DESTDIR}${MAN_DIR}/colordiff.1 install -Dm 644 cdiff.1 ${DESTDIR}${MAN_DIR}/cdiff.1 if [ -f ${DESTDIR}${ETC_DIR}/colordiffrc ]; then \ mv -f ${DESTDIR}${ETC_DIR}/colordiffrc \ ${DESTDIR}${ETC_DIR}/colordiffrc.old; \ else \ install -d ${DESTDIR}${ETC_DIR}; \ fi cp colordiffrc ${DESTDIR}${ETC_DIR}/colordiffrc -chown root.root ${DESTDIR}${ETC_DIR}/colordiffrc chmod 644 ${DESTDIR}${ETC_DIR}/colordiffrc .PHONY: uninstall uninstall: rm -f ${DESTDIR}${INSTALL_DIR}/colordiff rm -f ${DESTDIR}${ETC_DIR}/colordiffrc rm -f ${DESTDIR}${INSTALL_DIR}/cdiff rm -f ${DESTDIR}${MAN_DIR}/colordiff.1 rm -f ${DESTDIR}${MAN_DIR}/cdiff.1 .PHONY: dist dist: mkdir ${TMPDIR} cp -p ${DIST_FILES} ${TMPDIR} tar -zcvf ${TARBALL} ${TMPDIR} rm -fR ${TMPDIR} .PHONY: gitclean gitclean: rm -f colordiff.1 colordiff.html cdiff.1 .PHONY: clean clean: rm -f README colordiff.1 colordiff.html cdiff.1 colordiff-1.0.16.orig/colordiffrc0000644000000000000000000000170312306666455013630 0ustar # Example colordiffrc file for dark backgrounds # # Set banner=no to suppress authorship info at top of # colordiff output banner=no # By default, when colordiff output is being redirected # to a file, it detects this and does not colour-highlight # 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, # darkwhite, darkyellow, darkgreen, # darkblue, darkcyan, darkred, # darkmagenta, darkblack # # Can also specify 'none', 'normal' or 'off' which are all # aliases for the same thing, namely "don't colour highlight # this, use the default output colour" # plain=off newtext=darkgreen oldtext=darkred diffstuff=darkcyan cvsstuff=cyan colordiff-1.0.16.orig/README0000644000000000000000000000667212527321420012264 0ustar Name colordiff — a tool to colorize diff output Synopsis colordiff [diff options] [colordiff options] {file1} {file2} Description colordiff is a wrapper for diff and produces the same output as diff but with coloured syntax highlighting at the command line to improve readability. The output is similar to how a diff-generated patch might appear in Vim 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 ~ /.colordiffrc file. colordiff makes use of ANSI colours and as such will only work when ANSI colours can be used - typical examples are xterms and Eterms, as well as console sessions. colordiff has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems. Usage Use colordiff wherever you would normally use diff, or instead pipe output to colordiff: For example: $ colordiff file1 file2 $ diff -u file1 file2 | colordiff 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': $ diff -u file1 file2 | colordiff | less -R If you want to force disable colour escape sequences (for example pipe the output to patch), you can use option '--color=no' to do so: $ diff -u file1 file2 | colordiff --color=no | patch -p0 -d another-working-dir If you have wdiff installed, colordiff will correctly colourise the added and removed text, provided that the '-n' option is given to wdiff: $ wdiff -n file1 file2 | colordiff You may find it useful to make diff automatically call colordiff. Add the following line to ~/.bashrc (or equivalent): alias diff=colordiff 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: function cvsdiff () { cvs diff $@ | colordiff; } Or, combining the idea above using 'less': function cvsdiff () { cvs diff $@ | colordiff |less -R; } Note that the function name, cvsdiff, can be customized. By default colordiff returns the exit code of the underlying diff invocation (if there is one), but there are some circumstances where it is useful to force colordiff's exit code to be zero: to do this use the option '--fakeexitcode': colordiff --fakeexitcode ... Files /etc/colordiffrc Central configuration file. User-specific settings can be enabled by copying this file to ~/.colordiffrc and making the appropriate changes. colordiffrc-lightbg Alternate configuration template for use with terminals having light backgrounds. Copy this to /etc/colordiffrc or ~/.colordiffrc and customize. colordiffrc-gitdiff Alternate configuration template for use with terminals having dark backgrounds, with colour defaults set to match the output of 'git diff'. Copy this to /etc/colordiffrc or ~/.colordiffrc and customize. Bugs Bug reports and suggestions/patches to please. colordiff-1.0.16.orig/cdiff.xml0000644000000000000000000000371412037610653013200 0ustar diff"> cdiff"> ]> Ville Skyttä cdiff author Dave Ewart colordiff author, packager for colordiff/cdiff cdiff cdiff 1 User Commands cdiff a wrapper tool for colordiff cdiff URL|FILE Description &cdiff; is a wrapper for colordiff and will add colour to a diff given in a URL or a file, e.g. cdiff http://some.url.com/foo/thing.patch 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. See Also &cdiff; is part of the colordiff package, which should be consulted for further reference. colordiff-1.0.16.orig/colordiffrc-lightbg0000644000000000000000000000170312037610653015234 0ustar # Example colordiffrc file for light backgrounds # # Set banner=no to suppress authorship info at top of # colordiff output banner=no # By default, when colordiff output is being redirected # to a file, it detects this and does not colour-highlight # 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, # darkwhite, darkyellow, darkgreen, # darkblue, darkcyan, darkred, # darkmagenta, darkblack # # Can also specify 'none', 'normal' or 'off' which are all # aliases for the same thing, namely "don't colour highlight # this, use the default output colour" # plain=off newtext=blue oldtext=red diffstuff=darkgreen cvsstuff=darkmagenta colordiff-1.0.16.orig/colordiff.pl0000755000000000000000000004237312613166450013717 0ustar #!/usr/bin/perl -w ######################################################################## # # # ColorDiff - a wrapper/replacement for 'diff' producing # # colourful output # # # # Copyright (C)2002-2015 Dave Ewart (davee@sungate.co.uk) # # # ######################################################################## # # # 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. # # # ######################################################################## use strict; use Getopt::Long qw(:config pass_through no_auto_abbrev); my $app_name = 'colordiff'; my $version = '1.0.16'; my $author = 'Dave Ewart'; my $author_email = 'davee@sungate.co.uk'; my $app_www = 'http://www.colordiff.org/'; my $copyright = '(C)2002-2015'; my $show_banner = 1; my $color_patch = 0; my $diff_cmd = "diff"; # ANSI sequences for colours my %colour; $colour{white} = "\033[1;37m"; $colour{yellow} = "\033[1;33m"; $colour{green} = "\033[1;32m"; $colour{blue} = "\033[1;34m"; $colour{cyan} = "\033[1;36m"; $colour{red} = "\033[1;31m"; $colour{magenta} = "\033[1;35m"; $colour{black} = "\033[1;30m"; $colour{darkwhite} = "\033[0;37m"; $colour{darkyellow} = "\033[0;33m"; $colour{darkgreen} = "\033[0;32m"; $colour{darkblue} = "\033[0;34m"; $colour{darkcyan} = "\033[0;36m"; $colour{darkred} = "\033[0;31m"; $colour{darkmagenta} = "\033[0;35m"; $colour{darkblack} = "\033[0;30m"; $colour{off} = "\033[0;0m"; # Default colours if /etc/colordiffrc or ~/.colordiffrc do not exist my $plain_text = $colour{white}; my $file_old = $colour{red}; my $file_new = $colour{blue}; my $diff_stuff = $colour{magenta}; my $cvs_stuff = $colour{green}; # Locations for personal and system-wide colour configurations my $HOME = $ENV{HOME}; my $etcdir = '/etc'; my ($setting, $value); my @config_files = ("$etcdir/colordiffrc"); if (defined $ENV{XDG_CONFIG_HOME} && $ENV{XDG_CONFIG_HOME} ne '') { push (@config_files, "$ENV{XDG_CONFIG_HOME}/colordiff/colordiffrc") } elsif (defined $ENV{HOME}) { push (@config_files, "$ENV{HOME}/.config/colordiff/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; my $ddash = 0; while (my $arg = shift) { if ($arg eq "--") { $ddash = 1; next; } if ($ddash || $arg eq "-") { $nonopts++; next; } if ($arg !~ /^-/) { $nonopts++; } if ($arg eq "--help" || $arg eq "--version" || $arg eq "-v") { $nonopts++; } } return $nonopts; } sub detect_diff_type { # Two parameters: # $record is line in which a diff format has to be detected # $allow_diffy is flag indicating whether diffy is a # permitted diff type my $record = shift; my $allow_diffy = shift; # This may not be perfect - should identify most reasonably # formatted diffs and patches # 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'; } return 'unknown'; } my $enable_verifymode; my $specified_difftype; my $enable_fakeexitcode; my $color_mode = "auto"; GetOptions( # --enable-verifymode option is for testing behaviour of colordiff # against standard test diffs "verifymode" => \$enable_verifymode, "fakeexitcode" => \$enable_fakeexitcode, "difftype=s" => \$specified_difftype, "color=s" => \$color_mode ); $_ = $specified_difftype; if (defined $_ and not /^diff[cuy]?|(deb|w)diff$/) { print STDERR "Invalid --difftype value\n"; } 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 () { my $colourval; chop; next if (/^#/ || /^$/); s/\s+//g; ($setting, $value) = split ('='); if (!defined $value) { print STDERR "Invalid configuration line ($_) in $config_file\n"; next; } if ($setting eq 'banner') { if ($value eq 'no') { $show_banner = 0; } next; } if ($setting eq 'color_patches') { if ($value eq 'yes') { $color_patch = 1; } 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')) { $value = 'off'; } if ($value =~ m/[0-9]+/ && $value >= 0 && $value <= 255) { # Numeric color if( $value < 8 ) { $colourval = "\033[0;3${value}m"; } elsif( $value < 15 ) { $colourval = "\033[0;9" . (${value} - 8) . "m"; } else { $colourval = "\033[0;38;5;${value}m"; } } elsif (defined($colour{$value})) { $colourval = $colour{$value}; } else { print STDERR "Invalid colour specification for setting $setting ($value) in $config_file\n"; next; } if ($setting eq 'plain') { $plain_text = $colourval; } elsif ($setting eq 'oldtext') { $file_old = $colourval; } elsif ($setting eq 'newtext') { $file_new = $colourval; } elsif ($setting eq 'diffstuff') { $diff_stuff = $colourval; } elsif ($setting eq 'cvsstuff') { $cvs_stuff = $colourval; } else { print STDERR "Unknown option in $config_file: $setting\n"; } } close COLORDIFFRC; } } # --color=yes and --color=no will override the color_patches setting if ($color_mode eq "yes") { $color_patch = 1; } elsif ($color_mode eq "no") { $color_patch = 0; } # If output is to a file, switch off colours, unless 'color_patch' is set, # which might be due to --color=no being specified # Relates to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378563 if ((-f STDOUT) && ($color_patch == 0)) { $plain_text = ''; $file_old = ''; $file_new = ''; $diff_stuff = ''; $cvs_stuff = ''; $plain_text = ''; $colour{off} = ''; } # Disable output buffering. This allows "producer | colordiff | less" to output # earlier without having to wait for 'producer' to finish. select STDOUT; $| = 1; # ---------------------------------------------------------------------------- if ($show_banner == 1) { print STDERR "$app_name $version ($app_www)\n"; print STDERR "$copyright $author, $author_email\n\n"; } my $operating_methodology; if (check_for_file_arguments (@ARGV)) { $operating_methodology = 1; # we have files as arg, so we act as diff } else { $operating_methodology = 2; # no files as args, so operate as filter } my @inputstream; my $inputhandle; my $pid; if ($operating_methodology == 1) { # Feed stdin of colordiff with output from the diff program $pid = open($inputhandle, "-|", "$diff_cmd", @ARGV); } else { $inputhandle = \*STDIN; } # Input stream has been read - need to examine it # to determine type of diff we have. # $lastline is false if the input is EOF. If true, then either more data is # available, or the last read succeeded (and the next read may return EOF). # Initially assume that the input is not EOF (for obvious reasons). my $lastline = 1; my $record; if (defined $specified_difftype) { $diff_type = $specified_difftype; # diffy needs at least one line to look at if ($diff_type eq 'diffy') { if (defined($_ = <$inputhandle>)) { push @inputstream, $_; } $lastline = $_; } } else { # Detect diff type, diffy is permitted while (<$inputhandle>) { push @inputstream, $_; $diff_type = detect_diff_type($_, 1); last if $diff_type ne 'unknown'; } $lastline = $_; } my $inside_file_old = 1; # ------------------------------------------------------------------------------ # Special pre-processing for side-by-side diffs # Figure out location of central markers: these will be a consecutive set of # three columns where the first and third always consist of spaces and the # second consists only of spaces, '<', '>' and '|' # This is not a 100% certain match, but should be good enough my $diffy_sep_col = 0; my $mostlikely_sum = 0; if ($diff_type eq 'diffy') { # Not very elegant, but does the job my $longest_record = -1; my %separator_col = (); my %candidate_col = (); my $possible_cols = 0; my @checkbuffer; (@checkbuffer, @inputstream) = (@inputstream, @checkbuffer); while (@checkbuffer) { $_ = shift @checkbuffer; push @inputstream, $_; $_ = expand_tabs_to_spaces $_; if (length ($_) > $longest_record) { my $i = $longest_record + 1; $longest_record = length ($_); while ($i <= $longest_record) { $separator_col{$i} = 1; $candidate_col{$i} = 0; $i++; } } for (my $i = 0 ; $i < (length ($_) - 2) ; $i++) { next if ($separator_col{$i} == 0); next if ($_ =~ /^(Index: |={4,}|RCS file: |retrieving |diff )/); my $subsub = substr ($_, $i, 2); if ($subsub !~ / [ (|<>]/) { $separator_col{$i} = 0; if ($candidate_col{$i} > 0) { $possible_cols--; } } if ($subsub =~ / [|<>]/) { $candidate_col{$i}++; if ($candidate_col{$i} == 1) { $possible_cols++; } } } if ( !@checkbuffer ) { if (! (defined $specified_difftype) and $possible_cols == 0 && detect_diff_type($_, 0) ne 'unknown') { $diff_type = detect_diff_type($_, 0); last; } if (defined ($_ = <$inputhandle>)) { push @checkbuffer, $_; } $lastline = $_; } } for (my $i = 0 ; $i < $longest_record - 2 ; $i++) { if ($separator_col{$i} == 1) { if ($candidate_col{$i} > $mostlikely_sum) { $diffy_sep_col = $i; $mostlikely_sum = $i; } } } # 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 foreach (@inputstream) { $diff_type = detect_diff_type($_, 0); last if $diff_type ne 'unknown'; } } } # ------------------------------------------------------------------------------ while (defined( $_ = @inputstream ? shift @inputstream : ($lastline and <$inputhandle>) )) { if (/^Binary files (.*) and (.*) differ$/) { print "Binary files $file_old$1$plain_text and $file_new$2$plain_text differ\n"; next; } if ($diff_type eq 'diff') { if (/^/) { print "$file_new"; } elsif (/^[0-9]/) { print "$diff_stuff"; } elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } elsif (/^Only in/) { print "$diff_stuff"; } else { print "$plain_text"; } } elsif ($diff_type eq 'diffc') { if (/^- /) { print "$file_old"; } elsif (/^\+ /) { print "$file_new"; } elsif (/^\*{4,}/) { print "$diff_stuff"; } elsif (/^Only in/) { print "$diff_stuff"; } elsif (/^\*\*\* [0-9]+,[0-9]+/) { print "$diff_stuff"; $inside_file_old = 1; } elsif (/^\*\*\* /) { print "$file_old"; } elsif (/^--- [0-9]+,[0-9]+/) { print "$diff_stuff"; $inside_file_old = 0; } elsif (/^--- /) { print "$file_new"; } elsif (/^!/) { if ($inside_file_old == 1) { print "$file_old"; } else { print "$file_new"; } } elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } else { print "$plain_text"; } } elsif ($diff_type eq 'diffu') { if (/^-/) { print "$file_old"; } elsif (/^\+/) { print "$file_new"; } elsif (/^\@/) { print "$diff_stuff"; } elsif (/^Only in/) { print "$diff_stuff"; } elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { print "$cvs_stuff"; } else { print "$plain_text"; } } # Works with previously-identified column containing the diff-y # separator characters elsif ($diff_type eq 'diffy') { $_ = expand_tabs_to_spaces $_; if (length ($_) > ($diffy_sep_col + 2)) { my $sepchars = substr ($_, $diffy_sep_col, 2); if ($sepchars eq ' <') { print "$file_old"; } elsif ($sepchars eq ' |') { print "$diff_stuff"; } elsif ($sepchars eq ' >') { print "$file_new"; } else { print "$plain_text"; } } elsif (/^Only in/) { print "$diff_stuff"; } else { print "$plain_text"; } } elsif ($diff_type eq 'wdiff') { $_ =~ 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/$/$colour{off}/; print "$_"; } my $exitcode = 0; if ($operating_methodology == 1) { waitpid $pid, 0; $exitcode=$? >> 8; } if (defined $enable_fakeexitcode) { exit 0; } else { exit $exitcode; } colordiff-1.0.16.orig/cdiff.10000644000000000000000000000373112527321312012532 0ustar '\" t .\" Title: cdiff .\" Author: Ville Skytt\(:a .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 05/21/2015 .\" Manual: User Commands .\" Source: cdiff .\" Language: English .\" .TH "CDIFF" "1" "05/21/2015" "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 \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 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