# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # contrib/diff/ # contrib/diff/README # contrib/diff/ABOUT-NLS # contrib/diff/AUTHORS # contrib/diff/COPYING # contrib/diff/ChangeLog # contrib/diff/Makefile.am # contrib/diff/NEWS # contrib/diff/THANKS # contrib/diff/exgettext # contrib/diff/INSTALLME # contrib/diff/doc # contrib/diff/doc/fdl.texi # contrib/diff/doc/Makefile.am # contrib/diff/doc/stamp-vti # contrib/diff/doc/version.texi # contrib/diff/doc/diff.texi # contrib/diff/doc/diagmeet.note # contrib/diff/doc/diff.info # contrib/diff/lib # contrib/diff/lib/c-stack.h # contrib/diff/lib/cmpbuf.h # contrib/diff/lib/dirname.h # contrib/diff/lib/error.h # contrib/diff/lib/exclude.h # contrib/diff/lib/exitfail.h # contrib/diff/lib/fnmatch.hin # contrib/diff/lib/freesoft.h # contrib/diff/lib/getopt.h # contrib/diff/lib/gettext.h # contrib/diff/lib/hard-locale.h # contrib/diff/lib/inttostr.h # contrib/diff/lib/prepargs.h # contrib/diff/lib/posixver.h # contrib/diff/lib/quotesys.h # contrib/diff/lib/regex.hin # contrib/diff/lib/setmode.h # contrib/diff/lib/unlocked-io.h # contrib/diff/lib/xalloc.h # contrib/diff/lib/xstrtol.h # contrib/diff/lib/Makefile.am # contrib/diff/lib/alloca.c # contrib/diff/lib/fnmatch.c # contrib/diff/lib/malloc.c # contrib/diff/lib/memchr.c # contrib/diff/lib/mkstemp.c # contrib/diff/lib/realloc.c # contrib/diff/lib/regex.c # contrib/diff/lib/strcasecmp.c # contrib/diff/lib/strtoul.c # contrib/diff/lib/strtoull.c # contrib/diff/lib/strtoumax.c # contrib/diff/lib/tempname.c # contrib/diff/lib/waitpid.c # contrib/diff/lib/basename.c # contrib/diff/lib/c-stack.c # contrib/diff/lib/cmpbuf.c # contrib/diff/lib/error.c # contrib/diff/lib/exclude.c # contrib/diff/lib/exitfail.c # contrib/diff/lib/freesoft.c # contrib/diff/lib/getopt.c # contrib/diff/lib/getopt1.c # contrib/diff/lib/hard-locale.c # contrib/diff/lib/imaxtostr.c # contrib/diff/lib/offtostr.c # contrib/diff/lib/prepargs.c # contrib/diff/lib/posixver.c # contrib/diff/lib/quotesys.c # contrib/diff/lib/setmode.c # contrib/diff/lib/strftime.c # contrib/diff/lib/umaxtostr.c # contrib/diff/lib/xmalloc.c # contrib/diff/lib/xstrtoumax.c # contrib/diff/lib/inttostr.c # contrib/diff/lib/strtoimax.c # contrib/diff/lib/strtol.c # contrib/diff/lib/xstrtol.c # contrib/diff/lib/posix # contrib/diff/lib/posix/Makefile.am # contrib/diff/lib/posix/regex.h # contrib/diff/src # contrib/diff/src/diff.h # contrib/diff/src/system.h # contrib/diff/src/Makefile.am # contrib/diff/src/cmp.c # contrib/diff/src/version.c # contrib/diff/src/analyze.c # contrib/diff/src/context.c # contrib/diff/src/diff.c # contrib/diff/src/dir.c # contrib/diff/src/ed.c # contrib/diff/src/ifdef.c # contrib/diff/src/io.c # contrib/diff/src/normal.c # contrib/diff/src/side.c # contrib/diff/src/util.c # contrib/diff/src/diff3.c # contrib/diff/src/sdiff.c # contrib/diff/man # contrib/diff/man/cmp.1 # contrib/diff/man/diff.1 # contrib/diff/man/diff3.1 # contrib/diff/man/sdiff.1 # contrib/diff/man/Makefile.am # echo c - contrib/diff/ mkdir -p contrib/diff/ > /dev/null 2>&1 echo x - contrib/diff/README sed 's/^X//' >contrib/diff/README << 'END-of-contrib/diff/README' XREADME for GNU DIFF X X Copyright (C) 1992, 1998, 2001, 2002 Free Software Foundation, Inc. X X This file is part of GNU Diffutils. X X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 2, or (at your option) X any later version. X X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with this program; see the file COPYING. If not, write to X the Free Software Foundation, Inc., 59 Temple Place - Suite 330, X Boston, MA 02111-1307, USA. X X XThis directory contains the GNU diff, diff3, sdiff, and cmp utilities. XTheir features are a superset of the Unix features and they are Xsignificantly faster. X XPlease see the file COPYING for copying conditions. X XPlease see the file doc/diff.texi (or doc/diff.info) for documentation Xthat can be printed with TeX, or read with the `info' program or with XEmacs's `M-x info'. There are no man pages. X XSee the file INSTALL for generic compilation and installation instructions, Xand the file INSTALLME for instructions specific to GNU diff. X XSee the file ABOUT-NLS for notes about translations. X XPlease report bugs to . END-of-contrib/diff/README echo x - contrib/diff/ABOUT-NLS sed 's/^X//' >contrib/diff/ABOUT-NLS << 'END-of-contrib/diff/ABOUT-NLS' XNotes on the Free Translation Project X************************************* X X Free software is going international! The Free Translation Project Xis a way to get maintainers of free software, translators, and users all Xtogether, so that will gradually become able to speak many languages. XA few packages already provide translations for their messages. X X If you found this `ABOUT-NLS' file inside a distribution, you may Xassume that the distributed package does use GNU `gettext' internally, Xitself available at your nearest GNU archive site. But you do _not_ Xneed to install GNU `gettext' prior to configuring, installing or using Xthis package with messages translated. X X Installers will find here some useful hints. These notes also Xexplain how users should proceed for getting the programs to use the Xavailable translations. They tell how people wanting to contribute and Xwork at translations should contact the appropriate team. X X When reporting bugs in the `intl/' directory or bugs which may be Xrelated to internationalization, you should tell about the version of X`gettext' which is used. The information can be found in the X`intl/VERSION' file, in internationalized packages. X XQuick configuration advice X========================== X X If you want to exploit the full power of internationalization, you Xshould configure it using X X ./configure --with-included-gettext X Xto force usage of internationalizing routines provided within this Xpackage, despite the existence of internationalizing capabilities in the Xoperating system where this package is being installed. So far, only Xthe `gettext' implementation in the GNU C library version 2 provides as Xmany features (such as locale alias, message inheritance, automatic Xcharset conversion or plural form handling) as the implementation here. XIt is also not possible to offer this additional functionality on top Xof a `catgets' implementation. Future versions of GNU `gettext' will Xvery likely convey even more functionality. So it might be a good idea Xto change to GNU `gettext' as soon as possible. X X So you need _not_ provide this option if you are using GNU libc 2 or Xyou have installed a recent copy of the GNU gettext package with the Xincluded `libintl'. X XINSTALL Matters X=============== X X Some packages are "localizable" when properly installed; the Xprograms they contain can be made to speak your own native language. XMost such packages use GNU `gettext'. Other packages have their own Xways to internationalization, predating GNU `gettext'. X X By default, this package will be installed to allow translation of Xmessages. It will automatically detect whether the system already Xprovides the GNU `gettext' functions. If not, the GNU `gettext' own Xlibrary will be used. This library is wholly contained within this Xpackage, usually in the `intl/' subdirectory, so prior installation of Xthe GNU `gettext' package is _not_ required. Installers may use Xspecial options at configuration time for changing the default Xbehaviour. The commands: X X ./configure --with-included-gettext X ./configure --disable-nls X Xwill respectively bypass any pre-existing `gettext' to use the Xinternationalizing routines provided within this package, or else, X_totally_ disable translation of messages. X X When you already have GNU `gettext' installed on your system and run Xconfigure without an option for your new package, `configure' will Xprobably detect the previously built and installed `libintl.a' file and Xwill decide to use this. This might be not what is desirable. You Xshould use the more recent version of the GNU `gettext' library. I.e. Xif the file `intl/VERSION' shows that the library which comes with this Xpackage is more recent, you should use X X ./configure --with-included-gettext X Xto prevent auto-detection. X X The configuration process will not test for the `catgets' function Xand therefore it will not be used. The reason is that even an Xemulation of `gettext' on top of `catgets' could not provide all the Xextensions of the GNU `gettext' library. X X Internationalized packages have usually many `po/LL.po' files, where XLL gives an ISO 639 two-letter code identifying the language. Unless Xtranslations have been forbidden at `configure' time by using the X`--disable-nls' switch, all available translations are installed Xtogether with the package. However, the environment variable `LINGUAS' Xmay be set, prior to configuration, to limit the installed set. X`LINGUAS' should then contain a space separated list of two-letter Xcodes, stating which languages are allowed. X XUsing This Package X================== X X As a user, if your language has been installed for this package, you Xonly have to set the `LANG' environment variable to the appropriate X`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, Xand `CC' is an ISO 3166 two-letter country code. For example, let's Xsuppose that you speak German and live in Germany. At the shell Xprompt, merely execute `setenv LANG de_DE' (in `csh'), X`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). XThis can be done from your `.login' or `.profile' file, once and for Xall. X X You might think that the country code specification is redundant. XBut in fact, some languages have dialects in different countries. For Xexample, `de_AT' is used for Austria, and `pt_BR' for Brazil. The Xcountry code serves to distinguish the dialects. X X The locale naming convention of `LL_CC', with `LL' denoting the Xlanguage and `CC' denoting the country, is the one use on systems based Xon GNU libc. On other systems, some variations of this scheme are Xused, such as `LL' or `LL_CC.ENCODING'. You can get the list of Xlocales supported by your system for your country by running the command X`locale -a | grep '^LL''. X X Not all programs have translations for all languages. By default, an XEnglish message is shown in place of a nonexistent translation. If you Xunderstand other languages, you can set up a priority list of languages. XThis is done through a different environment variable, called X`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' Xfor the purpose of message handling, but you still need to have `LANG' Xset to the primary language; this is required by other parts of the Xsystem libraries. For example, some Swedish users who would rather Xread translations in German than English for when Swedish is not Xavailable, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. X X In the `LANGUAGE' environment variable, but not in the `LANG' Xenvironment variable, `LL_CC' combinations can be abbreviated as `LL' Xto denote the language's main dialect. For example, `de' is equivalent Xto `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' X(Portuguese as spoken in Portugal) in this context. X XTranslating Teams X================= X X For the Free Translation Project to be a success, we need interested Xpeople who like their own language and write it well, and who are also Xable to synergize with other translators speaking the same language. XEach translation team has its own mailing list. The up-to-date list of Xteams can be found at the Free Translation Project's homepage, X`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" Xarea. X X If you'd like to volunteer to _work_ at translating messages, you Xshould become a member of the translating team for your own language. XThe subscribing address is _not_ the same as the list itself, it has X`-request' appended. For example, speakers of Swedish can send a Xmessage to `sv-request@li.org', having this message body: X X subscribe X X Keep in mind that team members are expected to participate X_actively_ in translations, or at solving translational difficulties, Xrather than merely lurking around. If your team does not exist yet and Xyou want to start one, or if you are unsure about what to do or how to Xget started, please write to `translation@iro.umontreal.ca' to reach the Xcoordinator for all translator teams. X X The English team is special. It works at improving and uniformizing Xthe terminology in use. Proven linguistic skill are praised more than Xprogramming skill, here. X XAvailable Packages X================== X X Languages are not equally supported in all packages. The following Xmatrix shows the current state of internationalization, as of March X2002. The matrix shows, in regard of each package, for which languages XPO files have been submitted to translation coordination, with a Xtranslation percentage of at least 50%. X X Ready PO files bg ca cs da de el en eo es et fi fr X +-------------------------------------+ X a2ps | [] [] [] [] | X bash | [] [] [] [] | X bfd | [] [] | X binutils | [] [] | X bison | [] [] [] | X clisp | [] [] [] [] | X cpio | [] [] [] [] | X diffutils | [] [] [] [] [] [] | X enscript | [] [] | X error | [] [] | X fetchmail | () [] [] [] () | X fileutils | [] [] [] [] [] | X findutils | [] [] [] [] [] | X flex | [] [] [] [] | X gas | [] [] | X gawk | [] [] | X gcal | [] [] | X gcc | [] [] | X gettext | [] [] [] [] [] | X gnupg | [] [] [] [] [] [] | X gprof | [] [] | X grep | [] [] [] [] [] [] | X hello | [] [] [] [] [] [] [] [] | X id-utils | [] [] [] | X indent | [] [] [] [] [] | X jpilot | () [] [] [] | X jwhois | [] [] | X kbd | [] [] | X ld | [] [] | X libc | [] [] [] [] [] [] [] | X lilypond | [] [] | X lynx | [] [] [] [] | X m4 | [] [] [] [] [] | X make | [] [] [] [] | X mysecretdiary | [] [] | X nano | [] () [] [] [] [] | X nano_1_0 | [] () [] [] [] [] | X opcodes | [] [] [] | X parted | [] [] [] [] | X ptx | [] [] [] [] [] | X python | | X recode | [] [] [] [] [] [] | X sed | [] [] [] [] [] [] [] [] | X sh-utils | [] [] [] [] [] [] [] [] | X sharutils | [] [] [] [] [] [] | X sketch | () [] () | X soundtracker | [] [] [] | X sp | | X tar | [] [] [] [] [] [] | X texinfo | [] [] [] [] [] | X textutils | [] [] [] [] [] | X util-linux | [] [] [] [] | X vorbis-tools | | X wdiff | [] [] [] [] [] | X wget | [] [] [] [] [] [] [] [] | X +-------------------------------------+ X bg ca cs da de el en eo es et fi fr X 1 12 11 31 36 9 1 8 39 15 1 50 X X gl he hr hu id it ja ko lv nb nl nn X +-------------------------------------+ X a2ps | () () [] | X bash | | X bfd | [] | X binutils | [] | X bison | [] [] | X clisp | [] | X cpio | [] [] [] | X diffutils | [] [] [] | X enscript | [] | X error | [] | X fetchmail | | X fileutils | [] [] [] | X findutils | [] [] [] [] [] [] | X flex | [] | X gas | | X gawk | [] | X gcal | | X gcc | | X gettext | [] | X gnupg | [] [] [] | X gprof | | X grep | [] | X hello | [] [] [] [] [] [] [] [] [] [] | X id-utils | [] | X indent | [] [] [] | X jpilot | () () | X jwhois | | X kbd | | X ld | | X libc | [] [] [] [] | X lilypond | [] [] | X lynx | [] [] | X m4 | [] [] [] [] | X make | [] [] [] [] | X mysecretdiary | | X nano | [] [] [] () [] () [] | X nano_1_0 | [] [] [] () [] () [] | X opcodes | [] | X parted | [] [] [] | X ptx | [] [] [] [] | X python | | X recode | [] [] [] | X sed | [] [] [] [] [] [] [] | X sh-utils | [] [] [] [] [] | X sharutils | [] [] [] | X sketch | () | X soundtracker | [] | X sp | | X tar | [] [] [] | X texinfo | [] [] | X textutils | [] [] | X util-linux | () [] | X vorbis-tools | | X wdiff | | X wget | [] [] [] [] [] | X +-------------------------------------+ X gl he hr hu id it ja ko lv nb nl nn X 19 7 0 4 6 11 22 9 1 8 19 4 X X no pl pt pt_BR ru sk sl sv tr uk zh_TW X +----------------------------------------+ X a2ps | () () () [] [] [] () | 8 X bash | | 4 X bfd | [] [] | 5 X binutils | [] | 4 X bison | [] [] [] | 8 X clisp | | 5 X cpio | [] [] [] [] | 11 X diffutils | [] [] [] [] [] | 14 X enscript | [] [] [] | 6 X error | [] [] [] | 6 X fetchmail | () () [] | 4 X fileutils | [] [] [] [] | 12 X findutils | [] [] [] [] [] [] [] | 18 X flex | [] [] [] | 8 X gas | [] | 3 X gawk | [] [] | 5 X gcal | [] [] | 4 X gcc | [] | 3 X gettext | [] [] [] [] | 10 X gnupg | [] [] [] | 12 X gprof | [] [] | 4 X grep | [] [] [] | 10 X hello | [] [] [] [] [] [] [] | 25 X id-utils | [] [] | 6 X indent | [] [] [] [] | 12 X jpilot | () () | 3 X jwhois | () () [] | 3 X kbd | [] [] | 4 X ld | [] [] | 4 X libc | [] [] [] [] [] [] | 17 X lilypond | [] | 5 X lynx | [] [] [] | 9 X m4 | [] [] [] | 12 X make | [] [] [] [] | 12 X mysecretdiary | [] [] | 4 X nano | () [] [] [] [] | 14 X nano_1_0 | () [] [] [] | 13 X opcodes | [] [] | 6 X parted | [] [] [] | 10 X ptx | [] [] [] [] [] [] | 15 X python | | 0 X recode | [] [] [] [] | 13 X sed | [] [] [] [] [] [] | 21 X sh-utils | [] [] [] [] [] [] [] [] [] | 22 X sharutils | [] [] [] | 12 X sketch | [] () | 3 X soundtracker | [] | 5 X sp | | 0 X tar | [] [] [] [] [] [] [] | 16 X texinfo | [] [] [] | 10 X textutils | [] [] [] [] | 11 X util-linux | [] [] [] | 8 X vorbis-tools | [] | 1 X wdiff | [] [] [] [] | 9 X wget | [] [] [] [] [] [] [] | 20 X +----------------------------------------+ X 35 teams no pl pt pt_BR ru sk sl sv tr uk zh_TW X 55 domains 5 13 2 12 25 11 11 41 34 4 7 489 X X Some counters in the preceding matrix are higher than the number of Xvisible blocks let us expect. This is because a few extra PO files are Xused for implementing regional variants of languages, or language Xdialects. X X For a PO file in the matrix above to be effective, the package to Xwhich it applies should also have been internationalized and Xdistributed as such by its maintainer. There might be an observable Xlag between the mere existence a PO file and its wide availability in a Xdistribution. X X If March 2002 seems to be old, you may fetch a more recent copy of Xthis `ABOUT-NLS' file on most GNU archive sites. The most up-to-date Xmatrix with full percentage details can be found at X`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. X XUsing `gettext' in new packages X=============================== X X If you are writing a freely available program and want to Xinternationalize it you are welcome to use GNU `gettext' in your Xpackage. Of course you have to respect the GNU Library General Public XLicense which covers the use of the GNU `gettext' library. This means Xin particular that even non-free programs can use `libintl' as a shared Xlibrary, whereas only free software can use `libintl' as a static Xlibrary or use modified versions of `libintl'. X X Once the sources are changed appropriately and the setup can handle Xto use of `gettext' the only thing missing are the translations. The XFree Translation Project is also available for packages which are not Xdeveloped inside the GNU project. Therefore the information given above Xapplies also for every other Free Software Project. Contact X`translation@iro.umontreal.ca' to make the `.pot' files available to Xthe translation teams. X END-of-contrib/diff/ABOUT-NLS echo x - contrib/diff/AUTHORS sed 's/^X//' >contrib/diff/AUTHORS << 'END-of-contrib/diff/AUTHORS' XAuthors of GNU diffutils. X X Copyright 2001 Free Software Foundation, Inc. X X This file is part of GNU diffutils. X X GNU diffutils is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 2, or (at your option) X any later version. X X GNU diffutils is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with GNU diffutils; see the file COPYING. If not, write to X the Free Software Foundation, Inc., 59 Temple Place - Suite 330, X Boston, MA 02111-1307, USA. X XThe following contributions warranted legal paper exchanges with the XFree Software Foundation. Also see files ChangeLog and THANKS. X XDIFFUTILS Leonard H. Tower Jr. US 1949 1987-03-09 XAssigns diff (diff.c, initial version). X XDIFFUTILS Torbjorn Granlund Sweden 1961 1988-01-11 XAssigns cmp. Xtege@matematik.su.se X XDIFFUTILS Mike Haertel US 1967 1988-09-16 XAssigns changes to diff. X XDIFFUTILS David S. Hayes US ? 1988-01-12 XAssigns changes to diff. X XDIFFUTILS Randall Smith US 1964 1988-09-21 XAssigns diff3. X XDIFFUTILS Richard Stallman US 1953 1988-01-15 XAssigns changes to GNU Diff. X XDIFFUTILS F. Thomas May US 1965 1989-08-22 XAssigns changes to diff (for -D). X XDIFFUTILS Optimal Solutions, Inc. 1989-08-14 XDisclaims changes by Thomas May to diff. X XDIFFUTILS Wayne Davison 1990-09-10 XDisclaims changes to diff. X XDIFFUTILS Digital Research Inc. 1990-09-13 XDisclaims changes by Wayne Davison to diff. X XDIFFUTILS Paul Eggert 1990-03-16 XDisclaims changes to diff. Xeggert@twinsun.com X XDIFFUTILS Paul Eggert 1990-08-14 XDisclaims changes to GNU Diff. Xeggert@twinsun.com X XDIFFUTILS Twin Sun Inc. 1990-03-16 XDisclaims changes to GNU Diff by Paul Eggert. X XDIFFUTILS Twin Sun Inc. 1990-08-14 XDisclaims changes to GNU Diff by Paul Eggert. X XDIFFUTILS Chip Rosenthal US 1959 1990-03-06 XAssigns changes to diff. Xchip@chinacat.Unicom.COM X XDIFFUTILS Unicom Systems Development 1990-03-06 XDisclaims changes by Chip Rosenthal to diff. X XGCC DIFFUTILS Paul Eggert and Twin Sun Inc. 1992-03-11 XDisclaims changes by Paul Eggert to gcc and diff. Xeggert@twinsun.com X XDIFF Wayne Davison 1993-06-20 XDisclaims diffcvt.c. X XDIFFUTILS Francois Pinard Canada 1949 1993-01-15 XAssigns wdiff and future changes submitted to the FSF. Xpinard@iro.umontreal.ca X XDIFFUTILS Patrick D'Cruze Australia 1971 1994-11-10 XAssigns changes (makefile.in, analyze.c, cmp.c, error.c, diff.c, Xdiff3.c, getopt.c, getopt1.c, regex.c, sdiff.c, util.c, xmalloc.c; Xnew file: language.++) X XDIFFUTILS Paul R. Eggert US 1954 1997-04-07 XAssigns past and future changes. Xeggert@twinsun.com X XDIFFUTILS Paul R. Eggert US 1954 1997-04-07 XAssigns past and future changes to manual. Xeggert@twinsun.com X XANY DIFFUTILS GNATS Cyclic Software 1997-11-11 XAssigns past and future works (work for hire by Tim Pierce (diffutils) and XAbe Feldman (GNATS)). Xkingdon@cyclic.com X XWEBPAGES Gregory B. Harvey Canada 1976 1998-02-14 XAssigns web pages describing GNU Diffutils and future changes. X XDIFFUTILS Olga Nikulin Russia 1965 2001-01-11 XAssigns changes to diff. (diffutils-2.7.2/analyze.c, context.c, diff.[ch], Xed.c, ifdef.c, io.c, normal.c, side.c, util.c) Xonikulin@yahoo.com END-of-contrib/diff/AUTHORS echo x - contrib/diff/COPYING sed 's/^X//' >contrib/diff/COPYING << 'END-of-contrib/diff/COPYING' X GNU GENERAL PUBLIC LICENSE X Version 2, June 1991 X X Copyright (C) 1989, 1991 Free Software Foundation, Inc. X 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA X Everyone is permitted to copy and distribute verbatim copies X of this license document, but changing it is not allowed. X X Preamble X X The licenses for most software are designed to take away your Xfreedom to share and change it. By contrast, the GNU General Public XLicense is intended to guarantee your freedom to share and change free Xsoftware--to make sure the software is free for all its users. This XGeneral Public License applies to most of the Free Software XFoundation's software and to any other program whose authors commit to Xusing it. (Some other Free Software Foundation software is covered by Xthe GNU Library General Public License instead.) You can apply it to Xyour programs, too. X X When we speak of free software, we are referring to freedom, not Xprice. Our General Public Licenses are designed to make sure that you Xhave the freedom to distribute copies of free software (and charge for Xthis service if you wish), that you receive source code or can get it Xif you want it, that you can change the software or use pieces of it Xin new free programs; and that you know you can do these things. X X To protect your rights, we need to make restrictions that forbid Xanyone to deny you these rights or to ask you to surrender the rights. XThese restrictions translate to certain responsibilities for you if you Xdistribute copies of the software, or if you modify it. X X For example, if you distribute copies of such a program, whether Xgratis or for a fee, you must give the recipients all the rights that Xyou have. You must make sure that they, too, receive or can get the Xsource code. And you must show them these terms so they know their Xrights. X X We protect your rights with two steps: (1) copyright the software, and X(2) offer you this license which gives you legal permission to copy, Xdistribute and/or modify the software. X X Also, for each author's protection and ours, we want to make certain Xthat everyone understands that there is no warranty for this free Xsoftware. If the software is modified by someone else and passed on, we Xwant its recipients to know that what they have is not the original, so Xthat any problems introduced by others will not reflect on the original Xauthors' reputations. X X Finally, any free program is threatened constantly by software Xpatents. We wish to avoid the danger that redistributors of a free Xprogram will individually obtain patent licenses, in effect making the Xprogram proprietary. To prevent this, we have made it clear that any Xpatent must be licensed for everyone's free use or not licensed at all. X X The precise terms and conditions for copying, distribution and Xmodification follow. X X GNU GENERAL PUBLIC LICENSE X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION X X 0. This License applies to any program or other work which contains Xa notice placed by the copyright holder saying it may be distributed Xunder the terms of this General Public License. The "Program", below, Xrefers to any such program or work, and a "work based on the Program" Xmeans either the Program or any derivative work under copyright law: Xthat is to say, a work containing the Program or a portion of it, Xeither verbatim or with modifications and/or translated into another Xlanguage. (Hereinafter, translation is included without limitation in Xthe term "modification".) Each licensee is addressed as "you". X XActivities other than copying, distribution and modification are not Xcovered by this License; they are outside its scope. The act of Xrunning the Program is not restricted, and the output from the Program Xis covered only if its contents constitute a work based on the XProgram (independent of having been made by running the Program). XWhether that is true depends on what the Program does. X X 1. You may copy and distribute verbatim copies of the Program's Xsource code as you receive it, in any medium, provided that you Xconspicuously and appropriately publish on each copy an appropriate Xcopyright notice and disclaimer of warranty; keep intact all the Xnotices that refer to this License and to the absence of any warranty; Xand give any other recipients of the Program a copy of this License Xalong with the Program. X XYou may charge a fee for the physical act of transferring a copy, and Xyou may at your option offer warranty protection in exchange for a fee. X X 2. You may modify your copy or copies of the Program or any portion Xof it, thus forming a work based on the Program, and copy and Xdistribute such modifications or work under the terms of Section 1 Xabove, provided that you also meet all of these conditions: X X a) You must cause the modified files to carry prominent notices X stating that you changed the files and the date of any change. X X b) You must cause any work that you distribute or publish, that in X whole or in part contains or is derived from the Program or any X part thereof, to be licensed as a whole at no charge to all third X parties under the terms of this License. X X c) If the modified program normally reads commands interactively X when run, you must cause it, when started running for such X interactive use in the most ordinary way, to print or display an X announcement including an appropriate copyright notice and a X notice that there is no warranty (or else, saying that you provide X a warranty) and that users may redistribute the program under X these conditions, and telling the user how to view a copy of this X License. (Exception: if the Program itself is interactive but X does not normally print such an announcement, your work based on X the Program is not required to print an announcement.) X XThese requirements apply to the modified work as a whole. If Xidentifiable sections of that work are not derived from the Program, Xand can be reasonably considered independent and separate works in Xthemselves, then this License, and its terms, do not apply to those Xsections when you distribute them as separate works. But when you Xdistribute the same sections as part of a whole which is a work based Xon the Program, the distribution of the whole must be on the terms of Xthis License, whose permissions for other licensees extend to the Xentire whole, and thus to each and every part regardless of who wrote it. X XThus, it is not the intent of this section to claim rights or contest Xyour rights to work written entirely by you; rather, the intent is to Xexercise the right to control the distribution of derivative or Xcollective works based on the Program. X XIn addition, mere aggregation of another work not based on the Program Xwith the Program (or with a work based on the Program) on a volume of Xa storage or distribution medium does not bring the other work under Xthe scope of this License. X X 3. You may copy and distribute the Program (or a work based on it, Xunder Section 2) in object code or executable form under the terms of XSections 1 and 2 above provided that you also do one of the following: X X a) Accompany it with the complete corresponding machine-readable X source code, which must be distributed under the terms of Sections X 1 and 2 above on a medium customarily used for software interchange; or, X X b) Accompany it with a written offer, valid for at least three X years, to give any third party, for a charge no more than your X cost of physically performing source distribution, a complete X machine-readable copy of the corresponding source code, to be X distributed under the terms of Sections 1 and 2 above on a medium X customarily used for software interchange; or, X X c) Accompany it with the information you received as to the offer X to distribute corresponding source code. (This alternative is X allowed only for noncommercial distribution and only if you X received the program in object code or executable form with such X an offer, in accord with Subsection b above.) X XThe source code for a work means the preferred form of the work for Xmaking modifications to it. For an executable work, complete source Xcode means all the source code for all modules it contains, plus any Xassociated interface definition files, plus the scripts used to Xcontrol compilation and installation of the executable. However, as a Xspecial exception, the source code distributed need not include Xanything that is normally distributed (in either source or binary Xform) with the major components (compiler, kernel, and so on) of the Xoperating system on which the executable runs, unless that component Xitself accompanies the executable. X XIf distribution of executable or object code is made by offering Xaccess to copy from a designated place, then offering equivalent Xaccess to copy the source code from the same place counts as Xdistribution of the source code, even though third parties are not Xcompelled to copy the source along with the object code. X X 4. You may not copy, modify, sublicense, or distribute the Program Xexcept as expressly provided under this License. Any attempt Xotherwise to copy, modify, sublicense or distribute the Program is Xvoid, and will automatically terminate your rights under this License. XHowever, parties who have received copies, or rights, from you under Xthis License will not have their licenses terminated so long as such Xparties remain in full compliance. X X 5. You are not required to accept this License, since you have not Xsigned it. However, nothing else grants you permission to modify or Xdistribute the Program or its derivative works. These actions are Xprohibited by law if you do not accept this License. Therefore, by Xmodifying or distributing the Program (or any work based on the XProgram), you indicate your acceptance of this License to do so, and Xall its terms and conditions for copying, distributing or modifying Xthe Program or works based on it. X X 6. Each time you redistribute the Program (or any work based on the XProgram), the recipient automatically receives a license from the Xoriginal licensor to copy, distribute or modify the Program subject to Xthese terms and conditions. You may not impose any further Xrestrictions on the recipients' exercise of the rights granted herein. XYou are not responsible for enforcing compliance by third parties to Xthis License. X X 7. If, as a consequence of a court judgment or allegation of patent Xinfringement or for any other reason (not limited to patent issues), Xconditions are imposed on you (whether by court order, agreement or Xotherwise) that contradict the conditions of this License, they do not Xexcuse you from the conditions of this License. If you cannot Xdistribute so as to satisfy simultaneously your obligations under this XLicense and any other pertinent obligations, then as a consequence you Xmay not distribute the Program at all. For example, if a patent Xlicense would not permit royalty-free redistribution of the Program by Xall those who receive copies directly or indirectly through you, then Xthe only way you could satisfy both it and this License would be to Xrefrain entirely from distribution of the Program. X XIf any portion of this section is held invalid or unenforceable under Xany particular circumstance, the balance of the section is intended to Xapply and the section as a whole is intended to apply in other Xcircumstances. X XIt is not the purpose of this section to induce you to infringe any Xpatents or other property right claims or to contest validity of any Xsuch claims; this section has the sole purpose of protecting the Xintegrity of the free software distribution system, which is Ximplemented by public license practices. Many people have made Xgenerous contributions to the wide range of software distributed Xthrough that system in reliance on consistent application of that Xsystem; it is up to the author/donor to decide if he or she is willing Xto distribute software through any other system and a licensee cannot Ximpose that choice. X XThis section is intended to make thoroughly clear what is believed to Xbe a consequence of the rest of this License. X X 8. If the distribution and/or use of the Program is restricted in Xcertain countries either by patents or by copyrighted interfaces, the Xoriginal copyright holder who places the Program under this License Xmay add an explicit geographical distribution limitation excluding Xthose countries, so that distribution is permitted only in or among Xcountries not thus excluded. In such case, this License incorporates Xthe limitation as if written in the body of this License. X X 9. The Free Software Foundation may publish revised and/or new versions Xof the General Public License from time to time. Such new versions will Xbe similar in spirit to the present version, but may differ in detail to Xaddress new problems or concerns. X XEach version is given a distinguishing version number. If the Program Xspecifies a version number of this License which applies to it and "any Xlater version", you have the option of following the terms and conditions Xeither of that version or of any later version published by the Free XSoftware Foundation. If the Program does not specify a version number of Xthis License, you may choose any version ever published by the Free Software XFoundation. X X 10. If you wish to incorporate parts of the Program into other free Xprograms whose distribution conditions are different, write to the author Xto ask for permission. For software which is copyrighted by the Free XSoftware Foundation, write to the Free Software Foundation; we sometimes Xmake exceptions for this. Our decision will be guided by the two goals Xof preserving the free status of all derivatives of our free software and Xof promoting the sharing and reuse of software generally. X X NO WARRANTY X X 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, XREPAIR OR CORRECTION. X X 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE XPOSSIBILITY OF SUCH DAMAGES. X X END OF TERMS AND CONDITIONS X X How to Apply These Terms to Your New Programs X X If you develop a new program, and you want it to be of the greatest Xpossible use to the public, the best way to achieve this is to make it Xfree software which everyone can redistribute and change under these terms. X X To do so, attach the following notices to the program. It is safest Xto attach them to the start of each source file to most effectively Xconvey the exclusion of warranty; and each file should have at least Xthe "copyright" line and a pointer to where the full notice is found. X X X Copyright (C) X X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 2 of the License, or X (at your option) any later version. X X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with this program; if not, write to the Free Software X Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA X X XAlso add information on how to contact you by electronic and paper mail. X XIf the program is interactive, make it output a short notice like this Xwhen it starts in an interactive mode: X X Gnomovision version 69, Copyright (C) year name of author X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. X This is free software, and you are welcome to redistribute it X under certain conditions; type `show c' for details. X XThe hypothetical commands `show w' and `show c' should show the appropriate Xparts of the General Public License. Of course, the commands you use may Xbe called something other than `show w' and `show c'; they could even be Xmouse-clicks or menu items--whatever suits your program. X XYou should also get your employer (if you work as a programmer) or your Xschool, if any, to sign a "copyright disclaimer" for the program, if Xnecessary. Here is a sample; alter the names: X X Yoyodyne, Inc., hereby disclaims all copyright interest in the program X `Gnomovision' (which makes passes at compilers) written by James Hacker. X X , 1 April 1989 X Ty Coon, President of Vice X XThis General Public License does not permit incorporating your program into Xproprietary programs. If your program is a subroutine library, you may Xconsider it more useful to permit linking proprietary applications with the Xlibrary. If this is what you want to do, use the GNU Library General XPublic License instead of this License. END-of-contrib/diff/COPYING echo x - contrib/diff/ChangeLog sed 's/^X//' >contrib/diff/ChangeLog << 'END-of-contrib/diff/ChangeLog' X2002-04-05 Paul Eggert X X * NEWS, configure.ac (AC_INIT): Version 2.8.1. X X * configure.ac (AC_HEADER_STDBOOL): Add. X (AC_CHECK_HEADERS): Remove stdbool.h. X * m4/stdbool.m4: New file. X * m4/prereq.m4 (jm_PREREQ_EXCLUDE): X Use AC_HEADER_STDBOOL rather than AC_CHECK_HEADERS(stdbool.h). X (jm_PREREQ_HASH): Likewise. X X * src/system.h (SSIZE_MAX): Define if limits.h doesn't. X X * src/analyze.c (diff_2_files): Assign PTRDIFF_MAX - 1 to a X size_t variable, just in case there's a problem with ptrdiff_t X versus size_t. X X * lib/cmpbuf.c (errno): Remove decl; K&R C is no longer supported. X Include limits.h. X (SIZE_MAX, SSIZE_MAX): Define if standard headers don't. X (MIN): New macro. X (block_read): Do not attempt to read more than SSIZE_MAX bytes, as the X resulting behavior is implementation-defined. Work around bug in X Tru64 5.1, which can't read more than INT_MAX bytes at a time. X * src/cmp.c (cmp): Use block_read instead of read, to work X around Tru64 5.1 bug. X * src/diff3.c (read_diff): Likewise. X * src/diff3.c: Include cmpbuf.h. X X * THANKS: Add Ulrich Drepper. X X * INSTALLME: Mention GNU texinfo. X X * doc/diff.texi: X Use new @copying directive. X Put @contents first, not last, since Texinfo now suggests this. X Fix bug in -w documentation noted by Karl Berry. X Mention links for speedup. X New node "Speedups" for future speedups. X Just say "Index", not "Concept Index". X X2002-03-26 Paul Eggert X X * src/Makefile.am: X (INCLUDES): Remove this obsolete macro, replacing it with: X (AM_CPPFLAGS): New macro. X X2002-03-26 Albert Chin-A-Young X X * src/Makefile.am (datadir): Remove, as it conflicts with --datadir. X X2002-03-26 Paul Eggert X X * doc/diff.texi (dircategory GNU packages): Fix typo: a "* " was X missing before the menu entry. Bug diagnosed by Adam Heath. X Also, put this dircategory after the Individual utilities dircategory, X to work around a compatibility problem with Debian install-info. X X2002-03-24 Eli Zaretskii X X * src/io.c (sip): Do not mishandle buffered count when reverting X to text mode. X X2002-03-23 Paul Eggert X X * NEWS, configure.ac (AC_INIT): Version 2.8. X * configure.ac (AC_PREREQ): 2.53. X * INSTALLME: Upgrade to gettext 0.11.1 and help2man 1.27. X X * doc/diff.texi: Upgrade the description of `patch' to GNU patch X 2.5.4, and revamp the documentation accordingly. X X * src/diff.c (main): Fix typo that prevented diff -y from working. X Bug reported by Mitsuru Chinen. X X2002-03-15 Paul Eggert X X * lib/c-stack.c (c_stack_die) [!HAVE_SIGINFO_T]: Don't use info. X Bug reported by Eli Zaretskii. X X2002-03-15 Eli Zaretskii X X * ms/config.sed: Tweak editing of install-info-am target. X X2002-03-12 Paul Eggert X X * NEWS, configure.ac (AC_INIT): Version 2.7.10. X X * NEWS: cmp -l -s and cmp -s -l are not allowed. X Deprecate diff -h, -H, -L, -P, --inhibit-hunk-merge. X X * configure.ac (jm_PREREQ_HARD_LOCALE): Add. X (AM_INIT_AUTOMAKE): Do not distribute shar file. X X * doc/diff.texi (Overview): byte != character. X (Detailed Context, Detailed Unified, Alternate Names, diff Options): X Do not document diff -L. X (Comparing Directories, Making Patches, diff Options): X Do not document diff -P. X (diff Performance, sdiff Option Summary, diff Options, sdiff Options): X Do not document diff -H. X (diff Performance, diff Options): Do not document --horizon-lines. X (cmp Options): Prefer -b to -c. X (cmp Options, diff Options, diff3 Options, patch Options, X sdiff Options): Put short options next to the similar long options. X Document --help, and use the same wording for --verbose. X (diff3 Options): Fix typo in description of -E, which used wrongly used X "-e" instead of "-E". X X * lib/hard-locale.c (alloca): Remove. X Include stdlib.h if available, for malloc. X (hard_locale): Use malloc, not alloca, so that we need not worry about X alloca issues. Test for storage allocation failure. X X * m4/prereq.m4 (jm_PREREQ): Add jm_PREREQ_HARD_LOCALE. X (jm_PREREQ_HARD_LOCALE): New macro. X X * src/cmp.c (specify_comparison_type): New function. X (check_stdout): "indices and codes" -> "byte numbers and values" X (main): Detect clashing options. X (cmp): Use "byte" rather than "char" if a translation for "byte" X is available, even when in the POSIX locale. X X * src/diff.c (option_help_msgid): Do not document -L, -P, X --horizon-lines, --inhibit-hunk-merge, -H. X * src/diff.h: -L -> --label X X2002-03-11 Paul Eggert X X * NEWS, configure.ac (AC_INIT): Version 2.7.9. X X * INSTALLME: Update to autoconf 2.53, automake 1.6, help2man X 1.25 with patch. X X * configure.ac (AC_INIT): X Change package name from diff to diffutils. X (AM_INIT_AUTOMAKE): Use new form, with option gnits, X rather than old from that duplicated AC_INIT. X (AM_MISSING_PROG): Add help2man. X (REGEX_MALLOC): Define. X (AC_CONFIG_FILES): Add man/Makefile. X X * Makefile.am (AUTOMAKE_OPTIONS): Remove. X * doc/Makefile.am (AUTOMAKE_OPTIONS): Remove. X * lib/Makefile.am (AUTOMAKE_OPTIONS): Likewise. X * ms/Makefile.am (AUTOMAKE_OPTIONS): Likewise. X * src/Makefile.am (AUTOMAKE_OPTIONS): Likewise. X X * lib/c-stack.c: Include X (ENOTSUP): Define if errno.h doesn't. X (SA_NODEFER, SA_ONSTACK, SA_RESETHAND, SA_SIGINFO, SIGSTKSZ, X _SC_PAGESIZE, ALTERNATE_STACK_SIZE, stack_t, sigaltstack): X Remove; we now assume them all when X HAVE_XSI_STACK_OVERFLOW_HEURISTIC, so we don't need X substitutes. X (): Include only if HAVE_XSI_STACK_OVERFLOW_HEURISTIC. X (alternate_signal_stack): Now of size SIGSTKSZ. X (segv_handler): Simplify, under the assumption that X HAVE_XSI_STACK_OVERFLOW_HEURISTIC is nonzero. X (c_stack_action): Likewise. X (exit_failure) [DEBUG]: Initialize to 0, not 1. X (recurse, main) [DEBUG]: Remove main args. X X * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Change X wording of message. Do not check for stdbool.h or ucontext.h, X or for ucontext_t or sigaction or sigaltstack. X X * po/LINGUAS: Add zh_TW. X X * Makefile.am (SUBDIRS): Add man. X * man/Makefile.am: New file. X * src/cmp.c (usage): Reword for help2man. X * src/diff.c (option_help_msgid): Likewise. X * src/diff3.c (option_help_msgid, usage): Likewise. X * src/sdiff3.c (option_help_msgid, usage): Likewise. X Reword for help2man. X X * THANKS: Add email address for Tower. X X * config/config.guess, config/config.sub, config/depcomp, X config/install-sh, config/mdate-sh, config/missing, X config/mkinstalldirs, config/texinfo.texi: Update X to recent version (maintained in other packages). X X2002-03-04 Bruno Haible X X * m4/gettext.m4 (AM_GNU_GETTEXT): Set LIBINTL and LTLIBINTL to empty if X no preinstalled GNU gettext was found. X X2002-03-02 Eli Zaretskii X X * ms/config.sed: Tweak editing of install-info-am and X uninstall-info-am targets, to include 8+3-butchered names of Info X files. X X2002-02-28 Paul Eggert X X * NEWS, configure.ac (AC_INIT, AM_INIT_AUTOMAKE): Version 2.7.8. X X * doc/diff.texi: Add vr index. X Update copyright to 2002. X (Standards conformance): New chapter. X (Binary): Differing binary files are trouble unless the user asked for X brief output. X (Detailed Context): Prefer ISO time stamp format in discussion. X (Detailed Unified, Pagination): Likewise. X (Less Context): Likewise. Also use short option. X (Alternate Names): Separate option from arg. X (Making Patches): Mention -U 2. X (diff Options): Deprecate -LINES, as POSIX 1003.1-2001 does not X allow it. X X * INSTALLME: Update advice for Solaris installation problems. X We no longer use a test version of gettext. X Autoconf test version updated from 2.52f to 2.52h. X POSIX 1003.1-2001 patch for Automake. X X * configure.ac (AC__GNU_SOURCE): Add this, X replacing AH_VERBATIM of _GNU_SOURCE. X (tempname): Use AC_LIBOBJS, not LIBOBJS=, as now required by autoconf. X (jm_PREREQ_C_STACK): Add. X (AC_CONFIG_FILES): Remove intl/Makefile. X (AM_GNU_GETTEXT): Add external arg, from gettext 0.11. X X * lib/c-stack.c, lib/c-stack.h, lib/exitfail.c, lib/exitfail.h, X lib/posixver.c, lib/posixver.h, m4/c-stack.m4, m4/gnu-source.m4, X po/cs.po, po/ja.po: New files. X X * intl/ChangeLog, intl/Makefile.in, intl/VERSION, X intl/bindtextdom.c, intl/config.charset, intl/dcgettext.c, X intl/dcigettext.c, intl/dcngettext.c, intl/dgettext.c, X intl/dngettext.c, intl/explodename.c, intl/finddomain.c, X intl/gettext.c, intl/gettextP.h, intl/gmo.h, intl/hash-string.h, X intl/intl-compat.c, intl/l10nflist.c, intl/libgnuintl.h, X intl/loadinfo.h, intl/loadmsgcat.c, intl/localcharset.c, X intl/locale.alias, intl/localealias.c, intl/localename.c, X intl/ngettext.c, intl/os2compat.c, intl/os2compat.h, intl/osdep.c, X intl/plural-eval.c, intl/plural-exp.c, intl/plural-exp.h, X intl/plural.c, intl/plural.y, intl/ref-add.sin, intl/ref-del.sin, X intl/textdomain.c, m4/isc-posix.m4, m4/libtool.m4: Remove. X X * ABOUT-NLS: Update to Gettext 0.11. X X * Makefile.am (SUBDIRS): Remove intl. X X * config/config.guess, config/config.rpath, config/config.sub, X config/texinfo.tex, config/depcomp, config/texinfo.tex, X lib/tempname.c: Update to latest version from other packages. X X * lib/xalloc.h (xalloc_exit_failure): Remove; subsumed by exit_failure. X * lib/xmalloc.c: Include exitfail.h. X (xalloc_exit_failure): Remove; subsumed by exit_failure. X All uses changed. X X * lib/Makefile.am (noinst_HEADERS): Add c-stack.h, exitfail.h. X (libdiffutils_a_SOURCES): Add c-stack.c, exitfail.c, quotesys.c. X (INCLUDES): Remove. X X * lib/cmpbuf.h (buffer_lcm): New arg LCM_MAX. X * lib/cmpbuf.c: Include errno.h. X (errno): Declare if !STDC_HEADERS. X Include signal.h. X (SA_RESTART): Define if not already defined. X Include . X (PTRDIFF_MAX): Define if not already defined. X (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Likewise. X (block_read): Accommodate ancient AIX hosts that set errno to EINTR X after uncaught SIGCONT. X (buffer_lcm): Return a reasonable size if the multiple is too large. X New arg LCM_MAX. All callers changed. X X * lib/hard-locale.c: Include "hard-locale.h". X (hard_locale): Ignore ENABLE_NLS, since we want to operate on X locales other than LC_MESSAGES. X X * m4/prereq.m4 (jm_PREREQ): Add jm_PREREQ_POSIXVER. X (jm_PREREQ_POSIXVER): New macro. X X * m4/setmode.m4 (AC_FUNC_SETMODE_DOS): X Check for fcntl.h and unistd.h unconditionally. X Suggested by Bruno Haible. X X * po/LINGUAS: Add cs, ja. X * po/POTFILES.in: Add lib/c-stack.c, src/dir.c. X X * src/Makefile.am (datadir): @DATADIRNAME@ -> share. X (INCLUDES): Remove intl. X (LDADD): Change INTLLIBS to LIBINTL. X No longer need to link libdiffutils.a twice. X X * src/analyze.c (diff_2_files): X Avoid arithmetic overflow in buffer size calculation. X X * src/cmp.c: Include c-stack.h, exitfail.h. X (hard_locale_LC_MESSAGES): Depend on ENABLE_NLS. X (try_help, check_stdout, main, cmp): 2 -> EXIT_TROUBLE. X (main): Check for stack overflow. X 0 -> EXIT_SUCCESS. X 1 -> EXIT_FAILURE. X (cmp): Likewise. X Accommodate ancient AIX hosts that set errno to X EINTR after uncaught SIGCONT. X X * src/context.c (pr_context_hunk): X Do not dump core if an enormous context causes an X arithmetic overflow. X (pr_unidiff_hunk): Likewise. X (find_hunk): Likewise. X X * src/diff.h: unsigned -> unsigned int. X * src/diff.c: Include c-stack.h, exitfail.h. X Do not include signal.h. X (specify_style, specify_value): Bring these routines back, as POSIX X requires that the order of options not matter. X (shortopts): New constant. X (group_format_option, line_format_option): New constants. X (main): 0 -> EXIT_SUCCESS, 1 -> EXIT_FAILURE, 2 -> EXIT_TROUBLE. X Ensure that order of options does not matter. X Check for stack overflow. X If contexts overflow, substitute LIN_MAX, as that's good enough. X If multiple contexts are specified, use their maximum. X -c is equivalent to -C 3 now, instead of having an implicit context; X likewise for -u and -U 3. X Use specify_style and specify_value. X (SIGCHLD): Do not define; now done in a header. X Use new style time stamp format for -u / -U. X Reject numeric-string options if operating in POSIX 1003.1-2001 mode. X Avoid overflow problems with tab width. X Simplify from-file and to-file code. X (usage): Do not mention obsolete options. X (filetype): Do not mention whether a file is executable. X Add typed memory objects. X (compare_files): 0 -> EXIT_SUCCESS, 1 -> EXIT_FAILURE, 2 -> X EXIT_TROUBLE. X X * src/diff3.c: Include c-stack.h, exitfail.h. X (ALLOCATE): Remove. All uses changed to xmalloc, or to xmalloc plus X an overflow check. X (myread): Remove. X (main): Check for stack overflow. X 0 -> EXIT_SUCCESS, 1 -> EXIT_FAIULRE, 2 -> EXIT_TROUBLE. X (try_help): Likewise. X (process_diff): Check for integer overflow, to avoid core dumps. X 2 -> EXIT_TROUBLE. X (read_diff): Exit with status 126 if the file is not executable, X for compatibility with POSIX 1003.1-2001. X Accommodate ancient AIX hosts that set errno to EINTR after uncaught X SIGCONT. X Check for integer overflow to avoid core dumps. X (fatal, perror_with_exit): 2 -> EXIT_TROUBLE. X X * src/dir.c (dir_read): X Ignore st_size of directories: POSIX says it's garbage. X Check for integer overflow to avoid core dumps. X (diff_dirs): 0 -> EXIT_SUCCESS, 2 -> EXIT_TROUBLE. X X * src/ifdef.c: Include . X (format_group, print_ifdef_lines): Avoid core dumps with bad formats. X (do_printf_spec): Avoid alloca. X X * src/io.c (sip): X Avoid integer overflow and core dumps if buffer alignments are X preposterously incompatible. X (slurp): Do not dump core if the file is growing as we read it. X If a regular file grows, keep reading until we catch up with its EOF. X (find_and_hash_each_line): Check for integer overflow to avoid cores. X (GUESS_LINES): Remove. X (guess_lines): New function. Avoid integer overflow. X (find_identical_ends): Use it. X Avoid integer overflow and possible core dumps. X X * src/sdiff.c: Include c-stack.h, exitfail.h. Do not include signal.h. X 0 -> EXIT_SUCCESS, 1 -> EXIT_FAILURE, 2 -> EXIT_TROUBLE. X (ck_editor_status): New function. X (main): Check for stack overflow. X Adopt POSIX convention for subsidiary programs not found. X (diffarg): Check for integer overflow to avoid core dumps. X (trapsigs): Remove SA_INTERRUPT special case; now done by header. X (SIGCHLD): Likewise. X (edit): Adopt POSIX convention for subsidiary programs not found. X X * src/side.c: unsigned -> unsigned int. X X * src/system.h: Don't use alloca or include . X unsigned -> unsigned int X (EXIT_SUCCESS, EXIT_FAILURE, EXIT_TROUBLE): Define if not defined. X Include signal.h. X (SA_RESTART): Define if not defined. X (SIGCHLD): Likewise. X X * src/util.c: 2 -> EXIT_TROUBLE. X Adopt POSIX convention for ENOEXEC and exit status 126. X unsigned -> unsigned int X X2002-01-24 Paul Eggert X X * NEWS, configure.ac (AC_INIT, AM_INIT_AUTOMAKE): Version 2.7.7. X X * intl/plural.c: Regenerate with Bison 1.31. X X * ABOUT-NLS, intl/*: Update to Gettext 0.11-pre5++. X * INSTALL: Update to Autoconf 2.52f. X X * INSTALLME: New file. X * Makefile.am (EXTRA_DIST): Add config/config.rpath, INSTALLME. X (DISTCLEANFILES): Remove. X * NEWS: Reformat for imminent 2.8 release. X * README: Mention INSTALLME. X * README-alpha: Move most of contents to INSTALLME. X * THANKS: Add Bruno Haible, Jim Meyering, and Eli Zaretskii. X X * config: New subdirectory, containing the following files from .: X config.guess, config.sub, depcomp, missing, install-sh, mkinstalldirs. X Move the following files here from doc: texinfo.tex, mdate-sh. X * config/config.guess, config/config.sub, config/texinfo.tex: X Update to latest version from FSF. X * config/config.rpath: New file, from Gettext 0.11-pre5++. X X * configure.ac (AC_INIT): Use new 3-arg form. X (AC_CONFIG_SRCDIR): Specify src/diff.c here, not in AC_INIT. X (ALL_LINGUAS): Remove: now in po/LINGUAS as per Gettext 0.11. X (AC_CONFIG_AUX_DIR): New macro invocation. X X * lib/Makefile.am (noinst_HEADERS): Add gettext.h. X * lib/gettext.h: New file, from Gettext 0.11-pre5++. X * lib/prepargs.c: Include . Reported by Bruno Haible. X X * m4/codeset.m4, m4/gettext.m4, glibc21.m4, iconv.m4, isc-posix.m4, X lcmessage.m4, progtest.m4: Upgrade to Gettext 0.11-pre5++. X * m4/lib-ld.m4, m4/lib-link.m4, m4/lib-prefix.m4: New files, from X Gettext 0.11-pre5++. X X * po/LINGUAS: New file. X * po/Makefile.in.in: Upgrade to Gettext 0.11-pre5++. X * po/Makevars, po/Rules-quot, po/boldquot.sed: New files, X from Gettext 0.11-pre5++. X X * src/cmp.c (copyright_string): Update to 2002. X * src/diff.c (copyright_string): Likewise. X * src/diff3.c (copyright_string): Likewise. X * src/sdiff.c (copyright_string): Likewise. X X * src/cmp.c (bytes, parse_ignore_initial, cmp): Use UINTMAX_MAX X instead of (uintmax_t) -1, to avoid warnings on some compilers. X * src/io.c (file_block_read): Likewise, for SIZE_MAX. X X * src/cmp.c (usage): Reformat messages to ease translation. X * src/diff3.c (usage): Likewise. X * src/sdiff.c (usage): Likewise. X X * src/diff3.c (main): Remove unused variable. X X * src/dir.c: Include X (struct dirdata): New member nnames. X (locale_specific_sorting, failed_strcoll): New vars. X (dir_read): Renamed from dir_sort. Don't sort the dir. X Set new nnames member of struct dirdata. All callers changed. X (compare_names): Don't check for errno after strcasecmp. X Use strcoll only if locale_specific_sorting is nonzero. X If strcoll fails, longjmp out rather than returning a value X that might result in an invalid comparison function that might X make qsort dump core. X (diff_dirs): Sort the directory ourselves. Use setjmp to recover X from strcoll failure, falling back on native byte comparison. X Make local variables volatile if they need to preserve their value X after setjmp/longjmp. X X * src/sdiff.c (handler_index_of_SIGINT, handler_index_of_SIGPIPE): X New macros. X (main): Do not confuse signal numbers with their indices. X Bug reported by Bruno Haible. X (edit): Cat lin to long before printing with %ld, since lin might X be narrow than long. X X * src/system.h (UINTMAX_MAX): New macro. X Include gettext.h, not libgettext.h. X (N_): Do not wrap arg in parentheses. Fix from Bruno Haible. X X * src/util.c (finish_output): Ensure that werrno is initialized. X (lines_differ): Have an explicit do-nothing case for X IGNORE_NO_WHITE_SPACE, to pacify gcc -Wall. X X2001-12-29 Eli Zaretskii X X * src/sdiff.c (interact): After extracting rlen from the editor X command, test for a terminating null character, not for a newline. X X * ms/config.bat: Allow longer source directory names without X overflowing the line length limits. Create the cache in the X build directory, not in the source directory X * ms/config.sed: Fix AC_CONFIG_LINKS for when symlinks are X unavailable. X X2001-12-23 Paul Eggert X X * NEWS, configure.ac (AM_INIT_AUTOMAKE): Version 2.7.6. X X * configure.ac (ALL_LINGUAS): Add tr. X X * src/util.c (begin_output): X Have child exit with status 127 rather than reporting X failure on its own. Set errno to 0 before invoking popen. X (finish_output): Report errno on pclose failure. X Distinguish between subsidiary program not found, and failure. X X * src/sdiff.c (not_found, execdiff): Remove. X (DIFF_PROGRAM_OPTION): New constant. X (longopts, option_help_msgid, main): Add --diff-program=PROGRAM. X (check_stdout): New function. X (main): Remove DIFF_PROGRAM. Check stdout after printing version. X Use check_stdout after printing help. Use execvp/perror_fatail rather X than execdiff. Set errno to 0 before invoking popen. X Check for pclose failure properly. X (main, edit): If child exec fails, exit with 127 rather than trying to X print diagnostic. X Distinguish between subsidiary program failing and not being found. X (edit): Handle signals the same way, regardless of whether we're using X system or fork+exec. Check for system returning -1. X X * src/diff3.c (DIFF_PROGRAM_OPTION, HELP_OPTION): New constants. X (longopts, main): Use them. X (longopts, main, option_help_msgid): New option --diff-option=PROGRAM. X (main): Remove DIFF_PROGRAM support. X Check stdout after printing version. X (check_stdout): Report errno info if fclose fails. X (read_diff): Have child exit with status 127 when program is not found, X rather than trying to have the child report failure. Check for X pclose returning -1. X X * src/diff.c (DEFAULT_WIDTH): Remove. X (main): Use 130 instead of DEFAULT_WIDTH, since it's not really X builder-settable. Do not prepend DIFF_OPTIONS. X (check-stdout): If fclose (stdout) fails, print errno info. X (option_help_msgid): Default context is 3, not 2. X (usage): Work even if ptrdiff_t is wider than int. X X * doc/diff.texi (diff Options): Remove DIFF_OPTIONS. X (Invoking diff3, Invoking sdiff): Remove DIFF_PROGRAM. X (diff3 Options, sdiff Options): Add --diff-program. X X * src/cmp.c (valid_suffixes): X Add '0', to support suffixes like "MB" and "MiB". X (check_stdout): Don't assume that the translations of "write failed" X and of "standard output" lack '%'. X (main): Check stdout after printing version. X X * lib/setmode.c: [HAVE_FCNTL_H && HAVE_SETMODE_DOS]: Include . X [!HAVE_SETMODE_DOS]: Do not include . X (set_binary_mode): Return mode (not 1) if fd is a tty. X Do not assume that O_TEXT is zero. X X * doc/diff.texi (cmp Options): X In byte counts, a plain suffix (without any integer) X is assumed to modify the integer 1. Index terms like "kibibyte". X Document plain "k". X X (Reporting Bugs): Mention bug-report archive and test version X location. Ask for "diff --version" in bug reports. X X2001-12-13 Paul Eggert X X * src/diff.c (DEFAULT_WIDTH): Remove; couldn't be changed without X also changing option_help_msgid. All uses replaced with 130. X X * lib/setmode.c: Include fcntl.h and unistd.h only if X HAVE_SETMODE_DOS. X (setmode): Assume a file is binary unless the mode is O_TEXT. X * ms/README: Fix minor typos. X X2001-12-13 Eli Zaretskii X X * ms/README: New file. X X * lib/setmode.c (set_binary_mode) [HAVE_SETMODE_DOS]: Don't assume X O_TEXT has a zero value. If FD is a terminal device, do nothing X and return MODE, thus pretending that it was already in the X requested MODE. X [HAVE_FCNTL_H]: Include fcntl.h (needed for O_BINARY). X X * ms/config.sed: Remove the split prevention of config.status. X Fix Sed commands for converting absolute file names into X top_srcdir-relative ones. X X * ms/config.bat: Fix typos. X X2001-12-12 Neal H Walfield X X * diff.c (option_help_msgid): Correct the default context width X from 2 to 3. X X2001-12-11 Paul Eggert X X * m4/Makefile.am.in: Remove jm-glibc-io.m4 X X * NEWS, configure.ac (AM_INIT_AUTOMAKE): Version 2.7.5. X X * configure.ac (PR_PROGRAM): Use AC_DEFINE_UNQUOTED, so that X $PR_PROGRAM is expanded by sh. X (ptrdiff_t, ssize_t): Use AC_CHECK_TYPE with a default of int, X not AC_CHECK_TYPES. X (jm_AC_DOS, AC_FUNC_SETMODE_DOS): New macros. X (AC_CONFIG_FILES): Add ms/Makefile. X X * doc/diff.texi: Add --no-ignore-file-name-case. X File name case sensitivity now affects file name exclusion. X Fix typos. X X * src/util.c: Include dirname.h. X (dir_file_pathname): Use base_name rather than file_name_lastdirchar. X X * src/system.h (S_IXUSR, S_IXGRP, S_IXOTH): New macros. X Include rather than rolling it ourselves. X (file_name_lastdirchar, HAVE_SETMODE, set_binary_mode): Remove. X X * src/sdiff.c: Include . X (expand_name): Use base_name rather than file_name_lastdirchar, for X portability to DOS. X (main): Initialize xalloc_exit_failure before possibly invoking X any memory allocator. X X * src/io.c: Include setmode.h. X X * src/diff3.c (main): X Initialize xalloc_exit_failure before possibly invoking any memory X allocator. X X * src/diff.c: Include dirname.h, setmode.h. X X (main): Later values and/or styles now silently override earlier. X (specify_value, specify_style): Likewise. All callers changed. X Remove. X (binary, main, option_help_msgid, compare_files): X HAVE_SETMODE -> HAVE_SETMODE_DOS. X (NO_IGNORE_FILE_NAME_CASE_OPTION): New constant. X (longopts, main, option_help_msgid): Support it. X (exclude_options): New function. X (main): Use it. Initialize xalloc_exit_failure before potentially X allocating memory. X X (filetype): Distinguish executable files from others, as POSIX X suggests. X X (compare_files): Use base_name instead of file_name_lastdirchar. X X * src/cmp.c: Include , . X (hard_locale_LC_MESSAGES): New macro. X (sprintc): Remove int width arg; it's now the caller's responsibility X to pad. All callers changed. X (stat_buf): New static var; was formerly a local var in 'main'. X (valid_suffixes): Add 'K', for 'KiB'. X (option_help_msgid): Don't confuse bytes with characters. X (main): Set xalloc_exit_failure before invoking anything that might X allocate memory. Fix bug: -n was incorrectly ignored when optimizing X the case of regular files with different lengths. X (cmp): Use an index column wide enough to store this comparison's X indexes. In locales other than the POSIX locale, say "byte" X rather than "char". X X * ms/config.bat: pc -> ms X X * ms/Makefile.am, m4/setmode.m4, lib/setmode.c, lib/setmode.h: X New file. X X * lib/Makefile.am (noinst_HEADERS): Add dirname.h, setmode.h. X (libdiffutils_a_SOURCES): Add basename.c, setmode.c. X X * Makefile.am (SUBDIRS): Add ms. X X2001-12-10 Paul Eggert X X * m4/fnmatch.m4: Test for FNM_CASEFOLD. X X2001-12-03 Paul Eggert X X * lib/posix/regex.h: Fix copyright notice. X X2001-12-03 Paul Eggert X X * NEWS, configure.ac (AM_INIT_AUTOMAKE): Version 2.7.4. X X * diff.texi (direntry, Overview, Comparison, Binary, Invoking cmp): X Use "byte" rather than "character" when talking about cmp, since X it compares bytes, not character. X (Invoking cmp): New trailing operands FROM-SKIP and TO-SKIP. X -i or --ignore-initial now accepts FROM-SKIP:TO-SKIP. X New option -n or --bytes. X Count operands now may be in octal or hex, and may be followed by a X size multiplier. X X * configure.ac (DEFAULT_DIFF_PROGRAM): X Define to "diff", not "$bindir/diff" (which didn't work anyway). X (AC_CHECK_MEMBERS): Add struct stat.st_blksize, struct stat.st_rdev. X (AC_STRUCT_ST_BLKSIZE, AC_STRUCT_ST_RDEV): Remove; obsolescent. X (AC_FUNC_FORK): Use this, instead of obsolescent AC_FUNC_VFORK. X (AC_CONFIG_FILES, AC_CONFIG_COMMANDS): Add. X (AC_OUTPUT): Remove args; they were obsolescent. X X * util.c (setup_output, begin_output, finish_output): X HAVE_FORK -> HAVE_WORKING_FORK || HAVE_WORKING_VFORK. X * sdiff.c (diffpid, cleanup, main, edit): Likewise. X * diff3.c (read_diff): Likewise. X X * system.h (STAT_BLOCKSIZE): X Use HAVE_STRUCT_STAT_ST_BLKSIZE, not HAVE_ST_BLKSIZE. X (vfork): New macro. X (HAVE_FORK): Remove. X (set_binary_mode): New macro. X X * sdiff.c (main): HAVE_VFORK -> HAVE_WORKING_VFORK. X (edit): Reopen the temporary file after the editor has run, in case X the editor operates by unlinking the old file and linking a new one. X (P_tmpdir): Rename from PVT_tmpdir; this fixes a typo. X All uses changed. X X * io.c (sip, read_files): X Remove tests for HAVE_SETMODE; use set_binary_mode X instead of setmode. X (sip): Fix typo in backward lseek when reverting to text mode. X X * config.site, config.sed, config.bat: New file. X X * Makefile.am (EXTRA_DIST): Add xstrtol.c. X (noinst_HEADERS): Add xstrtol.h. X (libdiffutils_a_SOURCES): Add xstrtoumax.c. X X * cmp.c: : Include. X (ignore_initial): Now an array with 2 elements. All uses changed. X (bytes): New var. X (HELP_OPTION): New constant. X (long_options, main): Use it. X (long_options, option_help_msgid, main, cmp): X Add support for -n or --bytes. X (parse_ignore_initial): New function. X (option_help_msgid, main): Add -i M:N. X (usage, main): Add two optional trailing operands, a la BSD. X (main): setmode -> set_binary_mode. X (cmp): Report byte number of what we've seen, not of the entire file. X This is to be consistent with the line number, which is always relative X with what we've seen. X X2001-12-02 Paul Eggert X X * diff.c (main, compare_files): setmode -> set_binary_mode. X X * xstrtol.c (__xstrtol): Don't accept 'Ki'; require 'KiB'. X X * xstrtol.c (__xstrtol): Add support for IEC 60027-2. X X2001-11-25 Paul Eggert X X * NEWS, configure.ac (AM_INIT_AUTOMAKE): Version 2.7.3. X X * README-alpha: New file. X X * src/Makefile.am (INCLUDES): Add -I../lib, for regex.h. X X * configure.ac: X Don't set LIB_CLOCK_GETTIME to 'none required'; set it to X the empty string instead. X X * lib/Makefile.am (EXTRA_DIST): Add strtoimax.c, strtol.c. X X * Makefile.am (SUBDIRS): Put intl before lib, so that libintl.h exists. X X * lib/Makefile.am (noinst_HEADERS): Add unlocked-io.h. X X * configure.ac (__EXTENSIONS__): New define, for the unlocked macros. X X * README: Add copyright notice. X Remove stuff that doesn't apply any more. X X * doc/diff.texi: offsets -> indices for cmp X X * src/cmp.c (option_help_msgid): offsets -> indices X X * src/diff.c (option_help_msgid): X Don't mention --binary on POSIX hosts. X X * src/sdiff.c (STRIP_TRAILING_CR_OPTION): New constant. X (longopts, option_help_msgid, main): Add -E, --ignore-tab-expansion, X --strip-trailing-cr. X X * doc/diff.texi: Change direcategory from Utilities to GNU Packages. X Add individual utilities. X Switch to Free Documentation License. X @code -> @command X @samp -> @option X GNU -> @sc{gnu} X Expand tabs to spaces, except when in an example that actually X uses tabs. X Prefer @node with just one arg. X Document -E or --ignore-tab-expansion, --strip-trailing-cr, X --ignore-file-name-case. X Regular expressions are now grep style, not Emacs style. X cmp's -c or --print-chars option is now -b or --print-bytes. X Time stamps now depend on LC_TIME. X -p now implies ^[[:alpha:]$_]. X Flags now include ' and 0. X cmp -i is an alias for --ignore-initial X Document --from-file, --to-file. X Document DIFF_OPTIONS. X X * configure.ac (AC_CHECK_FUNCS): Add gettimeofday, clock_gettime. X (LIB_CLOCK_GETTIME): New subst. X X * src/system.h: Assume C89 or better. X (_GNU_SOURCE): Remove; config.h now defines it. X (alloca): Declare like coreutils does it. X (verify, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, O_RDWR, X S_IRUSR, S_IWUSR): New macros. X (STAT_BLOCKSIZE): Parenthesize definiens. X : Include if HAVE_INTTYPES_H. X (CHAR_MAX, INT_MAX): Remove. X (PTRDIFF_MAX, SIZE_MAX): New macros. X (strtoumax): New decl. X Include stddef.h. X (bzero): Remove. X (bindtextdomain, textdomain, N_): New macros. X (ISPRINT, ISSPACE): Remove ifndef wrappers. X (ISUPPER, ISDIGIT): Remove. X (TOLOWER): New macro. X (MIN): Renamed from min; all callers changed. X (MAX): Likewise, from max. X (lin): New type. X (LIN_MAX): New macro. X (file_name_cmp): Renamed from filename_cmp. All callers changed. X (file_name_lastdirchar): Renamed from file_name_lastdirchar. X All callers changed. X (could_be_mvfs_stat_bug, could_be_nfs_stat_bug, X dev_may_have_duplicate_ino): Remove. X (HAVE_SETMODE, NULL_DEVICE): New macros. X (same_file): Do not check attributes. X (same_file_attributes): New macro. X X * src/util.c: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X int -> size_t for sizes. X Use angle-brackets when including quotesys.h. X Include error.h, regex.h, xalloc.h. X (message5): sizeof -> offsetof X (begin_output): Invoke pr without -f. X (lines_differ): Renamed from line_cmp, and return bool not 3-way int. X All callers changed. X Add support for IGNORE_TAB_EXPANSION. X (change_letter): Now an array rather than a function. All X callers changed. X (translate_range): Translate line numbers to long, not lin, X for convenience with printf. X (analyze_hunk): Return enum changes instead of a count of X inserts and deletes. All callers changed. X (zalloc): New function. X X * src/side.c: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X X * src/sdiff.c: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X Use angle-brackets when including getopt.h, quotesys.h. X Include error.h, freesoft.h, stdio.h, xalloc.h. X (copyright_string): Use only most recent year. X (authorship_msgid, option_help_msgid): Wrap in N_(). X X (tmpname): Now volatile. X (tmpmade): Remove. X (tmp): New var. X (private_tempnam, exists, letters): Remove. X (temporary_file): New function. X (edit): Use it. X (interact): Use strtoumax, not atoi. X X * src/normal.c: Assume C89 or better. X int -> lin for line numbers. X X * src/io.c: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X int -> size_t for sizes. X Use angle-brackets when including cmpbuf.h. X Include regex.h, xalloc.h. X (word): Remove; now done in system.h. X (hash_value): New type; use it instead of 'unsigned' for hash values. X (file_block_read): New function. X (sip, slurp): Use it. Now static. X (sip): Ensure block size is a multiple of word size. Clear eof flag. X (slurp): Use xalloc_die to report memory exhaustion. X (find_and_hash_each_line): Use TOLOWER instead of _tolower. X Add support for IGNORE_TAB_EXPANSION. X (prepare_text_end): Strip trailing CR if requested. X (find_identical_ends): Prepare the text only once, X if they're duplicates. X Let the compiler take advantage more of the fact that the buffers are X word-aligned. X (primes): Remove. X (prime_offset): New var. X (read_var): Use prime_offset instead of primes. X Use zalloc instead of xmalloc + bzero. X X * src/ifdef.c: Assume C89 or better. X int -> lin for line numbers. X (format_group): Use strtoumax to parse line numbers. X (format_group, print_ifdef_lines): Use do_printf_spec to X handle printf specs. X (groups_letter_value): Don't use _tolower; it's locale-dependent. X (do_printf_spec): Renamed from scan_printf_spec; now does the printing. X X * src/ed.c: Assume C89 or better. X int -> lin for line numbers (or 'long' when that's more convenient). X (print_ed_hunk): Fix bug when handling double-dot inserts. X X * src/dir.c: Assume C89 or better. X int -> bool for booleans. X Include error.h, exclude.h, xalloc.h. X X (dir_sort): Return 0 on error, 1 on success. All callers changed. X compare_names -> compare_names_for_qsort. X X (compare_names): Try strcasecmp if ignore_file_name_case. Then try X strcoll. Use file_name_cmp only as a last resort. Warn about X strcasecmp or strcoll failure. X (compare_names_for_qsort): New function. X X (diff_dirs): Use compare_names rather than filename_cmp. X X * src/diff3.c: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X Use angle-brackets when including getopt.h, quotesys.h. X Include error.h, freesoft.h, inttostr.h, xalloc.h. X (copyright_string): Use only most recent year. X (authorship_msgid, option_help_msgid): Wrap in N_(). X X Rename the following variables for consistency with user-visible X option spellings. All uses changed. X (text): Renamed from always_text. X (initial_tab): Renamed from tab_align_flag. X X (horizon_lines): Remove. Remove all uses. X X (main): Invoke bindtextdomain and textdomain after setlocale. X Rename "DIFF" to "DIFF_PROGRAM". X X Try to compare file0 to file1, because this is where changes are X expected to come from. Diffing between these pairs of files is more X likely to avoid phantom changes from file0 to file1. X However, use file2 as the common file if this is a 3-way diff, X for backward compatibility. Suggested by Karl Tomlinson. X X (create_diff3_block): Use xcalloc instead of malloc + bzero. X X (INT_STRLEN_BOUND): Remove; now in system.h. X X (read_diff): Always use --horizon-lines=100 rather than trying X to guess it. X Do not pass --inhibit-hunk-merge. X Minimum chunk size is 1, not 8KiB. X Use xalloc_die to report memory exhaustion. X (undotlines): Use long for start, not int. X X * src/diff.h: Assume C89 or better. X int -> bool for booleans. X int -> lin for line numbers. X Don't include regex.h. X (enum changes): New enum. X (enum line_class): Remove; subsumed by enum changes. X (enum output_style): New constant OUTPUT_UNSPECIFIED. X X (ignore_space_change_flag, ignore_all_space_flag): Remove. X (ignore_white_space): New decl, subsuming the above two. All X uses changed. X X Rename the following decls for consistency with user-visible X option spellings. All uses changed. X (text): Renamed from always_text_flag. X (ignore_blank_lines): Renamed from ignore_blank_lines_flag. X (ignore_case): Renamed from ignore_case_flag. X (brief): Renamed from no_details_flag. X (initial_tab): Renamed from tab_align_flag. X (expand_tabs): Renamed from tab_expand_flag. X (starting_file): Renamed from dir_start_file. X (paginate): Renamed from paginate_flag. X (sdiff_merge_assist): Renamed from sdiff_help_sdiff. X (left_column): Renamed from sdiff_left_only. X (suppress_common_lines): Renamed from sdiff_skip_common_lines. X (speed_large_files): Renamed from heuristic. X (minimal): Renamed from no_discards. X X (inhibit_hunk_merge): Remove. X X (strip_trailing_cr, excluded, time_format): New decls. X X (files_can_be_treated_as_binary): Renamed from ignore_some_changes. X X (group_format, line_format): Now char const *[], not char *[]. X X (struct file_data): Buffer is now word*, not char*, as it's always X aligned and this can help the compiler. buffered_chars -> buffered X (since it's a byte count, not a char count). All uses changed. X New member `eof'. X X (FILE_BUFFER): New macro. X X (excluded_filename, error, free_software_msgid): Remove decls; now in X other .h files. X X (sip, slurp): Remove decls. X (file_block_read): New decl. X (change_letter): Now an array, not a function. X (lines_differ): Renamed from line_cmp. X (analyze_hunk): Now returns enum changes rather than two change counts. X X * src/Makefile.am (diff_LDADD): New symbol. X X * src/diff.c: Assume C89 or better. X int -> bool for booleans. X long -> off_t for line numbers. X Use angle-brackets when including getopt.h, fnmatch.h, quotesys.h. X Include error.h, exclude.h, freesoft.h, hard-locale.h, prepargs.h, X regex.h, signal.h, xalloc.h. X (copyright_string): Use only most recent year. X (authorship_msgid, option_help_msgid): Wrap in N_(). X X Rename the following variables for consistency with user-visible X option spellings. All uses changed. X (binary): Renamed from binary_flag. X (new_file): Renamed from entire_new_file_flag. X (unidirectional_new_file): Renamed from unidirectional_new_file_flag. X (report_identical_files): Renamed from print_file_same_flag. X X (numeric_arg): Remove. X X (exclude, exclude_alloc, exclude_count, excluded_filename, add_exclude, X add_exclude_file): X Remove; now done by exclude.h. X X (BINARY_OPTION, FROM_FILE_OPTION, HELP_OPTION, HORIZON_LINES_OPTION, X IGNORE_FILE_NAME_CASE_OPTION, INHIBIT_HUNK_MERGE_OPTION, X LEFT_COLUMN_OPTION, LINE_FORMAT_OPTION, NORMAL_OPTION, X SDIFF_MERGE_ASSIST_OPTION, STRIP_TRAILING_CR_OPTION, X SUPPRESS_COMMON_LINES_OPTION, TO_FILE_OPTION, X UNCHANGED_LINE_FORMAT_OPTION, OLD_LINE_FORMAT_OPTION, X NEW_LINE_FORMAT_OPTION, UNCHANGED_GROUP_FORMAT_OPTION, X OLD_GROUP_FORMAT_OPTION, NEW_GROUP_FORMAT_OPTION, X CHANGED_GROUP_FORMAT_OPTION): New constants. X (longopts, main): Use them. X X (longopts, main, option_help_msgid): Add -E, --from-file, --to-file. X X (main): Invoke bindtextdomain and textdomain after setlocale. X Use grep syntax, not Emacs, for regular expressions. X Use exclude.h, not our own functions. X Use ISO 8601 time format in hard locales. X Prepend DIFF_OPTIONS. X Don't update ignore_some_changes. X Use strtoumax instead of numeric_arg. X Use specify_value when appropriate. X error -> try_help when appropriate. X -p now means ^[[:alpha:]$_], not ^[_a-zA-Z$]. X Ignore --inhibit-hunk-merge. X Prefer changed group formats to unchanged ones. X Remove now-unnecessary casts. X Set files_can_be_treated_as_binary. X X (specify_value): Renamed from specify_format. All uses changed. X X (specify_style): Default is now unspecified, not normal. All X uses changed. X X (set_mtime_to_now): New function. X (compare_files): Use it. Use memset, not bzero. X Set stdin mtime to current time even when stdin is not a regular file. X Check for same file attributes, as well as for same file. X Use files_can_be_treated_as_binary. X "write failed" -> "standard output on output failure. X X * src/context.c: Assume C89 or better. X int -> lin for line numbers. X Include inttostr.h, regex.h. X (TIMESPEC_NS): New macro. X (nstrftime): New decl. X (print_context_label): Use nstrftime and time_format to format times. X Print numeric time stamp value if localtime fails. X (print_context_function): New function. X (pr_context_hunk, pr_unidiff_hunk): Use it. X (find_function): Use size_t for sizes, not int. X X * src/cmp.c: Assume C89 or better. X int -> bool for booleans. X long -> off_t for line numbers. X Use angle-brackets when including cmpbuf.h, getopt.h. X Include error.h, freesoft.h, inttostr.h, xalloc.h. X (copyright_string): Use only most recent year. X (authorship_msgid): Wrap in N_(). X (buffer): Now word*, not char*. All uses changed. X (word): Remove macro; now in system.h. X (long_options, option_help_msgid, main): -c --print-chars -> X -b --print-bytes X (check_stdout): "write failed" -> "standard output" X (option_help_msgid): Wrap in N_(). X (main): Invoke bindtextdomain and textdomain after setlocale. X Use strtoumax instead of doing the work ourselves. X Check for same_file_attributes as well as same_file. X (cmp): Use ssize_t for read returns, not size_t. X Do not assume that size_t is not narrower than int. X Do not assume that line numbers fit in 'long'. X (block_compare_and_count, block_compare): X Compiler now checks that buffers are word-aligned. X (block_compare_and_count): Count sizes with size_t, not long. X (sprintc): byte arg is unsigned char, not unsigned. X X * src/analyze.c: Assume C89 or better. X int -> lin for line numbers. X int -> bool for booleans. X unsigned int -> size_t for sizes. X Use angle-brackets when including cmpbuf.h. X Include error.h, regex.h, xalloc.h. X (discard_confusing_lines, diff_2_files): Use zalloc rather X than xalloc+bzero. X (discard_confusing_lines): unsigned int -> lin for values that X are really line numbers. X (shift_boundaries): Do not inhibit hunk merges. X (build_reverse_script, build_script, diff_2_files): Use |, not ||. X (diff_2_files): no_details_flag & ~ignore_some_changes -> X files_can_be_treated_as_binary. Esure that buffer size is a multiple X of sizeof (word). Use file_block_read to read buffers. X (diff_2_files): Abort if output style is not one of the X expected styles. X X2001-11-23 Paul Eggert X X * src/Makefile.am, m4/vararrays.m4: New file. X X * m4/prereq.m4 (jm_PREREQ_READUTMP): X Remove, as it gives autoheader the willies. X X * m4/README, lib/prepargs.h, lib/prepargs.c, lib/offtostr.c, X lib/umaxtostr.c, lib/inttostr.c, lib/inttostr.h, X lib/imaxtostr.c, lib/freesoft.h: New files. X X * lib/freesoft.c: Include config.h, freesoft.h rather than diff.h. X (free_software_msgid): Wrap contents in N_. X X * lib/cmpbuf.h: Use prototypes instead of old-style functions. X X * lib/cmpbuf.c: X Don't include system.h; instead, include config.h, unistd.h. X Use prototypes instead of old-style functions. X (block_read): Don't assume that int is no wider than size_t. X X * lib/Makefile.am, po/POTFILES.in: New file. X X2001-11-22 Paul Eggert X X * pc/config.h: X Define filename_cmp as an object-like macro, not as a function-like X macro. X X * exgettext: Always operate in the C locale. X Set AWK using a method that works even with broken shells. X X * doc/Makefile.am: New file. X X * configure.ac (AC_INIT): X Use src/diff.c, not diff.h, as the source files got removed. X (AM_CONFIG_HEADER): Switch from AC_CONFIG_HEADER. X (AC_ARG_PROGRAM, AC_MINIX): Remove. X X (AC_PREREQ, AM_INIT_AUTOMAKE, ALL_LINGUAS, AC_PROG_AWK, X AM_PROG_CC_STDC, AC_PROG_RANLIB, AC_C_INLINE, AC_C_VARARRAYS, X DEFAULT_DIFF_PROGRAM, DEFAULT_EDITOR_PROGRAM, X AC_STRUCT_ST_MTIM_NSEC): Add. X X (PR_PROGRAM): AC_DEFINE. X X (AC_SYS_LARGEFILE): Use instead of our homebrew version. X X (_GNU_SOURCE): Define if not defined. X X (AC_CHECK_HEADERS): Add stdbool.h, unistd.h. X (AC_CHECK_TYPES): Add ptrdiff_t, uintmax_t. X (AM_GNU_GETTEXT, XGETTEXT): Add. X X (WITH_MVFS_STAT_BUG, WITH_NFS_STAT_BUG): Remove. X (HAVE_MEMCHR): Remove. X (AC_CHECK_FUNCS): Add diraccess. X (AC_REPLACE_FUNCS): Add memchr, waitpid. X (jm_FUNC_GLIBC_UNLOCKED_IO, jm_FUNC_GNU_STRFTIME, jm_FUNC_MALLOC, X jm_FUNC_REALLOC, jm_PREREQ_ERROR, jm_PREREQ_QUOTEARG, jm_PREREQ_REGEX, X jm_PREREQ_TEMPNAME, jm_AC_PREREQ_XSTRTOUMAX, AC_FUNC_FNMATCH): Add. X (fnmatch.h, regex.h): Do not create these files unless we're using X our own fnmatch and regex. X X (AC_OUTPUT): Add doc/Makefile, intl/Makefile, lib/Makefile, X lib/posix/Makefile, m4/Makefile, po/Makefile.in, src/Makefile. X X * Makefile.am: New file. X X * po/en_GB.po: Don't translate "program" to "programme". X X2001-11-20 Paul Eggert X X * m4/prereq.m4: New file. X X2001-03-16 Paul Eggert X X * lib/tempname.c (uint64_t): X Define if not defined, and if UINT64_MAX is not defined. X X2001-02-26 Paul Eggert X X * lib/tempname.c: glibc 1.32 X X2001-02-17 Paul Eggert X X * m4/Makefile.am.in: GNU fileutils 4.1 X X2001-01-09 Paul Eggert X X * lib/tempname.c (struct_stat64): New macro. X (direxists, __gen_tempname): Use it. This avoids a portability problem X with Solaris 8. X X * lib/tempname.c (): Include if HAVE_CONFIG_H. X (, , ): X Include only if STDC_HEADERS || _LIBC. X (): Include only if HAVE_FCNTL_H || _LIBC. X (): Include only if HAVE_UNISTD_H || _LIBC. X (): Include only if HAVE_SYS_TIME_H || _LIBC. X (__set_errno): Define this macro if doesn't. X (P_tmpdir, TMP_MAX, __GT_FILE, __GT_BIGFILE, __GT_DIR, __GT_NOCREATE): X Define these macros if doesn't. X (S_ISDIR, S_IRUSR, S_IWUSR, S_IXUSR): X Define these macros if X doesn't. Ignore S_ISDIR if STAT_MACROS_BROKEN. X (stat64, __getpid, __gettimeofday, __mkdir, __open, __open64, lxstat64, X __xstat64): Define if not _LIBC. X (__secure_getenv): Define if ! (HAVE___SECURE_GETENV || _LIBC). X (__gen_tempname): Invoke gettimeofday only if HAVE_GETTIMEOFDAY X || _LIBC; otherwise, fall back on plain "time". X Use macros like S_IRUSR | S_IWUSR rather than octal values like 0600. X X * lib/mkstemp.c (__GT_FILE): Define to zero if not defined. X X2000-10-25 Paul Eggert X X * lib/hard-locale.c: New file. X X2000-02-05 Paul Eggert X X * exgettext: From GCC repository X X1999-07-06 Paul Eggert X X * lib/mkstemp.c: glibc 2.2 X X1998-12-11 Paul Eggert X X * src/sdiff.c (lf_snarf): X Fix bug when help line wrapped around the input buffer. X X1998-09-15 Paul Eggert X X * diff.texi: Add @dircategory and @direntry. X X1998-09-14 Paul Eggert X X * Makefile.in (VERSION): Version 2.7.2. X (DEFAULT_DIFF_PROGRAM): Renamed from DIFF_PROGRAM. X (PR_PROGRAM): All `configure' to define it. X (srcs): Add $(diffutils_srcs), freesoft.c, quotearg.c instead of X quote.c, quotearg.h. X (distfiles): Add acconfig.h, message/*. X (all): Depend on $(destfiles), not info. X (version.c): Parenthesize `GNU diffutils'. X (common_o): Add freesoft.o X (diff_o): quote.o -> quotearg.o X (diff3_o, sdiff_o): Likewise. X (diff.dvi): Depend on version.texi. X (diff.o diff3.o quotearg.o sdiff.o util.o): X New dependency on quotearg.h X (diff3.o): DIFF_PROGRAM -> DEFAULT_DIFF_PROGRAM. X (sdiff.o): Likewise. X (messages.po): Remove. X (message/msgid.po, message/template.po): New rules. X (maintainer-clean): Renamed from realclean. X (install): Install from source directory, if applicable. X Invoke install-info if needed. X (install-strip): New rule. X (check): Set DIFF. X (stamp-h.in): Don't put the date into the timestamp. X (D_dirs): Add $D/message. X ($D.tar.gz): Compress with gzip -9. X Don't use ln to create distribution; it doesn't work with symlinks. X (srcs, distfiles, diff_o, diff3_o, sdiff_o): Rename quotearg.c to X quotesys.c and quotearg.h to quotesys.h. X X * configure.in (AC_PATH_PROG): Add PR_PROGRAM. X If available, prefer support for large files unless the user specified X one of the CPPFLAGS, LDFLAGS, or LIBS variables. X (AC_STRUCT_ST_RDEV): Add. X (HAVE_ST_FSTYPE_STRING): Add. X (--with-mvfs-stat-bug, --with-nfs-stat-bug): New options. X (HAVE_MEMCHR): New macro. X (AC_CHECK_FUNCS): Add sicprocmask. X X * diff.h (XTERN): Renamed from EXTERN. X (struct filedata): Remove dir_p arg. X (struct comparison): New type. X (diff_2_files, diff_dirs)" Ise ot/ X (error): Add printf attribute if applicable. X (free_software_msgid): New decl. X (pr_program): New decl. X (fatal): Add noreturn attribute. X (pfatal_with_name): Likewise. X X * system.h (__attribute__): New macro. X (getenv): Don't declare if HAVE_STDLIB_H. X (CHAR_MAX): New macro. X (): New include. X (): Include before . X (could_be_mvfs_stat_bug, could_be_nfs_stat_bug, X dev_may_have_duplicate_ino, same_special_file): New macros. X (same_file): Use them. X X * cmp.c (authorship_msgid): New var. X (free_software_msgid): New decl. X (error): Now has printf attribute. X (try_help): Likewise. X (long_options): Don't assume ASCII. X (try_help): Now accepts operand arg. X (main): Check for -1, not EOF, when calling getopt_long. X Report --ignore-initial value when complaining about it. X Output copyright and free software info with -v. X Don't assume ASCII. X Report last operand when one is missing. X Report text of extra operand. X Move block_read into cmpbuf.c. X X * diff.c (authorship_msgid): New var. X (quotesys.h): Include. X (ck_atoi): Remove. X (function_regexp_list, ignore_regexp_list): Now static. X (binary_flag): Renamed from binary_I_O. X (entire_new_file_flag, unidirectional_new_file_flag, X print_file_same_flag): Now static. X (numeric_arg): Renamed from ck_atoi. X New argument specifying the argument type. X (longopts, main): Don't assume ASCII. X (longopts): Remove old aliases --file-label, --entire-new-file, X --ascii, --print. X (main): Check for -1, not EOF, when calling getopt_long. X Use numeric_arg to report errors. X Report error if -l specified but pagination is not supported. X Report error if -S is specified twice with conflicting values. X Have --version conform to the new GNU standards. X Add new --from-file, --to-file, --inhibit-hun,-merge options. X Make the horizon at least as large as the context. X Add casts to pacify gcc -Wall. X (try_help): Add operand arg. X (option_help_msgid): Doc fix to match above. X (usage): Indent option_help_msgid. X (compare_files): Now takes struct comparison X instead of two directory names and a depth. X (NONEXISTENT, UNOPENED, ERRNO_ENCODE, ERRNO_DECODE): X New macros. X (DIR_P): New macro. X Report error if fflush does. X X * cmpbuf.c (block_read): Moved here from cmp.c. X X * cmpbuf.h (block_read): New decl. X X * io.c (cmpbuf.h): Include. X (slurp): Check for arithmetic overflow when computing buffer size. X X * dir.c (diff_dirs): Check for recursive directory loop. X Arg is now struct comparison const *. X (dir_loop): New function X X * analyze.c (no_discards): Remove. X (inhibit): Remove. X (shift_boundaries): Don't inhibit. If inhibit_hunk_merge is nonzero, X don't merge hunks. X (briefly_report): Now returns 2 if trouble, CHANGES otherwise. X (diff_2_files): Now takes struct comparison. If briefly_report reports X trouble, pass it on to caller. X X * side.c (print_half_line): Add brackets to pacify GCC -Wall. X X * sdiff.c (quotesys.h): Include. X (DIFF_PROGRAM, DEFAULT_EDITOR_PROGRAM): Remove. X (free_software_msgid, editor_program, not_found): New vars. X (diffbin, edbin): Remove. X (editor_program): Renamed from edbin. X (edit, interact): Now take extra string arg. X (exiterr, fatal, perror_fatal, try_help): Add noreturn attribute. X (sigset_t, sigemptyset, sigmask, sigaddset, SIG_BLOCK, SIG_SETMASK): X (sigprocmask): New macros, if !HAVE_SIGPROCMASK. X (error): Now has printf attribute. X (longopts, main): Don't assume ASCII. X (try_help): New operand arg. X (usage): Conform to new GNU standards. X (main): Set static vars for editor and diff program. X Compare getopt_long result to -1, not EOF. X -v conforms to new GNU standard. X Complain better about extra and missing operands. X If HAVE_VFORK, block SIGINT and SIGPIPE in the parent, since when X the child munges its handlers it may somp on the parent. X Pass rname to intract. X Translate not-found message before forking. X (give_help): Just output it all at once. X (edit): New args lname, lline, rname, rline. X (edit): New command 'd'. X (interact): New args lname, rname. X X * util.c (quotesys.h): Include. X (PR_PROGRAM): New macro. X (pfatal_with_name): Abort if error returns. X (fatal): Likewise. X (print_message_queue): Free message chain after printing. X (currently_recursive): Renamed from current_depth, and now a boolean. X (begin_output): Report error if fflush does. X Avoid stdio and gettext in child. X X * diff3.c (quotesys.h): Include. X (free_software_msgid): New decl. X (RANGE_START, RANGE_END): Renamed from START and END. X (fatal, perror_with_exit, try_help): Add noreturn attribute. X (error): Add printf attribute. X (diff_program): Now a ptr, not an array. X Initialize to DEFAULT_DIFF_PROGRAM instead of DIFF_PROGRAM. X (longopts, main): Don't assume ASCII. X (main): Use DIFF environment var to specify name of diff program. X Compare getopt_long result to -1, not EOF. X -v now reports version according to new GNU standard. X Report spelling of extra operand, or last operand before missing one. X (try_help): Now takes operand arg. X (option_help_ms): Fix typo: missing comma. X (usage): Update as per current GNU standards. X (environ): Remove decl. X (read_diff): Invoke diff with --inhibit-hunk-merge. X Translate `not found' message before forking. X Quote name of diff program. X Pass horizon lines. X `memory exhausted' -> `Memory exhausted' X X * pc/makefile (%.exe): Remove. X (pc-clean): Remove *.exe X * pc/makefile.sed (DEFAULT_DIFF_PROGRAM): Renamed from DIFF_PROGRAM. X When editing mkinstalldirs rule, look for exec_prefix and prefix. X Add .exe when installing files. X * pc/emx/config.h (same_file): Add. X * pc/config.h (same_file): Remove. X * pc/djgpp/config.h: Adjust to latest patch from eliz. X * pc/djgpp/makefile.sed: Don't alter PROGRAMS. X * pc/pc.c: Update FSF address. X (quote_system_arg): Renamed from system_quote_arg. X X * README: Add --with-mvfs-stat-bug, --with-nfs-stat-bug. X X * getmsgids: Add copyright date and update FSF address. X X * diff.texi: Document recent changes. X The patch doc still corresponds to patch 2.2, unfortunately. X Update GNU bug reporting address. Omit Larry Wall's address; X it's obsolete and he's busy with perl. X X * context.c: Fix spacing. X X * NEWS: Mention --from-file=FILE, --to-file=FILE, ed. X X * acconfig.h, freesoft.c, message/de.po, message/en_UK.po, X message/es.po, message/fr.po, message/pl.po, message/sv.po: X New files. X X * ed.c: Remove `#if 0'ed code. X X * normal.c, waitpid.c: Update FSF address. X X1998-03-15 Paul Eggert X X * quotesys.c: Renamed from quotearg.c. X X * quotesys.h: Renamed from quotearg.h X (__QUOTESYS_P): Renamed from __QUOTEARG_P. X X1997-05-05 Paul Eggert X X * quotesys.c, quotesys.h: New file. X XMon Nov 14 05:10:56 1994 Paul Eggert X X Add internationalization support. X Several messages have been changed slightly, X to make them more consistent and easier to translate. X All strings that are messages are passed through gettext once before X being used, so that they can be localized. X Each function and macro whose first parameter is a gettext msgid X has had its first parameter's name changed so it ends in `msgid'. X All arrays of msgids have had their names changed to end in `msgid'. X `getmsgids' uses this to determine which strings are msgids. X X * pc/COPYING, pc/INSTALL, pc/config.h, X pc/djgpp/config.h, pc/djgpp/makefile.sed, X pc/emx/config.h, pc/emx/diff.def, pc/emx/gnuregex.def, X pc/emx/makefile.sed, X pc/makefile, pc/makefile.sed, pc/pc.c: New files, for PC support. X X * getmsgids: New file. X X * Makefile.in (PACKAGE, VERSION, diffutils_srcs, D): New vars. X (version.c, version.texi, messages.po): New files. X messages.po is built automatically from source files and `getmsgids'. X (distfiles): Add them, pc/*, and getmsgids. X (diff.info): Now depends on version.texi. X (realclean): Clean messages.po, version.*. X (dist): Just build $D.tar.gz. X ($D.tar.gz): New file, takes over old `dist' function. X Don't assume $(distfiles) are all in same directory. X X * configure.in (AC_CHECK_HEADERS): Add libintl.h, locale.h. X (AC_CHECK_LIB): Check for -lintl. X X * analyze.c (briefly_report): Rewrite `message (A?"B":"C")' as X `if (A) message ("B") : message ("C")'; this is for getmsgids. X (briefly_report, diff_2_files): For label, use file_label if set. X * diff.c (compare_files): Likewise. X X * system.h (gettext): Declare; use a stub if ! HAVE_LIBINTL_H. X (setlocale): Declare; use a stub if ! HAVE_LOCALE_H. X X * cmp.c, diff.c, diff3.c, sdiff.c (main): X Invoke setlocale first thing, to tell library we're internationalized. X (option_help_msgid): New constant. X (usage): Use it, so message is translated one option at a time. X * sdiff (help_msgid, give_help): Likewise. X X * cmp.c (sprintc): Renamed from `printc'. X Now outputs to a buffer instead of stdout. X (cmp): Use new sprintc; it's easier to internationalize. X X * diff.c (main): -D FOO now outputs `/* ! FOO */ instead of X `/* not FOO */'. X X * sdiff.c (version_string): Fix decl typo: `const' was missing. X (trapsigs): Ignore sigaction failure, to be compatible with `signal'. X X * util.c (struct msg, message5, print_message_queue): X Allocate just one block of memory to save a message. X XWed Nov 9 17:42:44 1994 Paul Eggert X X * sdiff.c (trapsigs): Don't check signal return value, since it's X bogus under djgpp. X XMon Oct 31 07:27:27 1994 Paul Eggert X X * Makefile.in (srcs, diff_o, diff3_o, sdiff_o): X New files quote.c, quote.o. X X * diff.h (function_regexp, ignore_regexp): Replace lists of compiled X regexps with these single compiled regexps. All users changed. X (regexp_list,function_regexp_list,ignore_regexp_list): Move to diff.c. X * diff.c (add_regexp): Build one big regexp instead of a regexp list. X (summarize_regexp_list): New function. X (regexp_list): Redesigned struct; moved here from diff.h. X (function_regexp_list, ignore_regexp_list): Likewise, for vars. X X * context.c (find_function): Simplify interface: X don't return size of function line. All callers changed. X (print_context_script, find_function): INT_MAX now denotes no X previous match; this is simpler than `- file->prefix_lines - 1'. X X * diff3.c (read_diff): Quote arguments with system_quote_arg. X * sdiff.c (main): Use system_quote_arg to compute command. X * diff.c (option_list): Quote options with system_quote_arg. X * util.c (begin_output): Use system_quote_arg to compute command. X X * util.c (pr_program): New var. X (analyze_hunk): Fix off-by-1 line length bug. X Match with one big regexp instead of a list of regexps. X Use new `trivial_length' local instead of comparing first byte to `\n'. X Help the compiler with linbuf local vars. X X * system.h (system_quote_arg): X New function; replaces SYSTEM_QUOTE_ARG macro. X XSat Oct 15 20:09:12 1994 Paul Eggert X X * system.h (_tolower): Define if not already defined. X * io.c (find_and_hash_each_line): Change tolower to _tolower; this X speeds up diff -i considerably on some hosts (e.g. Solaris 2.3). X * util.c (line_cmp): Likewise. X * ifdef.c (groups_letter_value): Likewise. X X * diff.h (ignore_some_line_changes): Remove. All users changed. X * io.c (find_and_hash_each_line): Don't invoke line_cmp if the length X differs and -i is in force. Don't assume ISSPACE ('\n') is nonzero. X X * diff.h (xmalloc_exit_failure): New variable. X All `main' programs set this variable at the start. X xmalloc and xrealloc are now taken from GNU library. X * cmp.c (main): Align buffer size to word size; some mallocs care. X * io.c (slurp): Likewise. X * diff.c (add_exclude): Can now assume xrealloc (0, ...) works. X (add_regexp): Free storage on failure. Allocate storage all at one go. X * system.h (malloc, realloc): Remove unused declarations. X * diff3.c, sdiff.c, util.c (xmalloc, xrealloc): Remove. X * sdiff.c (diffarg): Take advantage of cleaner xrealloc semantics. X X * io.c (ROL): Use sizeof to make it more generic. X X * Makefile.in (common_o): New variable. X Link error.o and xmalloc.o into all programs. X (check): Depend on $(PROGRAMS). X X * diff.h (error): Change to GNU library standard. All callers changed. X * diff3.c (main): Use strerror (EISDIR) instead of "Is a directory". X (fatal, perror_with_exit): Use `error'. X * util.c (perror_with_name, fatal): Use GNU `error'. X (error): Remove. X XWed Oct 12 17:04:40 1994 David J. MacKenzie (djm@duality.gnu.ai.mit.edu) X X * cmp.c (main): Set xmalloc_exit_failure. X XSat Oct 1 05:24:19 1994 Paul Eggert X X * Version 2.7 released. X X * configure.in (AC_HEADER_SYS_WAIT): Add. X (AC_CHECK_HEADERS): Remove sys/wait.h. X (AC_CHECK_FUNCS): Add tmpnam. X * system.h (, WEXITSTATUS): Use simpler scheme X now that HAVE_SYS_WAIT_H is not set on hosts X that are incompatible with Posix applications. X X * util.c (dir_file_pathname): Use filename_lastdirchar not strrchr. X * sdiff.c (expand_name): Likewise. X (private_tempnam): Use tmpnam if HAVE_TMPNAM; this simplifies porting. X (exists, letters): Omit if HAVE_TMPNAM. X X * diff3.c (read_diff): If STAT_BLOCKSIZE yields zero, X adjust it to a more reasonable value. X XSat Sep 24 20:36:40 1994 Paul Eggert X X * sdiff.c (exists, private_tempname): Adopt latest GNU libc algorithm. X (private_tempnam): Specialize for sdiff to avoid portability problems. X XThu Sep 22 16:47:00 1994 Paul Eggert X X * configure.in (AC_ARG_PROGRAM): Added. X (AC_OUTPUT): Add [date > stamp-h]. X X * Makefile.in (DEFAULT_EDITOR_PROGRAM, DIFF_PROGRAM, LIBOBJS, X NULL_DEVICE, PR_PROGRAM, PROGRAMS): New variables. X (check, stamp-h.in, cmp.o, util.o): New targets. X (edit_program_name): New variable; replaces old binprefix method. X (install, uninstall): Use it. X (binprefix): Removed. X (distfiles): Add stamp-h.in. X (clean): Clean stamp-h. X (config.hin, config.h): Use time stamp files. X (cmp_o): Add $(LIBOBJS). X (install): Install info files from srcdir if they're not in `.'. X X * cmp.c, io.c (word): Don't define if already defined. X X * comp.c (main): Use setmode, not open(..., O_BINARY); this gets stdin. X Use NULL_DEVICE instead of "/dev/null". X (cmp): Use %lu instead of %ld when it is more likely to be right. X X * diff.h (PR_FILE_NAME): Rename to PR_PROGRAM and move to Makefile.in, X util.c. X X * diff3.c (main): Give proper diagnostic if too many labels were given. X (read_diff): Use SYSTEM_QUOTE_ARG. X X * system.h: : Include if HAVE_STRING_H, too. X : Include here. All includers changed. X (CTYPE_DOMAIN, ISDIGIT, ISPRINT, ISSPACE, ISUPPER): New macros that X work around common problems. X (O_BINARY): Remove. X (SYSTEM_QUOTE_ARG): New macros. X X * diff.c: Add comment. X X * util.c (PR_PROGRAM): Moved here from diff.h. X (begin_output): Use SYSTEM_QUOTE_ARG. X X * io.c (read_files): Set mode to binary before returning 1. X X * sdiff.c (TMPDIR_ENV): New macro. X (DEFAULT_EDITOR_PROGRAM): Renamed from DEFAULT_EDITOR for consistency. X (expand_name): Change `isdir' to `is_dir' to avoid theoretical ctype X namespace contamination. X (main): Use SYSTEM_QUOTE_ARG. X (private_tempnam): Don't access "/tmp" directly; use PVT_tmpdir. X XTue Sep 13 18:46:43 1994 Paul Eggert X X * configure.in (AC_FUNC_MEMCHR): Remove. Autoconf didn't adopt this, X since we need not worry about an old experimental library X where memchr didn't work. X (AC_FUNC_MEMCMP): Not needed, since we only test for equality. X (AC_REPLACE_FUNCS): Add test for memchr. X (AC_CHECK_FUNCS): Check for memchr, not memcpy, since it'll be cached. X (AC_CHECK_HEADERS): Add string.h; regex.c uses on some old hosts. X X * system.h (memcmp): Define in terms of bcmp. X Use HAVE_MEMCHR to test for all mem* routines. X X * Makefile.in (srcs): Remove memcmp.c. X We use bcmp if memcmp doesn't work, since we only test for equality. X XMon Sep 12 15:52:22 1994 Paul Eggert X X * configure.in (AC_CONFIG_HEADER): Rename config.h.in to config.hin. X (AC_ISC_POSIX, AC_MINIX): Go back to these old names for Autoconf 2. X (AC_CHECK_HEADERS): Remove now-redundant check for . X (AC_CHECK_FUNCS): Check for strchr. X (AC_FUNC_MEMCHR, AC_FUNC_MEMCMP, AC_CHECK_FUNCS): Use special-purpose X macros when suitable. X * memcmp.c: New file. X * Makefile.in (CPPFLAGS, DEFS, CFLAGS, LDFLAGS, prefix, exec_prefix): X Default to autoconf-specified strings. X (COMPILE): Use the defaults. X (srcs): Add memcmp.c. X (distfiles): Rename config.h.in->config.hin, install.sh->install-sh. X (Makefile, config.h, config.hin, config.status): Rework for X compatibility with Autoconf 2. X * io.c (binary_file_p): Assume non-broken memchr. X * memchr.c: Assume compiler understands void *; otherwise X we don't match GCC's internal declaration of memchr. X * system.h: Use more modern autoconf approach to standard C headers. X * version.c: Include , not "config.h". X X * diff.c, diff.h (ignore_some_line_changes): X New variable; replaces `length_varies'. X (line_end_char): Replace with '\n'; it wasn't being used consistently. X X * io.c (find_and_hash_each_line): Fix inconsistencies with -b -w -i and X incomplete lines. Put incomplete lines into their own bucket. X This means line_cmp no longer needs line length arguments, X and equivalence classes' line lengths no longer need to include \n. X Invoke line_cmp only if ignore_some_line_changes. X (prepare_text_end): -B no longer ignores missing newlines. X (read_files): Allocate another bucket for incomplete lines. X X * util.c (line_cmp): Now takes just two arguments. No longer X optimizes for common case of exact equality; the caller does that X optimization now. The caller is changed accordingly. X Optimize for the common case of mostly equality. X Use isupper+tolower instead of islower+toupper, for consistency. X X * waitpid.c (waitpid): Fix typo with internal scoping. X XThu Sep 8 08:23:15 1994 Paul Eggert X X * configure.in: Revamp for Autoconf 2. X * memchr.c, waitpid.c: New source files for substitute functions. X * Makefile.in (diff_o, diff3_o, sdiff_o): Add $(LIBOBJS). X (srcs): Add memchr.c, waitpid.c. X (distfiles): Add install.sh, memchr.c, waitpid.c, install.sh. X * system.h: Use Autoconf 2 style HAVE_DIRENT_H etc. macros for dirs. X * dir.c (dir_sort): Prefer NAMLEN (p) to strlen (p->d_name). X Change VOID_CLOSEDIR to CLOSEDIR_VOID for Autoconf 2. X * sdiff.c, util.c (memchr, waitpid): Remove; use new substitutes. X * diff3.c (read_diff): Use new waitpid substitute. X X * cmp.c, diff.c, diff3.c, sdiff.c (check_stdout, try_help): New fns. X (usage): Just print more detailed usage message; let caller exit. X * diff.c (option_help): New variable. X (filetype): Add Posix.1b file types. X XFri Sep 2 16:01:49 1994 Paul Eggert X X * configure.in: Switch to new autoconf names. Add sys/file.h test. X * Makefile.in (distclean): Clean config.cache, config.log X (used by new autoconf). X X * diff.c, diff3.c, (main), sdiff.c (trapsigs): If we'll have children, X make sure SIGCHLD isn't ignored. X X * diff3.c (DIFF_CHUNK_SIZE): Removed. Get size from STAT_BLOCKSIZE. X (INT_STRLEN_BOUND): New macro. X X * ifdef.c (format_group, groups_letter_value): X Use * instead of [] in prototypes. X X * system.h: Include only if HAVE_SYS_FILE_H. X (S_IXGRP, S_IXOTH, S_IXUSR): Remove unused macros. X X * util.c (begin_output): Check fdopen result. X X The following changes simplify porting to non-Posix environments. X * cmp.c, diff.c, diff3.c, sdiff.c, (main): Call initialize_main first. X * diff.c (binary_I_O): New variable for --binary option. X (main, usage, compare_files): Support --binary option. X (compare_files): Use filename_lastdirchar to find last X directory char in a file name. X * cmp.c (main), diff.c (compare_files), dir.c (compare_names, X diff_dirs): Use filename_cmp to compare file names. X Use same_file to determine whether two files are the same. X * context.c (print_context_label): Check whether ctime yields 0. X * diff3.c (read_diff), sdiff.c (cleanup, main, waitpid), X util.c (begin_output): Use popen+pclose if !HAVE_FORK. X * io.c (sip): If HAVE_SETMODE, test for binary files in O_BINARY mode. X * sdiff.c (ck_fdopen): Function removed. X (edit): Use system if !HAVE_FORK. X (execdiff): Now assumes caller has pushed all args, plus trailing 0. X All callers changed. X (private_tempnam): Try TMP if TMPDIR isn't defined. X Fit temporary filenames into 8.3 limit. X * system.h (STAT_BLOCKSIZE): Don't define if already defined. X (min, max): Undef if already defined. X (filename_cmp, filename_lastdirchar, HAVE_FORK, HAVE_SETMODE, X initialize_main, O_BINARY, same_file): New macros. X XFri Jun 17 11:23:53 1994 David J. MacKenzie (djm@geech.gnu.ai.mit.edu) X X * Makefile.in (info, dvi, diff.dvi): New targets. X (clean): Remove TeX output files. X XFri Jun 17 05:37:52 1994 Paul Eggert (eggert@twinsun.com) X X * cmp.c, io.c (word): Change from typedef to #define, to avoid X collision with Unicos 8.0 , which also typedefs `word'. X XThu Apr 15 00:53:01 1994 Paul Eggert (eggert@twinsun.com) X X * diff3.c (scan_diff_line), util.c (print_number_range): Don't X rely on promotion to make the old-style parameter type agree X with the prototype parameter type; this doesn't work on X Apollos running bsd4.3. X XMon Jan 3 02:05:51 1994 Paul Eggert (eggert@twinsun.com) X X * Makefile.in (LDFLAGS): Remove -g. Change all link commands X to use both $(CFLAGS) and $(LDFLAGS). X XMon Dec 13 12:23:27 1993 Paul Eggert (eggert@twinsun.com) X X * system.h: Don't assume dirent.h exists just because X _POSIX_VERSION is defined. X XFri Dec 3 18:39:39 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c (main): allow -pu. X XTue Nov 23 03:51:08 1993 Paul Eggert (eggert@twinsun.com) X X * Makefile.in (distclean): Remove config.h. X XWed Nov 10 00:28:27 1993 Paul Eggert (eggert@twinsun.com) X X * Version 2.6 released. X X * analyze.c (too_expensive): New variable, for heuristic to X limit the worst-case cost to O(N**1.5 log N) at the price of X producing suboptimal output for large inputs with many differences. X (diff_2_files): Initialize it. X (struct partition): New type. X (SNAKE_LIMIT): New macro; merely documents already-used number 20. X (diag): New `minimal' arg; all callers changed. Put results into X struct partition. Apply `too_expensive' heuristic. Tune. X (compareseq): New `minimal' arg; all callers changed. Tune. X (shift_boundaries): Improve heuristic to also coalesce adjacent runs X of changes more often. X X * diff.c (long_options, main, usage): Add `--help'. X (main): Send version number to stdout, not stderr. X (usage): Send usage to stdout, not stderr. X (compare_files): Initialize `inf' properly. X X * io.c (word): Change to `int'; it makes a big difference on x86. X (sip, slurp): Put off allocating room to hold the whole file until we X have to read the whole file. This wins if the file turns out X to be binary. X X * util.c (xmalloc, xrealloc): "virtual memory" -> "memory" X (primes): Omit large primes if INT_MAX is small. X X * sdiff.c (usage): Send usage to stdout, not stderr. X (long_options, main, usage): Add `--help'. X (main): Send version number to stdout, not stderr. Exit afterwards. X X * diff3.c (usage): Send usage to stdout, not stderr. X (long_options, main, usage): Add `--help'. X (read_diff): Detect integer overflow in buffer size calculations. X X * cmp.c (word): New type. All uses of `long' for X word-at-a-time comparisons changed to `word'. X (long_options, main, usage): Add `--help'. X (usage): Send usage to stdout, not stderr. X (main): Add `-v'. Send version number to stdout, not stderr. X X * configure.in (AC_HAVE_HEADERS): Add unistd.h; remove AC_UNISTD_H. X XMon Sep 27 07:20:24 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c (add_exclude_file): Cast memchr to (char *) X to suppress bogus warnings on some nonstandard hosts. X X * Makefile.in (cmp): Add version.o. X X * analyze.c (diff_2_files): Work around memcmp bug with size=0. X X * cmp.c (main, usage, version_string): Add --version option. X X * system.h (malloc, realloc): Declare only if !HAVE_STDLIB_H. X (memchr): Declare only if !HAVE_MEMCHR. These changes are X needed to keep some nonstandard hosts happy. X X * util.c (memchr): Make first arg char const * X to match standard. X (xmalloc, xrealloc): Cast malloc, realloc X to (VOID *) to suppress bogus warnings on some nonstandard hosts. X X * diff3.c (xmalloc, xrealloc): Cast malloc, realloc X to (VOID *) to suppress bogus warnings on some nonstandard hosts. X X * sdiff.c (xmalloc, xrealloc): Cast malloc, realloc X to (VOID *) to suppress bogus warnings on some nonstandard hosts. X (lf_copy, lf_skip, lf_snarf): Cast memchr to (char *) X to suppress bogus warnings on some nonstandard hosts. X (memchr): Make first arg char const * X to match standard. X XMon Sep 27 00:23:37 1993 Paul Eggert (eggert@twinsun.com) X X * Version 2.5 released. X X * analyze.c (diff_2_files): Work around memcmp bug with size=0. X X * cmp.c (main, usage, version_string): Add --version option. X * Makefile.in (cmp): Add version.o. X X * diff.c (add_exclude_file): Cast memchr to (char *) X to suppress bogus warnings on some nonstandard hosts. X * sdiff.c (lf_copy, lf_skip, lf_snarf): Likewise. X X * diff3.c, sdiff.c, util.c (xmalloc, xrealloc): Cast malloc, realloc X to (VOID *) to suppress bogus warnings on some nonstandard hosts. X X * sdiff.c, util.c (memchr): Make first arg char const * X to match standard. X X * system.h (malloc, realloc): Declare only if !HAVE_STDLIB_H. X (memchr): Declare only if !HAVE_MEMCHR. These changes are X needed to keep some nonstandard hosts happy. X X * xmalloc.c: Include always; some nonstandard hosts X need it for size_t even if STDC_HEADERS. X XSat Sep 18 01:33:07 1993 Paul Eggert (eggert@twinsun.com) X X * configure.in (AC_STAT_MACROS_BROKEN): Add. X * system.h (S_IS{BLK,CHR,DIR,FIFO,REG,SOCK}): Fix defns if X STAT_MACROS_BROKEN. X X * Makefile.in (diff3, sdiff, cmp): Do not link $(ALLOCA). X X * analyze.c (discard_confusing_lines): Make defn static, like decl. X * sdiff.c (xmalloc): Likewise. X X * ifdef.c (format_group): Ensure isdigit argument isn't < 0. X X * side.c (print_half_line): Use isprint, since some hosts lack isgraph. X * util.c (output_1_line): Likewise. Ensure its argument isn't < 0. X (xmalloc, xrealloc): Remove needless casts. X X * system.h (volatile, const): X Define these before including any system headers, X so that they're used consistently in all system includes. X (getenv, malloc, realloc): Declare even if HAVE_STDLIB_H, since some X s don't declare them. X (memchr): Likewise for . X X * cmp.c, diff3.c, diff.h, sdiff.c: Include "system.h" first. X * diff.c: Remove redundant "system.h" inclusion. X X * diff3.c (xmalloc): Now static. X (xmalloc, realloc): Remove needless casts. X (READNUM): Ensure isdigit argument isn't negative. X XWed Sep 14 07:14:15 1993 Paul Eggert (eggert@twinsun.com) X X * Version 2.4 released. X X * ifdef.c (scan_char_literal): New function, for new %c'x' and X %c'\ooo' format specs. X (format_group, print_ifdef_lines): Use it. Remove %0 format spec. X X * cmp.c (cmp): Don't try to read past end of file; this doesn't X work on ttys. X X * system.h, version.c: #include , not "config.h", to allow X configuring in a separate directory when the source directory has X already been configured. X * Makefile.in (COMPILE): New defn, with proper -I options so that X `#include ' works. X (.c.o, diff3.o, sdiff.o): Use it. X XMon Sep 13 06:45:43 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c (main, longopts): Add --line-format=FORMAT option. X (specify_format): Args no longer const pointers. All callers changed. X X * ifdef.c: Add support for %?c, %(A=B?T:E), PRINTF_SPECn formats. X (struct group): New struct. X (print_ifdef_lines): Use it to simplify argument passing. X Remove the convention that last arg -1 signifies that the lines X from file 2 are the same as the lines from file 1; this X convention no longer works, now that line numbers might be X printed out, since the line numbers may differ. X Add first FILE * argument to output to. All callers changed. X Use a faster test for the single-fwrite optimization. X (format_group, scan_printf_spec, groups_letter_value): New functions. X X * diff.h (group_format, line_format): No longer const pointers. X (format_ifdef): 1st arg is no longer const pointer. X X * configure.in: Configure HAVE_LIMITS_H, HAVE_STDLIB_H. X * system.h , , : X Include only if HAVE_LIMITS_H etc. X X * system.h (memcmp, memcpy, strchr, strrchr, struct dirent): Prefer X these standard names to the traditional names (bcmp, bcpy, index, X rindex, struct direct). All callers changed. X X * system.h (PARAMS, VOID): X Define earlier so that malloc decl can use VOID. X (STAT_BLOCKSIZE): Simplify ersatz defn; just use 8K. X XFri Sep 3 00:21:02 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c (compare_files): Two files with the same name must be X the same file; avoid a needless `stat' in that case. X XFri Aug 27 06:59:03 1993 Paul Eggert (eggert@twinsun.com) X X * Pervasive changes for portability to 64-bit hosts: X Add prototypes to function declarations. X Use size_t, not int, when needed. X X * Other pervasive changes: X Use `const' more often. X Use STD{IN,OUT,ERR}_FILENO instead of [012]. X Use 0, not NULL, for portability to broken hosts. X X * Makefile.in: (srcs, objs, distfiles, cmp): New files cmpbuf.[ch]. X (distfiles): New files config.h.in, mkinstalldirs. X (.c.o): Add -DHAVE_CONFIG_H. X X * analyze.c: (diag): Pacify `gcc -Wall' with a useless assignment. X (diff_2_files): Use l.c.m., not max, of files' buffer sizes. X X * cmp.c: Make globals static when possible. X X (file): Now a 2-element array; replaces `file1' and `file2'. X (file_desc, buffer): Likewise, for file[12]_desc and buf[12]. X (main): Likewise, for stat_buf[12]. Index these variables with `i'. X X (ignore_initial): New var. X (long_options): Now const. Add `--ignore-initial'. X (usage): Sort options and add `--ignore-initial'. X (main, cmp): Add `--ignore-initial' support. X X (main): `cmp - -' now succeeds. X When comparing standard input to a file, and using a shortcut (e.g. X looking at file sizes or inode numbers), take the lseek offset into X account before deciding whether the files are identical. X Avoid mentioning `dev_t', `ino_t' for portability to nonstandard hosts. X Use l.c.m. of files' buffer sizes, not 8 * 1024. X ferror (stdout) does not imply errno has a useful value. X If 2nd file is "-", treat it first, in case stdin is closed. X X (cmp): Always compute `char_number', `smaller' for speed and simplicity. X Say `cmp: EOF on input', not `/usr/gnu/bin/cmp: EOF on input', X as per Posix.2. X X (block_compare_and_count): Increment line_number argument. X Remove end_char argument; it's always '\n'. All callers changed. X Do not assume sizeof(long) == 4; this isn't true on some 64-bit hosts. X (block_compare): Minimize differences with block_compare_and_count. X X (block_read): Coalesce `bp += nread's. X X (printc): Remove `FILE *' arg; output to stdout. All callers changed. X X * configure.in: Configure HAVE_SIGACTION, RETSIGTYPE, HAVE_VPRINTF. X Configure into config.h. X X * context.c (print_context_label): X Standard input's st_mtime is no longer a special case X here, since `compare_files' now sets it to the current time. X X * diff.c (usage): Sort options. X (filetype): New function. X (compare_files): Set stdin's st_mtime to be the current time. X Leave its name "-" instead of changing it to "Standard Input"; X to test whether a file is stdin, we must compare its name to "-" instead X of its desc to 0, since if it's closed other file descs may be 0. X When comparing standard input to a file, and using a shortcut (e.g. X looking at file sizes or inode numbers), take the lseek offset into X account before deciding whether the files are identical. X Pretend that nonexistent files have the same filetype as existing files. X Rename `errorcount' to `failed', since it's boolean. X In directory comparisons, if a file is neither a regular file nor a X directory, just print its type and the other file's type. X X * diff.h (Is_space, textchar): Remove. X (struct msg, msg_chain, msg_chain_end): Move to util.c. X (VOID): Move to system.h. X (line_cmp, version_string, change_letter, print_number_range, X find_change): New decls. X X * diff.texi: X whitespace -> white space. It now stands for whatever isspace yields. X Add --ignore-initial. X X * diff3.c (VOID): Move to system.h. X (version_string): Now char[]. X (usage): Sort options. X (process_diff): Pacify `gcc -Wall' with a useless assignment. X (read_diff): pid is of type pid_t, not int. Use waitpid if available. X (output_diff3): Simplify test for `\ No newline at end of file' message. X X * dir.c (struct dirdata): Rename `files' to `names' to avoid confusion X with external struct file_data `files'. X X * io.c (line_cmp): Move declaration to diff.h. X (textchar): Remove. X (find_and_hash_each_line): Use locale's definition of white space X instead of using one hardwired defn for -b and another for -w. X X * normal.c (change_letter, print_number_range, find_change): X Move decls to diff.h. X (print_normal_hunk): Now static. X X * sdiff.c (SEEK_SET): Move to system.h. X (version_string): Now char[], not char*. X (private_tempnam): Remove hardcoded limit on temporary file names. X (exiterr, perror_fatal, main): When exiting because of a signal, X exit with that signal's status. X (lf_refill, main, skip_white, edit, interact): Check for signal. X (ignore_SIGINT): Renamed from `ignore_signals'. X (NUM_SIGS, initial_handler): New macros. X (initial_action, signal_received, sigs_trapped): New vars. X (catchsig, trapsigs): Use sigaction if possible, since this closes the X windows of vulnerability that `signal' has. Use RETSIGTYPE not void. X When a signal comes in, just set a global variable; this is safer. X (checksigs, untrapsig): New functions. X (edit): Pacify `gcc -Wall' with a useless assignment. X Respond to each empty line with help, not to every other empty line. X (private_tempnam): Remove hardcoded limit on temporary file name length. X Don't assume sizeof (pid_t) <= sizeof (int). X X * system.h: (S_IXOTH, S_IXGRP, S_IXUSR, X SEEK_SET, SEEK_CUR, X STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO): X New macros, if system doesn't define them. X (volatile): Don't define if already defined. X (PARAMS): New macro. X (VOID): Move here from diff.h. X X * util.c (struct msg, msg_chain, msg_chain_end): Moved here from diff.h. X (message5): New function. X (pr_pid): New var. X (begin_output): Allocate `name' more precisely. X Put child pid into pr_pid, so that we can wait for it later. X Don't check execl's return value, since any return must be an error. X (finish_output): Detect and report output errors. X Use waitpid if available. Check pr exit status. X (line_cmp): Use locale's definition of white space X instead of using one hardwired defn for -b and another for -w. X (analyze_cmp): Avoid double negation with `! nontrivial'. X Pacify `gcc -Wall' be rewriting for-loop into do-while-loop. X (dir_file_pathname): New function. X X * version.c (version_string): Now char[], not char*. X XThu Jul 29 20:44:30 1993 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) X X * Makefile.in (config.status): Run config.status --recheck, not X configure, to get the right args passed. X XThu Jul 22 10:46:30 1993 Paul Eggert (eggert@twinsun.com) X X * Makefile.in (dist): Replace `if [ ! TEST ]; then ACTION; fi' X with `[ TEST ] || ACTION || exit' so that the containing for-loop exits X with proper status for `make'. X XThu Jul 8 19:47:22 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) X X * Makefile.in (installdirs): New target. X (install): Use it. X (Makefile, config.status, configure): New targets. X XSat Jun 5 23:10:40 1993 Paul Eggert (eggert@twinsun.com) X X * Makefile.in (dist): Switch from .z to .gz. X XWed May 26 17:16:02 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c (main): Cast args to compare_files, for traditional C. X * side.c (print_sdiff_common_lines_print_sdiff_hunk): Likewise. X * analyze.c, diff3.c, sdiff.c, util.c: Don't assume NULL is defined X properly. X XTue May 25 14:54:05 1993 Paul Eggert (eggert@twinsun.com) X X * analyze.c (diff_2_files): With -q, do not report that files differ X if all their differences are ignored. X (briefly_report): New function. X * diff.h (ignore_some_changes): New variable. X * diff.c (compare_files): Don't use the file size shortcut if X ignore_some_changes is nonzero, since the file size may differ X merely due to ignored changes. X (main): Set ignore_some_changes if we might ignore some changes. X Remove unsystematic assignment of 0 to static vars. X * io.c (read_files): New argument PRETEND_BINARY says whether to X pretend the files are binary. X X * diff3.c (tab_align_flag): New variable, for new -T option. X (main, usage, output_diff3): Add support for -T. X XSun May 23 15:25:29 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * dir.c (dir_sort): Always init `data' to avoid GCC warning. X XSat May 22 15:35:02 1993 Paul Eggert (eggert@twinsun.com) X X * Makefile.in (dist): Change name of package from diff to diffutils. X Don't bother to build .Z dist; .z suffices. X XFri May 21 16:35:22 1993 Paul Eggert (eggert@twinsun.com) X X * diff.c: Include "system.h" to get memchr declaration. X * system.h (memchr): Declare if !HAVE_MEMCHR, not if X !HAVE_MEMCHR && !STDC_HEADERS. X XWed May 19 17:43:55 1993 Paul Eggert (eggert@twinsun.com) X X * Version 2.3 released. X XFri Apr 23 17:18:44 1993 Paul Eggert (eggert@twinsun.com) X X * io.c (find_identical_ends): Do not discard the last HORIZON_LINES X lines of the prefix, or the first HORIZON_LINES lines of the suffix. X * diff.c (main, longopts, usage): Add --horizon-lines option. X * diff3.c (main, process_diff, read_diff): Invoke second diff X with --horizon-lines determined by the first diff. X * diff.h, diff3.c (horizon_lines): New variable. X XMon Mar 22 16:16:00 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) X X * system.h [HAVE_STRING_H || STDC_HEADERS] (bcopy, bcmp, bzero): X Don't define if already defined. X XFri Mar 5 00:20:16 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * diff.c (main): Use NULL in arg to compare_files. X XThu Feb 25 15:26:01 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) X X * system.h: Declare memchr #if !HAVE_MEMCHR && !STDC_HEADERS, X not #if !HAVE_MEMCHR || !STDC_HEADERS. X XMon Feb 22 15:04:46 1993 Richard Stallman (rms@geech.gnu.ai.mit.edu) X X * io.c (find_identical_ends): Move complicated arg outside GUESS_LINES. X XMon Feb 22 12:56:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) X X * Makefile.in (.c.o): Add -I$(srcdir); put $(CFLAGS) last before $<. X XSat Feb 20 19:18:56 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * io.c (binary_file_p): Return zero if file size is zero. X XFri Feb 19 17:31:32 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) X X * Version 2.2 released. X X * system.h [HAVE_STRING_H || STDC_HEADERS] (index, rindex): Don't X define if already defined. X XWed Feb 17 17:08:00 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) X X * Makefile.in (srcs): Remove limits.h. X XThu Feb 11 03:36:00 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * diff3.c (xmalloc): No longer static. X X * sdiff.c (edit): Allocate buf dynamically. X X * dir.c (dir_sort): Handle VOID_CLOSEDIR. X XWed Feb 10 00:15:54 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * limits.h: File deleted (should never have been there). X XTue Feb 9 03:53:22 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * Makefile.in (.c.o, diff3.o, sdiff.o): Put $(CFLAGS) last. X XWed Feb 3 15:42:10 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) X X * system.h: Don't #define const; let configure do it. X XMon Feb 1 02:13:23 1993 Paul Eggert (eggert@hal.gnu.ai.mit.edu) X X * Version 2.1 released. X X * Makefile.in (dist): Survive ln failures. Create .tar.z X (gzipped tar) file as well as .tar.Z (compressed tar) file. X XFri Jan 8 22:31:41 1993 Paul Eggert (eggert@twinsun.com) X X * side.c (print_half_line): When the input position falls X outside the column, do not output a tab even if the output X position still falls within the column. X XMon Dec 21 13:54:36 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) X X * Makefile.in (.c.o): Add -I. X XFri Dec 18 14:08:20 1992 Paul Eggert (eggert@twinsun.com) X X * configure.in: Add HAVE_FCNTL_H, since system.h uses it. X XTue Nov 24 10:06:48 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) X X * Makefile.in: Note change from USG to HAVE_STRING_H. X XMon Nov 23 18:44:00 1992 Paul Eggert (eggert@twinsun.com) X X * io.c (find_and_hash_each_line): When running out of lines, X double the number of allocated lines, instead of just doubling X that number minus the prefix lines. This is more likely to X avoid the need for further memory allocation. X XWed Nov 18 20:40:28 1992 Paul Eggert (eggert@twinsun.com) X X * dir.c (dir_sort): Plug memory leak: space holding directory X contents was not being reclaimed. Get directory size from X struct file_data for initial guess at memory needed. X Detect errors when reading and closing directory. X (diff_dirs): Pass struct file_data to dir_sort. Finish plugging leak. X * diff.c (compare_files): Pass struct file_data to diff_dirs. X X * io.c (find_and_hash_each_line): Don't assume alloc_lines is X nonzero when allocating more lines. X XThu Nov 12 16:02:18 1992 Paul Eggert (eggert@twinsun.com) X X * diff.c (main): Add `-U lines' as an alias for `--unified=lines'. X X * diff3.c (usage): Add third --label option in example. X X * util.c (analyze_hunk): Fix test for ignoring blank lines. X X * configure.in, system.h: Avoid USG; use HAVE_TIME_H etc. instead. X XMon Nov 9 05:13:25 1992 Paul Eggert (eggert@twinsun.com) X X * diff3.c (main, usage): Add -A or --show-all. X -m now defaults to -A, not -E. Allow up to three -L options. X (output_diff3_edscript, output_diff3_merge): X Remove spurious differences between these two functions. X Output ||||||| for -A. Distinguish between conflicts and overlaps. X (dotlines, undotlines): New functions that output `Ns', not `N,Ns'. X (output_diff3_edscript, output_diff3_merge): Use them. X X * io.c (find_identical_ends): shift_boundaries needs an extra X identical line at the end, not at the beginning. X X * sdiff.c (edit): execvp wants char **, not const char **. X XMon Oct 19 04:39:32 1992 Paul Eggert (eggert@twinsun.com) X X * context.c (print_context_script, find_function): Context X line numbers start with - file->prefix_lines, not 0. X X * io.c (binary_file_p): Undo last change; it was a library bug. X XSun Oct 18 00:17:29 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * io.c (binary_file_p): Consider empty file as non-binary. X XMon Oct 5 05:18:46 1992 Paul Eggert (eggert@twinsun.com) X X * diff3.c (main, make_3way_diff, using_to_diff3_block): Don't X report bogus differences (for one of -mexEX3) just because the X file0-file1 diffs don't line up with the file0-file2 diffs. X (This is entirely possible since we don't use diff's -n X option.) Always compare file1 to file2, so that diff3 sees X those changes directly. Typically, file2 is now the common X file, not file0. X (output_diff3_merge): The input file is file 0, not the common file. X X (FC, FO): New macros; they replace FILE1, FILE0 for two-way diffs, X to distinguish them from three-way diffs. X X * diff3.c (using_to_diff3_block): Fold repeated code into loops. X X * diff3.c (make_3way_diff, process_diff): Have the *_end X variable point to the next field to be changed, not to the last X object allocated; this saves an if-then-else. X X * diff3.c (process_diff): Use D_NUMLINES instead of its definiens. X X * diff3.c: Make fns and vars static unless they must be external. X XWed Sep 30 09:21:59 1992 Paul Eggert (eggert@twinsun.com) X X * analyze.c (diff_2_files): OUTPUT_IFDEF is now robust. X * diff.h (ROBUST_OUTPUT_STYLE): Likewise. X (default_line_format): Remove. All refs removed. X X * ifdef.c (print_ifdef_lines): Add %L. Optimize %l\n even if user X specified it, as opposed to its being the default. X XTue Sep 29 19:01:28 1992 Paul Eggert (eggert@twinsun.com) X X * diff.c (longopts, main): --{old,new,unchanged,changed}--group-format X are new options, so that -D is no longer overloaded. Set X no_diff_means_no_output if --unchanged-{line,group}-format allows it. X * diff.h (enum line_class): New type. X (group_format, line_format): Use it to regularize option flags. X All refs changed. X X * ifdef.c (format_ifdef, print_ifdef_lines): %n is no longer a format. X XMon Sep 28 04:51:42 1992 Paul Eggert (eggert@twinsun.com) X X * diff.c (main, usage): Replace --line-prefix with the more general X --{old,new,unchanged}-line-format options. X * ifdef.c (format_ifdef, print_ifdef_lines): Likewise. X * diff.h (line_format): Renamed from line_prefix. All refs changed. X * diff.h, ifdef.c (default_line_format): New variable. X * util.c (output_1_line): New function. X (print_1_line): Use it. X X * ifdef.c: (format_ifdef, print_ifdef_lines): Add %0 format. X XSun Sep 27 05:38:13 1992 Paul Eggert (eggert@twinsun.com) X X * diff.c (main): Add -E or --line-prefix option. Add -D'=xxx' X for common lines. Change default -D< format from copy of -D> X format to to -D<%<; similarly for default -D> format. X * diff.h (common_format, line_prefix): New variables. X * ifdef.c (format_ifdef): New function. X (print_ifdef_script, print_ifdef_hunk, print_ifdef_lines): X Use it for -D'=xxx', -E. X X * context.c (find_hunk): Glue together two non-ignorable changes that X are exactly CONTEXT * 2 lines apart. This shortens output, removes X a behavioral discontinuity at CONTEXT = 0, and is more compatible X with traditional diff. X X * io.c (find_identical_ends): Slurp stdin at most once. X X * util.c (print_line_line): line_flag is const char *. X XThu Sep 24 15:18:07 1992 Paul Eggert (eggert@twinsun.com) X X * ifdef.c (print_ifdef_lines): New function, which fwrites a sequence X of lines all at once for speed. X (print_ifdef_script, print_ifdef_hunk): Use it. X XThu Sep 24 05:54:14 1992 Paul Eggert (eggert@twinsun.com) X X * diff.c (main): Support new -D options for if-then-else formats. X (specify_format): New function. X * diff.h (ifndef_format, ifdef_format, ifnelse_format): New variables. X * ifdef.c (print_ifdef_hunk): Use the new variables instead of X a hardwired format. X X * side.c (print_1sdiff_line): Represent incomplete lines on output. X (print_sdiff_script): Likewise. Don't print 'q' at end, X since that doesn't work with incomplete lines. X * sdiff.c (interact): Don't assume diff output ends with 'q' line. X * diff.h (ROBUST_OUTPUT_STYLE): OUTPUT_SDIFF is now robust. X X * sdiff.c (lf_copy, lf_snarf): Use memchr instead of index, X to avoid dumping core when files contain null characters. X (memchr): New function (if memchr is missing). X X * io.c (sip): New arg SKIP_TEST to skip test for binary file. X (read_files): Don't bother testing second file if first is binary. X XThu Sep 17 21:17:49 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * system.h [!USG && !_POSIX_VERSION]: Protect from conflicting X prototype for wait in sys/wait.h. X XWed Sep 16 12:32:18 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * Makefile.in: Include binprefix in -DDIFF_PROGRAM. X XTue Sep 15 14:27:25 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * Version 2.0. X XSat Sep 12 01:31:19 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * util.c, diff.h, system.h [!HAVE_MEMCHR]: Don't use void * X and const when declaring memchr replacement. Declare memchr X if !STDC_HEADERS && !USG. X XThu Sep 10 15:17:32 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * Makefile.in (uninstall): New target. X X * diff.c (excluded_filename): Use fnmatch, not wildmat. X (usage): Document -x, -X, --exclude, --exclude-from. X Makefile.in: Use fnmatch.c, not wildmat.c. X XSun Sep 6 23:46:25 1992 Paul Eggert (eggert@twinsun.com) X X * configure.in: Add HAVE_MEMCHR. X * diff.h, util.c: Use it instead of MEMCHR_MISSING. X XSun Sep 6 07:25:49 1992 Paul Eggert (eggert@twinsun.com) X X * diff.h: (struct line_def): Replace this 3-word struct with char *. X This uses less memory, particularly for large files with short lines. X (struct file_data): New member linbuf_base counts number of lines X in common prefix that are not recorded in linbuf; X this uses less memory if files are identical or differ only at end. X New member buffered_lines counts possibly differing lines. X New member valid_lines counts valid data. X New member alloc_lines - linbuf_base replaces old linbufsize. X linbuf[0] now always points at first differing line. X Remove unused members ltran, suffix_lines. X Add const where appropriate. X (Is_space): New macro, for consistent definition of `white space'. X (excluded_filename, memchr, sip, slurp): New declarations. X * ed.c (print_ed_hunk): Adjust to diff.h's struct changes. X * context.c (pr_context_hunk): Likewise. X * ifdef.c (print_ifdef_script): Likewise. X * side.c (print_sdiff_script, print_half_line): Likewise. X * util.c (analyze_hunk, line_cmp, print_1_line): Likewise. X X * analyze.c (shift_boundaries): Remove unneeded variable `end' and X unnecessary comparisons of `preceding' and `other_preceding' against 0. X (diff_2_files): When comparing files byte-by-byte for equality, X don't slurp them all in at once; just compare them a buffer at a time. X This can win big if they differ early on. X Move some code to compare_files to enable this change. X Use only one buffer for stdin with `diff - -'. X (discard_confusing_lines, diff_2_files): Coalesce malloc/free calls. X (build_script): Remove obsolete OUTPUT_RCS code. X X * diff.c (add_exclude, add_exclude_file, excluded_filename): New fns. X (main): Use them for the new --exclude and --exclude-from options. X (compare_files): Don't open a file unless it must be read. X Treat `diff file file' and `diff file dir' similarly. X Move some code here from diff_2_files to enable this. X Simplify file vs dir warning. X X * dir.c (dir_sort): Support new --exclude* options. X X * io.c (struct equivclass): Put hash code and line length here instead X of struct line_def, so that they can be shared. X (find_and_hash_each_line): Compute equivalence class as we go, X instead of doing it in a separate pass; this thrashes memory less. X Make buckets realloc-able, since we can't preallocate them. X Record one more line start than there are lines, so that we can compute X any line's length by subtracting its start from the next line's, X instead of storing the length explicitly. This saves memory. X Move prefix-handling code to find_identical_ends; X this wins with large prefixes. X Use Is_space, not is_space, for consistent treatment of white space. X (prepare_text_end): New function. X (find_identical_ends): Move slurping here, so it's only done when X needed. Work even if the buffers are the same (because of `diff - -'). X Compare prefixes a word at a time for speed. X (find_equiv_class): Delete; now done by find_and_hash_each_line. X (read_files): Don't slurp unless needed. X find_equiv_class's work is now folded into find_and_hash_each_line. X Don't copy stdin buffer if `diff - -'. X Check for running out of primes. X (sip, slurp): Split first part of `slurp' into another function `sip'. X `sip' sets things up and perhaps reads the first ST_BLKSIZE buffer to X see whether the file is binary; `slurp' now just finishes the job. X This lets diff_2_files compare binary files lazily. X Allocate a one-word sentinel to allow word-at-a-time prefix comparison. X Count prefix lines only if needed, only count the first file's prefix. X Don't bother to count suffix lines; it's never needed. X Set up linbuf[0] to point at first differing line. X (binary_file_p): Change test for binary files: X if it has a null byte in its first buffer, it's binary. X (primes): Add more primes. X X * util.c (line_cmp): Use bcmp for speed. X Use Is_space, not is_space, for consistent treatment of white space. X (translate_line_number): Internal line numbers now count from 0 X starting after the prefix. X (memchr): New function (if memchr is missing). X X * Makefile.in: Document HAVE_ST_BLKSIZE. Link with wildmat.o. X * system.h (STAT_BLOCKSIZE): New macro based on HAVE_ST_BLKSIZE. X * configure.in: Add AC_ST_BLKSIZE. X * wildmat.c: New file. X XFri Sep 4 01:28:51 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * sdiff.c (xmalloc): Renamed from ck_malloc. Callers changed. X XThu Sep 3 15:28:59 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * diff.h: Don't declare free, index, rindex. X XTue Aug 11 22:18:06 1992 John Gilmore (gnu at cygnus.com) X X * io.c (binary_file_p): Use heuristic to avoid declaring info X files as binary files. Allow about 1.5% non-printing X characters (in info's case, ^_). X XTue Jul 7 01:09:26 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * diff.h: Replace function_regexp and ignore_regexp with lists X of compiled regexps. X * analyze.c, context.c, util.c: Test whether the lists, not X the old variables, are empty. X * util.c (analyze_hunk), context.c (find_function): Compare X lines with the lists of regexps. X * diff.c (add_regexp): New function. X (main): Use it. X X * diff3: Add -v --version option. X * Makefile.in: Link with version.o. X X * system.h: New file. X * diff.h, cmp.c, diff3.c, sdiff.c: Use it. X X * diff.h, diff3.c: Include string.h or strings.h, as appropriate. X Declare malloc and realloc. X X * diff3.c (perror_with_exit): Include program name in message. X X * diff3.c: Lowercase error messages for GNU standards. X X * sdiff.c [USG || STDC_HEADERS]: Define bcopy in terms of memcpy. X X * sdiff.c: Use the version number from version.c. X * Makefile.in: Link with version.o. X X * cmp.c error.c xmalloc.c: New files from textutils. X * Makefile.in: Add rules for them. X X * diff.c (longopts): --unidirectional-new-file is like -P, not -N. X Rename --file-label to --label (leave old name, but undocumented). X X * sdiff.c, diff.c (usage): Condense messages and fix some errors. X X * diff3.c (main, usage): Add long-named options. X XFri Jul 3 14:31:18 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) X X * diff.h, diff3.c, sdiff.c: Change FOO_MISSING macros to HAVE_FOO. X XThu Jun 25 16:59:47 1992 David J. MacKenzie (djm@apple-gunkies.gnu.ai.mit.edu) X X * diff.c: --reversed-ed -> --forward-ed. X XWed Feb 26 12:17:32 1992 Paul Eggert (eggert@yata.uucp) X X * analyze.c, diff.c, diff.h, io.c: For -y, compare even if same file. X XFri Feb 14 22:46:38 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * io.c, diff3.c, analyze.c: Add extra parentheses. X XSun Feb 9 00:22:42 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu) X X * diff.h (unidirectional_new_file_flag): New variable. X * diff.c (main): Set that for -P. X (compare_files): Support -P, somewhat like -N. X (longopts): Support long name for -P. X XSat Jan 4 20:10:34 1992 Paul Eggert (eggert at yata.uucp) X X * Makefile.in: Distribute diff.info-* too. X X * README, sdiff.c: version number now matches version.c. X X * configure: Fix and document vfork test. X X * ifdef.c: Don't dump core if `diff -Dx f f'. X XMon Dec 23 23:36:08 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) X X * diff.h, diff3.c, sdiff.c: Change POSIX ifdefs to X HAVE_UNISTD_H and _POSIX_VERSION. X XWed Dec 18 17:00:31 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) X X * Makefile.in (srcs): Add sdiff.c. X (tapefiles): Add diff.texi and diff.info. X X * diff.h, diff3.c, sdiff.c: Use HAVE_VFORK_H instead of X VFORK_HEADER and VFORK_WORKS. X XTue Dec 17 00:02:59 1991 Paul Eggert (eggert at yata.uucp) X X * Makefile.in (all): Add diff.info, sdiff. X X * configure, diff.c, sdiff.c: X Prefix long options with `--', not `+'. X * diff.c: Regularize option names. X X * configure: Fix check for vfork. X * configure, diff.c, diff.h, diff3.c, sdiff.c: X Use Posix definitions when possible. X X * context.c: Align context with tab if -T is given. Tune. X * diff.c, diff.h, side.c: Calculate column widths so that tabs line up. X * io.c: Add distinction between white space and printing chars. X * side.c: Don't expand tabs unless -t is given. X * side.c, util.c: Tab expansion now knows about '\b', '\f', '\r', '\v'. X * util.c: -w skips all white space. Remove lint. Tune. X X * sdiff.c: Support many more diff options, e.g. `-', `sdiff file dir'. X Ignore interrupts while the subsidiary editor is in control. X Clean up temporary file and kill subsidiary diff if interrupted. X Ensure subsidiary diff doesn't ignore SIGPIPE. X Don't get confused while waiting for two subprocesses. X Don't let buffers overflow. Check for I/O errors. X Convert to GNU style. Tune. X X * sdiff.c, util.c: Don't lose errno. X Don't confuse sdiff with messages like `Binary files differ'. X * sdiff.c, side.c: Don't assume that common lines are identical. X Simplify --sdiff-merge-assist format. X XMon Sep 16 16:42:01 1991 Tom Lord (lord at churchy.gnu.ai.mit.edu) X X * Makefile.in, sdiff.c: introduced sdiff front end to diff. X X * Makefile.in, analyze.c, diff.c, diff.h, io.c, side.c: Added X sdiff-style output format to diff. X XMon Aug 26 16:44:55 1991 David J. MacKenzie (djm at pogo.gnu.ai.mit.edu) X X * Makefile.in, configure: Only put $< in Makefile if using VPATH, X because older makes don't understand it. X XFri Aug 2 12:22:30 1991 David J. MacKenzie (djm at apple-gunkies) X X * configure: Create config.status. Remove it and Makefile if X interrupted while creating them. X XThu Aug 1 22:24:31 1991 David J. MacKenzie (djm at apple-gunkies) X X * configure: Check for +srcdir etc. arg and look for X Makefile.in in that directory. Set VPATH if srcdir is not `.'. X * Makefile.in: Get rid of $(archpfx). X XTue Jul 30 21:28:44 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) X X * Makefile.in (prefix): Renamed from DESTDIR. X XWed Jul 24 23:08:56 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) X X * diff.h, diff3.c: Rearrange ifdefs to use POSIX, X STDC_HEADERS, VFORK_MISSING, DIRENT. This way it works on X more systems that aren't pure USG or BSD. X Don't not define const if __GNUC__ is defined -- that would X break with -traditional. X * configure: Check for those features. X XWed Jul 10 01:39:23 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) X X * configure, Makefile.in: $(INSTALLPROG) -> $(INSTALL). X XSat Jul 6 16:39:04 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) X X * Replace Makefile with configure and Makefile.in. X Update README with current compilation instructions. X XSat Jul 6 14:03:29 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) X X * util.c (setup_output): Just save the args for later use. X (begin_output): Do the real work, with the values that were saved. X It's safe to call begin_output more than once. X Print the special headers for context format here. X * analyze.c (diff_2_files): Don't print special headers here. X * context.c (pr_context_hunk, pr_unidiff_hunk): Call begin_output. X * ed.c (print_ed_hunk, print_forward_ed_hunk, print_rcs_hunk): X * normal.c (print_normal_hunk): Likewise. X * ifdef.c (print_ifdef_hunk): Likewise. X * util.c (finish_output): Don't die if begin_output was not called. X XThu Jun 20 23:10:01 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) X X * Makefile: Add TAGS, distclean, and realclean targets. X Set SHELL. X XTue Apr 30 13:54:36 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) X X * diff.h (TRUE, FALSE): Undefine these before defining. X XThu Mar 14 18:27:27 1991 Richard Stallman (rms@mole.ai.mit.edu) X X * Makefile (objs): Include $(ALLOCA). X XSat Mar 9 22:34:03 1991 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.h: Include regex.h. X XThu Feb 28 18:59:53 1991 Richard Stallman (rms at mole.ai.mit.edu) X X * Makefile (diff3): Link with GNU getopt. X XSat Feb 23 12:49:43 1991 Richard Stallman (rms at mole.ai.mit.edu) X X * io.c (find_equiv_class): Make hash code unsigned before mod. X X * diff.h (files): Add EXTERN. X XSun Jan 13 21:33:01 1991 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c: +print option renamed +paginate. Remove +all-text. X XMon Jan 7 06:18:01 1991 David J. MacKenzie (djm at geech.ai.mit.edu) X X * Makefile (dist): New target, replacing diff.tar and X diff.tar.Z, to encode version number in distribution directory X and tar file names. X XSun Jan 6 18:42:23 1991 Michael I Bushnell (mib at geech.ai.mit.edu) X X * Version 1.15 released. X X * version.c: Updated from 1.15 alpha to 1.15 X X * context.c (print_context_number_range, X print_unidiff_number_range): Don't print N,M when N=M, print X just N instead. X X * README: Updated for version 1.15. X Makefile: Updated for version 1.15. X X * diff3.c (main): Don't get confused if one of the arguments X is a directory. X X * diff.c (compare_files): Don't get confused if comparing X standard input to a directory; print error instead. X X * analyze.c (diff_2_files), context.c (print_context_header, X print_context_script), diff.c (main), diff.h (enum X output_style): Tread unidiff as an output style in its own X right. This also generates an error when both -u and -c are X given. X X * diff.c (main): Better error messages when regexps are bad. X X * diff.c (compare_files): Don't assume stdin is opened. X X * diff3.c (read_diff): Don't assume things about the order of X descriptor assignment and closes. X X * util.c (setup_output): Don't assume things about the order X of descriptor assignment and closes. X X * diff.c (compare_files): Set a flag so that closes don't X happen more than once. X X * diff.c (main): Don't just flush stdout, do a close. That X way on broken systems we can still get errors. X XMon Dec 24 16:24:17 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c (usage): Use = for args of long options. X XMon Dec 17 18:19:20 1990 Michael I Bushnell (mib at geech.ai.mit.edu) X X * context.c (print_context_label): Labels were interchanged badly. X X * context.c (pr_unidiff_hunk): Changes to deal with files X ending in incomplete lines. X * util.c (print_1_line): Other half of the changes. X XMon Dec 3 14:23:55 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c (longopts, usage): unidiff => unified. X XWed Nov 7 17:13:08 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * analyze.c (diff_2_files): No warnings about newlines for -D. X X * diff.c (pr_unidiff_hunk): Remove ref to output_patch_flag. X XTue Oct 23 23:19:18 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c (compare_files): For -D, compare even args are same file. X * analyze.c (diff_2_files): Likewise. X Also, output even if files have no differences. X X * analyze.c (diff_2_files): Print missing newline messages last. X Return 2 if a newline is missing. X Print them even if files end with identical text. X XMon Oct 22 19:40:09 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c (usage): Return 2. X XWed Oct 10 20:54:04 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.c (longopts): Add +new-files. X XSun Sep 23 22:49:29 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * context.c (print_context_script): Handle unidiff_flag. X (print_context_header): Likewise. X (print_unidiff_number_range, pr_unidiff_hunk): New functions. X * diff.c (longopts): Add element for +unidiff. X (main): Handle +unidiff and -u. X (usage): Mention them. X XWed Sep 5 16:33:22 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * io.c (find_and_hash_each_line): Deal with missing final newline X after buffering necessary context lines. X XSat Sep 1 16:32:32 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * io.c (find_identical_ends): ROBUST_OUTPUT_FORMAT test was backward. X XThu Aug 23 17:17:20 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff3.c (WIFEXITED): Undef it if WEXITSTATUS is not defined. X * context.c (find_function): Don't try to return values. X XWed Aug 22 11:54:39 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * diff.h (O_RDONLY): Define if not defined. X XTue Aug 21 13:49:26 1990 Richard Stallman (rms at mole.ai.mit.edu) X X * Handle -L option. X * context.c (print_context_label): New function. X (print_context_header): Use that. X * diff.c (main): Recognize the option. X (usage): Updated. X * diff.h (file_label): New variable. X * diff3.c (main): Recognize -L instead of -t. X X * diff3.c (main): Support -m without other option. X X * diff3.c (WEXITSTATUS, WIFEXITED): Define whenever not defined. X X * diff3.c (bcopy, index, rindex): Delete definitions; not used. X (D_LINENUM, D_LINELEN): Likewise. X (struct diff_block): lengths includes newlines. X (struct diff3_block): Likewise. X (always_text, merge): New variables. X (read_diff): Return address of end, not size read. Calls changed. X Pass -a to diff if given to diff3. X current_chunk_size now an int. Detect error in `pipe'. X Check for incomplete line of output here. X (scan_diff_line): Don't make scan_ptr + 2 before knowing it is valid. X No need to check validity of diff output here. X Include newline in length of line. X (main): Compute rev_mapping here. Handle -a and -m. X Error message if excess -t operands. Error for incompatible options. X Error if `-' given more than once. X Fix error storing in tag_strings. X (output_diff3): REV_MAPPING is now an arg. Call changed. X Change syntax of "missing newline" message. X Expect length of line to include newline. X (output_diff3_edscript): Return just 0 or 1. X REV_MAPPING is now an arg. Call changed. X (output_diff3_merge): New function. X (process_diff): Better error message for bad diff format. X (fatal, perror_with_exit): Return status 2. X X * analyze.c (diff_2_files): Report missing newline in either X or both files, if not robust output style. X X * util.c (setup_output): Detect error from pipe. X No need to close stdin. X X * util.c (print_1_line): Change format of missing-newline msg. X Change if statements to switch. X X * io.c (slurp): Don't mention differences in final newline if -B. X X * io.c (binary_file_p): Use ISO char set as criterion, not ASCII. X X * io.c (find_identical_ends): Increase value of BEG0 by 1. X Other changes in backwards scan to avoid decrementing pointers X before start of array, and set LINES properly. X X * diff.h (ROBUST_OUTPUT_STYLE): New macro. X * io.c (find_identical_ends, find_and_hash_each_line): Use that macro. X X * diff.h (dup2): Don't define if XENIX. X X * diff.c (main): Check for write error at end. X X * context.c (find_function): Don't return a value. X Use argument FILE rather than global files. X X * analyze.c: Add external function declarations. X * analyze.c (build_script): Turn off explicit check for final newline. X X * analyze.c (discard_confusing_lines): Make integers unsigned. X XTue Jul 31 21:37:16 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (find_and_hash_each_line): Correct the criterion X for leaving out the newline from the end of the line. X XTue May 29 21:28:16 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * dir.c (diff_dirs): Free things only if nonzero. X XMon Apr 16 18:31:05 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.h (NDIR_IN_SYS): New macro controls location of ndir.h. X X * diff3.c (xmalloc, xrealloc): Don't die if size == 0 returns 0. X XSun Mar 25 15:58:42 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * analyze.c (discard_confusing_lines): X `many' wasn't being used; use it. X Canceling provisionals near start of run must handle already X canceled provisionals. X Canceling subruns of provisionals was canceling last nonprovisional. X XSat Mar 24 14:02:51 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * analyze.c (discard_confusing_lines): X Threshold for line occurring many times scales by square root X of total lines. X Within each run, cancel any long subrun of provisionals. X Don't update `provisional' while canceling provisionals. X In big outer loop, handle provisional and nonprovisional separately. X XThu Mar 22 16:35:33 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * analyze.c (discard_confusing_lines): X The first loops to discard provisionals from ends failed to step. X In second such loops, keep discarding all consecutive provisionals. X Increase threshold for stopping discarding, and also check for X consecutive nondiscardables as separate threshold. X XFri Mar 16 00:33:08 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (read_diff): Pass -- as first arg to diff. X X * diff3.c: Include wait.h or define equivalent macros. X (read_diff): Don't use stdio printing error in the inferior. X Remember the pid and wait for it. Report failing status. X Report failure of vfork. X XSun Mar 11 17:10:32 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (main): Accept -t options and pass to output_diff3_edscript. X (usage): Mention -t. X (read_diff): Use vfork. X (vfork): Don't use it on Sparc. X X * diff.h (vfork): Don't use it on Sparc. X XTue Mar 6 22:37:20 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (dup2): Don't define on Xenix. X X * Makefile: Comments for Xenix. X XThu Mar 1 17:19:23 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * analyze.c (diff_2_files): `message' requires three args. X XFri Feb 23 10:56:50 1990 David J. MacKenzie (djm at albert.ai.mit.edu) X X * diff.h, util.c, diff3.c: Change 'void *' to 'VOID *', with X VOID defined as void if __STDC__, char if not. X XSun Feb 18 20:31:58 1990 David J. MacKenzie (djm at albert.ai.mit.edu) X X * Makefile: Add rules for getopt.c, getopt1.c, getopt.h. X X * getopt.c, getopt.h, getopt1.c: New files. X X * main.c (main, usage): Add long options. X X * analyze.c (shift_boundaries): Remove unused var 'j_end'. X XThu Feb 8 02:43:16 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) X X * GNUmakefile: include ../Makerules before Makefile. X XFri Feb 2 23:21:38 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * analyze.c (diff_2_files): If -B or -I, don't return 1 X if all changes were ignored. X XWed Jan 24 20:43:57 1990 Richard Stallman (rms at albert.ai.mit.edu) X X * diff3.c (fatal): Output to stderr. X XThu Jan 11 00:25:56 1990 David J. MacKenzie (djm at hobbes.ai.mit.edu) X X * diff.c (usage): Mention -v. X XWed Jan 10 16:06:38 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (output_diff3_edscript): Return number of overlaps. X (main): If have overlaps, exit with status 1. X XSun Dec 24 10:29:20 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (find_equiv_class): Fix typo that came from changing init of B X to an assignment. X X * version.c: New file. X * diff.c (main): -v prints version number. X X * io.c (binary_file_p): Null char implies binary file. X XFri Nov 17 23:44:55 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * util.c (print_1_line): Fix off by 1 error. X XThu Nov 16 13:51:10 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * util.c (xcalloc): Function deleted. X X * io.c (slurp): Null-terminate the buffer. X X * io.c (read_files): Delete unused vars. X X * io.c (find_equiv_class): Don't index by N if too low. X X * dir.c (dir_sort): Delete the extra declaration of compare_names. X X * diff.h: Don't declare xcalloc. Declare some other functions. X X * analyze.c (shift_boundaries): X Test for END at end of range before indexing by it. X Fix misspelling of `preceding' in var names. X XSat Nov 11 14:04:16 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (using_to_diff3_block): Delete unused vars. X (make_3way_diff, process_diff_control, read_diff, output_diff3): Likewise. X XMon Nov 6 18:15:50 EST 1989 Jay Fenlason (hack@ai.mit.edu) X X * README Fix typo. X XFri Nov 3 15:27:47 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (usage): Mention -D. X X * ifdef.c (print_ifdef_hunk): Write comments on #else and #endif. X XSun Oct 29 16:41:07 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (compare_files): Don't fflush for identical files. X XWed Oct 25 17:57:12 1989 Randy Smith (randy at apple-gunkies.ai.mit.edu) X X * diff3.c (using_to_diff3_block): When defaulting lines from X FILE0, only copy up to just under the *lowest* line mentioned X in the next diff. X X * diff3.c (fatal): Add \n to error messages. X XWed Oct 25 15:05:49 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * Makefile (tapefiles): Add ChangeLog. X XTue Oct 3 00:51:17 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c (process_diff, create_diff3_block): Init ->next field. X XFri Sep 29 08:16:45 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * util.c (line_cmp): Alter end char of line 2, not line 1. X XWed Sep 20 00:12:37 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * Makefile (diff.tar): Expect ln to fail on some files; X copy them with cp. X XMon Sep 18 02:54:29 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * Handle -D option: X * io.c (find_and_hash_each_line): Keep all lines of 1st file. X * diff.c (main): Handle -D option. X (compare_files): Reject -D if files spec'd are directories. X * analyze.c (diff_2_files): Handle OUTPUT_IFDEF case. X XFri Sep 1 20:15:50 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (option_list): Rename arg VECTOR as OPTIONVEC. X XMon Aug 28 17:58:27 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (compare_files): Clear entire inf[i].stat. X XWed Aug 23 17:48:47 1989 Richard Stallman (rms at apple-gunkies.ai.mit.edu) X X * io.c (find_identical_ends): Sign was backward X determining where to bound the scan for the suffix. X XWed Aug 16 12:49:16 1989 Richard Stallman (rms at hobbes.ai.mit.edu) X X * analyze.c (diff_2_files): If -q, treat all files as binary. X * diff.c (main): Detect -q, record in no_details_flag. X XSun Jul 30 23:12:00 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (usage): New function. X (main): Call it. X XWed Jul 26 02:02:19 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (main): Make -C imply -c. X XThu Jul 20 17:57:51 1989 Chris Hanson (cph at kleph) X X * io.c (find_and_hash_each_line): Bug fix in context handling, X introduced by last change. X XFri Jul 14 17:39:20 1989 Chris Hanson (cph at kleph) X X * analyze.c: To make RCS work correctly on files that don't X necessarily end in newline, introduce some changes that cause X diffs to be sensitive to missing final newline. Because X non-RCS modes don't want to be affected by these changes, they X are conditional on `output_style == OUTPUT_RCS'. X (diff_2_files) [OUTPUT_RCS]: Suppress the "File X missing X newline" message. X (build_script) [OUTPUT_RCS]: Cause the last line to compare as X different if exactly one of the files is missing its final X newline. X X * io.c (find_and_hash_each_line): Bug fix in X ignore_space_change mode. Change line's length to include the X newline. For OUTPUT_RCS, decrement last line's length if X there is no final newline. X (find_identical_ends) [OUTPUT_RCS]: If one of the files is X missing a final newline, make sure it's not included in either X the prefix or suffix. X X * util.c (print_1_line): Change line output routine to account X for line length including the newline. X XTue Jun 27 02:35:28 1989 Roland McGrath (roland at hobbes.ai.mit.edu) X X * Makefile: Inserted $(archpfx) where appropriate. X XWed May 17 20:18:43 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff3.c [USG]: Include fcntl.h. X X * diff.h [USG]: New compilation flags HAVE_NDIR, HAVE_DIRECT. X XWed Apr 26 15:35:57 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * dir.c (diff_dirs): Two new args, NONEX1 and NONEX2, say to pretend X nonex dirs are empty. X (dir_sort): New arg NONEX, likewise. X * diff.c (compare_files): Pass those args. X Sometimes call diff_dirs if subdir exists in just one place. X XWed Apr 12 01:10:27 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (find_identical_ends): Set END0 *after* last char X during backward scan for suffix. X XSat Apr 8 15:49:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) X X * diff3.c (using_to_diff3_block): Now find high marks in files 1 X and 2 through mapping off of the last difference instead of the X first. X X * diff3.c: Many trivial changes to spelling inside comments. X XFri Feb 24 12:38:03 1989 Randall Smith (randy at gluteus.ai.mit.edu) X X * util.c, normal.c, io.c, ed.c, dir.c, diff.h, diff.c, context.c, X analyze.c, Makefile: Changed copyright header to conform with new X GNU General Public license. X * diff3.c: Changed copyright header to conform with new GNU X General Public license. X * COPYING: Made a hard link to /gp/rms/COPYING. X XFri Feb 24 10:01:58 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (slurp): Leave 2 chars space at end of buffer, not one. X (find_identical_ends): Special case if either file is empty; X don't try to make a sentinel since could crash. X XWed Feb 15 14:24:48 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) X X * diff3.c (message) Re-wrote routine to avoid using alloca() X XWed Feb 15 06:19:14 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (find_identical_ends): Delete the variable `bytes'. X XSun Feb 12 11:50:36 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * io.c (slurp): ->bufsize is nominal amount we have room for; X add room for sentinel when calling xmalloc or xrealloc. X X * io.c (find_identical_ends): Do need overrun check in finding suffix. X XFri Feb 10 01:28:15 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.c (main): -C now takes arg to specify context length. X Now -p to show C function name--Damned IEEE! X Fatal error if context length spec'd twice. X X * ed.c (print_ed_hunk): Now special treatment only for lines containing X precisely a dot and nothing else. Output `..', end the insert, X substitute that one line, then resume the insert if nec. X X * io.c (find_and_hash_lines): When backing up over starting context, X don't move past buffer-beg. X X * io.c (find_identical_ends): Use sentinels to make the loops faster. X If files are identical, skip the 2nd loop and return quickly. X (slurp): Leave 1 char extra space after each buffer. X X * analyze.c (diff_2_files): Mention difference in final newlines. X XWed Jan 25 22:44:44 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * dir.c (diff_dirs): Use * when calling fcn ptr variable. X XSat Dec 17 14:12:06 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * Makefile: New vars INSTALL and LIBS used in some rules; X provide default defns plus commented-put defns for sysV. X XThu Nov 17 16:42:53 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * dir.c (dir_sort): Open-trouble not fatal; just say # files is -1. X (diff_dirs): If dir_sort does that, give up and return 2. X X * diff.c (compare_files): Don't open directories. X Don't close them specially either. X Cross-propagate inf[i].dir_p sooner. X XSun Nov 13 11:19:36 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) X X * diff.h: Declare index, rindex. X X * diff.c (compare_files): If comparing foodir with b/f, X use foodir/f, not foodir/b/f. X X * diff.c (compare_files): Don't print "are identical" msg for 2 dirs. X Status now 1 if one file is a dir and the other isn't, etc. X XThu Nov 3 16:30:24 1988 Randall Smith (randy at gluteus.ai.mit.edu) X X * Makefile: Added a define for diff3 to define DIFF_PROGRAM. X X * util.c: Added hack to make sure that perror was not called with X a null pointer. X X * diff.c: Changed S_IFDIR to S_IFMT in masking type of file bits X out. X X * diff3.c: Included USG compatibility defines. X X * diff.h: Moved sys/file.h into #else USG section (not needed or X wanted on System V). X X * ed.c, analyze.c, context.c: Shortened names to 12 characters for X the sake of System V (too simple not to do). X X XCopyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997, 1998, 1999, X2000, 2001, 2002 Free Software Foundation, Inc. X XThis file is part of GNU Diffutils. X XThis program is free software; you can redistribute it and/or modify Xit under the terms of the GNU General Public License as published by Xthe Free Software Foundation; either version 2, or (at your option) Xany later version. X XThis program is distributed in the hope that they will be useful, Xbut WITHOUT ANY WARRANTY; without even the implied warranty of XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the XGNU General Public License for more details. X XYou should have received a copy of the GNU General Public License Xalong with this program; see the file COPYING. If not, write to Xthe Free Software Foundation, Inc., 59 Temple Place - Suite 330, XBoston, MA 02111-1307, USA. END-of-contrib/diff/ChangeLog echo x - contrib/diff/Makefile.am sed 's/^X//' >contrib/diff/Makefile.am << 'END-of-contrib/diff/Makefile.am' X# Main Automakefile for GNU diffutils. X X# Copyright (C) 2001, 2002 Free Software Foundation, Inc. X X## This program is free software; you can redistribute it and/or modify X## it under the terms of the GNU General Public License as published by X## the Free Software Foundation; either version 2, or (at your option) X## any later version. X X## This program is distributed in the hope that it will be useful, X## but WITHOUT ANY WARRANTY; without even the implied warranty of X## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X## GNU General Public License for more details. X X## You should have received a copy of the GNU General Public License X## along with this program; if not, write to the Free Software X## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA X## 02111-1307, USA. X XEXTRA_DIST = config/config.rpath exgettext INSTALLME XSUBDIRS = doc lib m4 ms src man po X XACLOCAL_AMFLAGS = -I m4 END-of-contrib/diff/Makefile.am echo x - contrib/diff/NEWS sed 's/^X//' >contrib/diff/NEWS << 'END-of-contrib/diff/NEWS' XUser-visible changes in version 2.8.1: X X* Documentation fixes. X XUser-visible changes in version 2.8: X X* cmp and diff now conform to POSIX 1003.1-2001 (IEEE Std 1003.1-2001) X if the underlying system conforms to POSIX and if the _POSIX2_VERSION X environment variable is set to 200112. Conformance removes support X for `diff -NUM', where NUM is a number. Use -C NUM or -U NUM instead. X* cmp now supports trailing operands SKIP1 and SKIP2, like BSD cmp. X* cmp -i or --ignore-initial now accepts SKIP1:SKIP2 option value. X* New cmp option: -n or --bytes. X* cmp's old -c or --print-chars option has been renamed; X use -b or --print-bytes instead. X* cmp now outputs "byte" rather than "char" outside the POSIX locale. X* cmp -l's index column width now adjusts to fit larger (or smaller) files. X* cmp -l -s and cmp -s -l are not allowed. Use cmp -s or cmp -l instead. X* diff uses ISO 8601 style time stamps for output times (e.g. "2001-11-23 X 16:44:36.875702460 -0800") unless in the C or POSIX locale and the X -c style is specified. X* diff's -I and -F options use the regexp syntax of grep, not of Emacs. X* diff now accepts multiple context arguments, and uses their maximum value. X* New diff and sdiff options: X -E --ignore-tab-expansion X --strip-trailing-cr X* New diff options: X --from-file=FILE, --to-file=FILE X --ignore-file-name-case X --no-ignore-file-name-case X* New diff3 and sdiff option: X --diff-program=PROGRAM X* The following diff options are still accepted, but are no longer documented. X They may be withdrawn in future releases. X -h (omit; it has no effect) X -H (use --speed-large-files instead) X -L (use --label instead) X -P (use --unidirectional-new-file instead) X --inhibit-hunk-merge (omit; it has no effect) X* Recursive diffs now sort file names according to the LC_COLLATE locale X category if possible, instead of using native byte comparison. X* Diff printf specs can now use the "0" and "'" flags. X* The new sdiff interactive command `ed' precedes each version with a header. X* On 64-bit hosts, files larger than 2 GB can be compared. X* Some internationalization support has been added, but multibyte locales X are still not completely supported yet. X* Some diagnostics have been reworded slightly for consistency. X Also, `diff -D FOO' now outputs `/* ! FOO */' instead of `/* not FOO */'. X* The `patch' part of the manual now describes `patch' version 2.5.4. X* Man pages are now distributed and installed. X* There is support for DJGPP; see the 'ms' subdirectory and the files X m4/dos.m4 and */setmode.*. X X XUser-visible changes in version 2.7: X X* New diff option: --binary (useful only on non-POSIX hosts) X* diff -b and -w now ignore line incompleteness; -B no longer does this. X* cmp -c now uses locale to decide which output characters to quote. X* Help and version messages are reorganized. X X XUser-visible changes in version 2.6: X X* New cmp, diff, diff3, sdiff option: --help X* A new heuristic for diff greatly reduces the time needed to compare X large input files that contain many differences. X* Partly as a result, GNU diff's output is not exactly the same as before. X Usually it is a bit smaller, but sometimes it is a bit larger. X X XUser-visible changes in version 2.5: X X* New cmp option: -v --version X X XUser-visible changes in version 2.4: X X* New cmp option: --ignore-initial=BYTES X* New diff3 option: -T --initial-tab X* New diff option: --line-format=FORMAT X* New diff group format specifications: X [eflmnEFLMN] X A printf spec followed by one of the following letters X causes the integer corresponding to that letter to be X printed according to the printf specification. X E.g. `%5df' prints the number of the first line in the X group in the old file using the "%5d" format. X e: line number just before the group in old file; equals f - 1 X f: first line number in group in the old file X l: last line number in group in the old file X m: line number just after the group in old file; equals l + 1 X n: number of lines in group in the old file; equals l - f + 1 X E, F, L, M, N: likewise, for lines in the new file X %(A=B?T:E) X If A equals B then T else E. A and B are each either a decimal X constant or a single letter interpreted as above. T and E are X arbitrary format strings. This format spec is equivalent to T if X A's value equals B's; otherwise it is equivalent to E. For X example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no lines' X if N (the number of lines in the group in the the new file) is 0, X to `1 line' if N is 1, and to `%dN lines' otherwise. X %c'C' X where C is a single character, stands for the character C. C may not X be a backslash or an apostrophe. E.g. %c':' stands for a colon. X %c'\O' X where O is a string of 1, 2, or 3 octal digits, stands for the X character with octal code O. E.g. %c'\0' stands for a null character. X* New diff line format specifications: X n X The line number, printed with . X E.g. `%5dn' prints the line number with a "%5d" format. X %c'C' X %c'\O' X The character C, or with octal code O, as above. X* Supported s have the same meaning as with printf, but must X match the extended regular expression %-*[0-9]*(\.[0-9]*)?[doxX]. X* The format spec %0 introduced in version 2.1 has been removed, since it X is incompatible with printf specs like %02d. To represent a null char, X use %c'\0' instead. X* cmp and diff now conform to POSIX 1003.2-1992 (ISO/IEC 9945-2:1993) X if the underlying system conforms to POSIX: X - Some messages' wordings are changed in minor ways. X - ``White space'' is now whatever C's `isspace' says it is. X - When comparing directories, if `diff' finds a file that is not a regular X file or a directory, it reports the file's type instead of diffing it. X (As usual, it follows symbolic links first.) X - When signaled, sdiff exits with the signal's status, not with status 2. X* Now portable to hosts where int, long, pointer, etc. are not all the same X size. X* `cmp - -' now works like `diff - -'. X X XUser-visible changes in version 2.3: X X* New diff option: --horizon-lines=lines X X XUser-visible changes in version 2.1: X X* New diff options: X --{old,new,unchanged}-line-format='format' X --{old,new,unchanged,changed}-group-format='format' X -U X* New diff3 option: X -A --show-all X* diff3 -m now defaults to -A, not -E. X* diff3 now takes up to three -L or --label options, not just two. X If just two options are given, they refer to the first two input files, X not the first and third input files. X* sdiff and diff -y handle incomplete lines. X X XUser-visible changes in version 2.0: X X* Add sdiff and cmp programs. X* Add Texinfo documentation. X* Add configure script. X* Improve diff performance. X* New diff options: X-x --exclude X-X --exclude-from X-P --unidirectional-new-file X-W --width X-y --side-by-side X--left-column X--sdiff-merge-assist X--suppress-common-lines X* diff options renamed: X--label renamed from --file-label X--forward-ed renamed from --reversed-ed X--paginate renamed from --print X--entire-new-file renamed from --entire-new-files X--new-file renamed from --new-files X--all-text removed X* New diff3 options: X-v --version X* Add long-named equivalents for other diff3 options. X* diff options -F (--show-function-line) and -I (--ignore-matching-lines) X can now be given more than once. X X X XCopyright (C) 1993, 1994, 1998, 2001, 2002 Free Software Foundation, XInc. X XThis file is part of GNU Diffutils. X XThis program is free software; you can redistribute it and/or modify Xit under the terms of the GNU General Public License as published by Xthe Free Software Foundation; either version 2, or (at your option) Xany later version. X XThis program is distributed in the hope that they will be useful, Xbut WITHOUT ANY WARRANTY; without even the implied warranty of XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the XGNU General Public License for more details. X XYou should have received a copy of the GNU General Public License Xalong with this program; see the file COPYING. If not, write to Xthe Free Software Foundation, Inc., 59 Temple Place - Suite 330, XBoston, MA 02111-1307, USA. END-of-contrib/diff/NEWS echo x - contrib/diff/THANKS sed 's/^X//' >contrib/diff/THANKS << 'END-of-contrib/diff/THANKS' XThanks to all the following for their contributions to GNU diffutils: X XThomas Bushnell XWayne Davison XUlrich Drepper XPaul Eggert XJay Fenlason XJohn Gilmore XTorbjorn Granlund XMike Haertel XBruno Haible XChris Hanson XJim Kingdon XTom Lord XDavid J. MacKenzie XRoland McGrath XJim Meyering XEugene W. Myers XRandy Smith XRichard Stallman XLeonard H. Tower Jr. XEli Zaretskii END-of-contrib/diff/THANKS echo x - contrib/diff/exgettext sed 's/^X//' >contrib/diff/exgettext << 'END-of-contrib/diff/exgettext' X#! /bin/sh X# Wrapper around gettext for programs using the msgid convention. X X# Copyright (C) 1998, 2001 Free Software Foundation, Inc. X X# Written by Paul Eggert . X X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 2, or (at your option) X# any later version. X X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X X# You should have received a copy of the GNU General Public License X# along with GNU CC; see the file COPYING. If not, write to X# the Free Software Foundation, 59 Temple Place - Suite 330, X# Boston, MA 02111-1307, USA. X X# Always operate in the C locale. XLANG=C XLANGUAGE=C XLC_ALL=C Xexport LANG LANGUAGE LC_ALL X X# Set AWK if environment has not already set it. XAWK=${AWK-awk} X X# The argument to this wrapper is the xgettext command to be executed. X# Extract the xgettext program name from the rest of the command. Xxgettext=${1?} Xshift X X# Save work if we're just wrapping a no-op. Xcase $xgettext in X:) exit;; Xesac X X# Find the files to be scanned, and the directory to scan them from. Xdirectory=. Xfiles= Xfor i Xdo X case $i in X --directory=*) X directory=`expr " $i" : ' --directory=\(.*\)'`;; X --files-from=*) X files_from=`expr " $i" : ' --files-from=\(.*\)'` X files=`$AWK '/^[^#]/ { print }' $files_from`;; X esac Xdone X X# Generate keyword options for xgettext, X# by scanning for declarations of functions X# whose parameter names end in "msgid". Xgenerate_keyword_options=' X /^[A-Z_a-z].*\(.*msgid[,)]/ { X X paren_index = index($0, "(") X X name = substr($0, 1, paren_index - 1) X sub(/[^0-9A-Z_a-z]*$/, "", name) X sub(/[ ]+PARAMS/, "", name) X sub(/[ ]+VPARAMS/, "", name) X sub(/.*[^0-9A-Z_a-z]/, "", name) X X args = substr($0, paren_index) X sub(/msgid[,)].*/, "", args) X for (n = 1; sub(/^[^,]*,/, "", args); n++) { X continue; X } X X if (n == 1) { X keyword = name X } else { X keyword = name ":" n X } X X if (! keyword_seen[keyword]++) { X print "--keyword=" keyword X } X } X' Xkeyword_options=`( X cd $directory && X $AWK "$generate_keyword_options" $files < /dev/null X)` || exit X X# Generate temporary file reflecting the %e strings in the scanned files. Xtmp=tmp-emsgids.c X Xgenerate_emsgids=' X /%e.*}/ { X line = $0 X while ((percent_index = index(line, "%e")) != 0) { X line = substr(line, percent_index + 2) X bracket_index = index(line, "}") X if (bracket_index == 0) { X continue X } X msgid = substr(line, 1, bracket_index - 1) X if (index(msgid, "%") != 0) { X continue X } X printf "#line %d \"%s\"\n", FNR, FILENAME X printf "_(\"%s\")\n", msgid X line = substr(line, bracket_index + 1) X } X } X' X(cd $directory && X $AWK "$generate_emsgids" $files < /dev/null X) > $directory/$tmp || exit X X# Run the xgettext command, with temporary added as a file to scan. X"$xgettext" $keyword_options ${1+"$@"} $tmp || exit X X# Clean up. X# If we don't get here, `make clean' will remove this file later. Xrm -f $directory/$tmp END-of-contrib/diff/exgettext echo x - contrib/diff/INSTALLME sed 's/^X//' >contrib/diff/INSTALLME << 'END-of-contrib/diff/INSTALLME' XInstallation instructions specific to GNU Diffutils X X Copyright (C) 2001, 2002 Free Software Foundation, Inc. X X This file is part of GNU Diffutils. X X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 2, or (at your option) X any later version. X X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with this program; see the file COPYING. If not, write to X the Free Software Foundation, Inc., 59 Temple Place - Suite 330, X Boston, MA 02111-1307, USA. X X XPlease send comments and problem reports to . X XIf you have a problem with internationalization, you might be able to Xwork around it as described in ABOUT-NLS by invoking `./configure X--disable-nls'. Many of the problems arise from dynamic linking Xissues on non-GNU platforms (e.g. with the iconv library). Such Xproblems tend to be shared by other GNU applications on these Xplatforms, and can usually be fixed by carefully tweaking your non-GNU Xinstallation. If you have an older version of libiconv, please Xupgrade to the latest one, preferably libiconv-1.8 or newer. X(libiconv-1.8 is not yet available as of this writing, but it should Xbe out soon.) If the problem seems isolated to diffutils, though, Xplease report a bug. X XThis program requires a Standard C compiler (C89 or later); if you Xhave an older K&R compiler, please install GCC first. X XIf you make changes to the source code, you may need recent test Xversions of GNU build tools to regenerate the intermediate files. The Xfollowing versions were used to generate the intermediate files in Xthis distribution: X X* GNU Autoconf 2.53 X X* GNU Automake 1.6 X X* GNU gettext 0.11.1 X X* GNU help2man 1.27 X X* GNU texinfo 4.2 END-of-contrib/diff/INSTALLME echo c - contrib/diff/doc mkdir -p contrib/diff/doc > /dev/null 2>&1 echo x - contrib/diff/doc/fdl.texi sed 's/^X//' >contrib/diff/doc/fdl.texi << 'END-of-contrib/diff/doc/fdl.texi' X X@node GNU Free Documentation License X@appendixsec GNU Free Documentation License X X@cindex FDL, GNU Free Documentation License X@center Version 1.1, March 2000 X X@display XCopyright @copyright{} 2000 Free Software Foundation, Inc. X59 Temple Place, Suite 330, Boston, MA 02111-1307, USA X XEveryone is permitted to copy and distribute verbatim copies Xof this license document, but changing it is not allowed. X@end display X X@enumerate 0 X@item XPREAMBLE X XThe purpose of this License is to make a manual, textbook, or other Xwritten document @dfn{free} in the sense of freedom: to assure everyone Xthe effective freedom to copy and redistribute it, with or without Xmodifying it, either commercially or noncommercially. Secondarily, Xthis License preserves for the author and publisher a way to get Xcredit for their work, while not being considered responsible for Xmodifications made by others. X XThis License is a kind of ``copyleft'', which means that derivative Xworks of the document must themselves be free in the same sense. It Xcomplements the GNU General Public License, which is a copyleft Xlicense designed for free software. X XWe have designed this License in order to use it for manuals for free Xsoftware, because free software needs free documentation: a free Xprogram should come with manuals providing the same freedoms that the Xsoftware does. But this License is not limited to software manuals; Xit can be used for any textual work, regardless of subject matter or Xwhether it is published as a printed book. We recommend this License Xprincipally for works whose purpose is instruction or reference. X X@item XAPPLICABILITY AND DEFINITIONS X XThis License applies to any manual or other work that contains a Xnotice placed by the copyright holder saying it can be distributed Xunder the terms of this License. The ``Document'', below, refers to any Xsuch manual or work. Any member of the public is a licensee, and is Xaddressed as ``you''. X XA ``Modified Version'' of the Document means any work containing the XDocument or a portion of it, either copied verbatim, or with Xmodifications and/or translated into another language. X XA ``Secondary Section'' is a named appendix or a front-matter section of Xthe Document that deals exclusively with the relationship of the Xpublishers or authors of the Document to the Document's overall subject X(or to related matters) and contains nothing that could fall directly Xwithin that overall subject. (For example, if the Document is in part a Xtextbook of mathematics, a Secondary Section may not explain any Xmathematics.) The relationship could be a matter of historical Xconnection with the subject or with related matters, or of legal, Xcommercial, philosophical, ethical or political position regarding Xthem. X XThe ``Invariant Sections'' are certain Secondary Sections whose titles Xare designated, as being those of Invariant Sections, in the notice Xthat says that the Document is released under this License. X XThe ``Cover Texts'' are certain short passages of text that are listed, Xas Front-Cover Texts or Back-Cover Texts, in the notice that says that Xthe Document is released under this License. X XA ``Transparent'' copy of the Document means a machine-readable copy, Xrepresented in a format whose specification is available to the Xgeneral public, whose contents can be viewed and edited directly and Xstraightforwardly with generic text editors or (for images composed of Xpixels) generic paint programs or (for drawings) some widely available Xdrawing editor, and that is suitable for input to text formatters or Xfor automatic translation to a variety of formats suitable for input Xto text formatters. A copy made in an otherwise Transparent file Xformat whose markup has been designed to thwart or discourage Xsubsequent modification by readers is not Transparent. A copy that is Xnot ``Transparent'' is called ``Opaque''. X XExamples of suitable formats for Transparent copies include plain X@sc{ascii} without markup, Texinfo input format, La@TeX{} input format, X@acronym{SGML} or @acronym{XML} using a publicly available X@acronym{DTD}, and standard-conforming simple @acronym{HTML} designed Xfor human modification. Opaque formats include PostScript, X@acronym{PDF}, proprietary formats that can be read and edited only by Xproprietary word processors, @acronym{SGML} or @acronym{XML} for which Xthe @acronym{DTD} and/or processing tools are not generally available, Xand the machine-generated @acronym{HTML} produced by some word Xprocessors for output purposes only. X XThe ``Title Page'' means, for a printed book, the title page itself, Xplus such following pages as are needed to hold, legibly, the material Xthis License requires to appear in the title page. For works in Xformats which do not have any title page as such, ``Title Page'' means Xthe text near the most prominent appearance of the work's title, Xpreceding the beginning of the body of the text. X X@item XVERBATIM COPYING X XYou may copy and distribute the Document in any medium, either Xcommercially or noncommercially, provided that this License, the Xcopyright notices, and the license notice saying this License applies Xto the Document are reproduced in all copies, and that you add no other Xconditions whatsoever to those of this License. You may not use Xtechnical measures to obstruct or control the reading or further Xcopying of the copies you make or distribute. However, you may accept Xcompensation in exchange for copies. If you distribute a large enough Xnumber of copies you must also follow the conditions in section 3. X XYou may also lend copies, under the same conditions stated above, and Xyou may publicly display copies. X X@item XCOPYING IN QUANTITY X XIf you publish printed copies of the Document numbering more than 100, Xand the Document's license notice requires Cover Texts, you must enclose Xthe copies in covers that carry, clearly and legibly, all these Cover XTexts: Front-Cover Texts on the front cover, and Back-Cover Texts on Xthe back cover. Both covers must also clearly and legibly identify Xyou as the publisher of these copies. The front cover must present Xthe full title with all words of the title equally prominent and Xvisible. You may add other material on the covers in addition. XCopying with changes limited to the covers, as long as they preserve Xthe title of the Document and satisfy these conditions, can be treated Xas verbatim copying in other respects. X XIf the required texts for either cover are too voluminous to fit Xlegibly, you should put the first ones listed (as many as fit Xreasonably) on the actual cover, and continue the rest onto adjacent Xpages. X XIf you publish or distribute Opaque copies of the Document numbering Xmore than 100, you must either include a machine-readable Transparent Xcopy along with each Opaque copy, or state in or with each Opaque copy Xa publicly-accessible computer-network location containing a complete XTransparent copy of the Document, free of added material, which the Xgeneral network-using public has access to download anonymously at no Xcharge using public-standard network protocols. If you use the latter Xoption, you must take reasonably prudent steps, when you begin Xdistribution of Opaque copies in quantity, to ensure that this XTransparent copy will remain thus accessible at the stated location Xuntil at least one year after the last time you distribute an Opaque Xcopy (directly or through your agents or retailers) of that edition to Xthe public. X XIt is requested, but not required, that you contact the authors of the XDocument well before redistributing any large number of copies, to give Xthem a chance to provide you with an updated version of the Document. X X@item XMODIFICATIONS X XYou may copy and distribute a Modified Version of the Document under Xthe conditions of sections 2 and 3 above, provided that you release Xthe Modified Version under precisely this License, with the Modified XVersion filling the role of the Document, thus licensing distribution Xand modification of the Modified Version to whoever possesses a copy Xof it. In addition, you must do these things in the Modified Version: X X@enumerate A X@item XUse in the Title Page (and on the covers, if any) a title distinct Xfrom that of the Document, and from those of previous versions X(which should, if there were any, be listed in the History section Xof the Document). You may use the same title as a previous version Xif the original publisher of that version gives permission. X X@item XList on the Title Page, as authors, one or more persons or entities Xresponsible for authorship of the modifications in the Modified XVersion, together with at least five of the principal authors of the XDocument (all of its principal authors, if it has less than five). X X@item XState on the Title page the name of the publisher of the XModified Version, as the publisher. X X@item XPreserve all the copyright notices of the Document. X X@item XAdd an appropriate copyright notice for your modifications Xadjacent to the other copyright notices. X X@item XInclude, immediately after the copyright notices, a license notice Xgiving the public permission to use the Modified Version under the Xterms of this License, in the form shown in the Addendum below. X X@item XPreserve in that license notice the full lists of Invariant Sections Xand required Cover Texts given in the Document's license notice. X X@item XInclude an unaltered copy of this License. X X@item XPreserve the section entitled ``History'', and its title, and add to Xit an item stating at least the title, year, new authors, and Xpublisher of the Modified Version as given on the Title Page. If Xthere is no section entitled ``History'' in the Document, create one Xstating the title, year, authors, and publisher of the Document as Xgiven on its Title Page, then add an item describing the Modified XVersion as stated in the previous sentence. X X@item XPreserve the network location, if any, given in the Document for Xpublic access to a Transparent copy of the Document, and likewise Xthe network locations given in the Document for previous versions Xit was based on. These may be placed in the ``History'' section. XYou may omit a network location for a work that was published at Xleast four years before the Document itself, or if the original Xpublisher of the version it refers to gives permission. X X@item XIn any section entitled ``Acknowledgments'' or ``Dedications'', Xpreserve the section's title, and preserve in the section all the Xsubstance and tone of each of the contributor acknowledgments Xand/or dedications given therein. X X@item XPreserve all the Invariant Sections of the Document, Xunaltered in their text and in their titles. Section numbers Xor the equivalent are not considered part of the section titles. X X@item XDelete any section entitled ``Endorsements''. Such a section Xmay not be included in the Modified Version. X X@item XDo not retitle any existing section as ``Endorsements'' Xor to conflict in title with any Invariant Section. X@end enumerate X XIf the Modified Version includes new front-matter sections or Xappendices that qualify as Secondary Sections and contain no material Xcopied from the Document, you may at your option designate some or all Xof these sections as invariant. To do this, add their titles to the Xlist of Invariant Sections in the Modified Version's license notice. XThese titles must be distinct from any other section titles. X XYou may add a section entitled ``Endorsements'', provided it contains Xnothing but endorsements of your Modified Version by various Xparties---for example, statements of peer review or that the text has Xbeen approved by an organization as the authoritative definition of a Xstandard. X XYou may add a passage of up to five words as a Front-Cover Text, and a Xpassage of up to 25 words as a Back-Cover Text, to the end of the list Xof Cover Texts in the Modified Version. Only one passage of XFront-Cover Text and one of Back-Cover Text may be added by (or Xthrough arrangements made by) any one entity. If the Document already Xincludes a cover text for the same cover, previously added by you or Xby arrangement made by the same entity you are acting on behalf of, Xyou may not add another; but you may replace the old one, on explicit Xpermission from the previous publisher that added the old one. X XThe author(s) and publisher(s) of the Document do not by this License Xgive permission to use their names for publicity for or to assert or Ximply endorsement of any Modified Version. X X@item XCOMBINING DOCUMENTS X XYou may combine the Document with other documents released under this XLicense, under the terms defined in section 4 above for modified Xversions, provided that you include in the combination all of the XInvariant Sections of all of the original documents, unmodified, and Xlist them all as Invariant Sections of your combined work in its Xlicense notice. X XThe combined work need only contain one copy of this License, and Xmultiple identical Invariant Sections may be replaced with a single Xcopy. If there are multiple Invariant Sections with the same name but Xdifferent contents, make the title of each such section unique by Xadding at the end of it, in parentheses, the name of the original Xauthor or publisher of that section if known, or else a unique number. XMake the same adjustment to the section titles in the list of XInvariant Sections in the license notice of the combined work. X XIn the combination, you must combine any sections entitled ``History'' Xin the various original documents, forming one section entitled X``History''; likewise combine any sections entitled ``Acknowledgments'', Xand any sections entitled ``Dedications''. You must delete all sections Xentitled ``Endorsements.'' X X@item XCOLLECTIONS OF DOCUMENTS X XYou may make a collection consisting of the Document and other documents Xreleased under this License, and replace the individual copies of this XLicense in the various documents with a single copy that is included in Xthe collection, provided that you follow the rules of this License for Xverbatim copying of each of the documents in all other respects. X XYou may extract a single document from such a collection, and distribute Xit individually under this License, provided you insert a copy of this XLicense into the extracted document, and follow this License in all Xother respects regarding verbatim copying of that document. X X@item XAGGREGATION WITH INDEPENDENT WORKS X XA compilation of the Document or its derivatives with other separate Xand independent documents or works, in or on a volume of a storage or Xdistribution medium, does not as a whole count as a Modified Version Xof the Document, provided no compilation copyright is claimed for the Xcompilation. Such a compilation is called an ``aggregate'', and this XLicense does not apply to the other self-contained works thus compiled Xwith the Document, on account of their being thus compiled, if they Xare not themselves derivative works of the Document. X XIf the Cover Text requirement of section 3 is applicable to these Xcopies of the Document, then if the Document is less than one quarter Xof the entire aggregate, the Document's Cover Texts may be placed on Xcovers that surround only the Document within the aggregate. XOtherwise they must appear on covers around the whole aggregate. X X@item XTRANSLATION X XTranslation is considered a kind of modification, so you may Xdistribute translations of the Document under the terms of section 4. XReplacing Invariant Sections with translations requires special Xpermission from their copyright holders, but you may include Xtranslations of some or all Invariant Sections in addition to the Xoriginal versions of these Invariant Sections. You may include a Xtranslation of this License provided that you also include the Xoriginal English version of this License. In case of a disagreement Xbetween the translation and the original English version of this XLicense, the original English version will prevail. X X@item XTERMINATION X XYou may not copy, modify, sublicense, or distribute the Document except Xas expressly provided for under this License. Any other attempt to Xcopy, modify, sublicense or distribute the Document is void, and will Xautomatically terminate your rights under this License. However, Xparties who have received copies, or rights, from you under this XLicense will not have their licenses terminated so long as such Xparties remain in full compliance. X X@item XFUTURE REVISIONS OF THIS LICENSE X XThe Free Software Foundation may publish new, revised versions Xof the GNU Free Documentation License from time to time. Such new Xversions will be similar in spirit to the present version, but may Xdiffer in detail to address new problems or concerns. See X@uref{http://www.gnu.org/copyleft/}. X XEach version of the License is given a distinguishing version number. XIf the Document specifies that a particular numbered version of this XLicense ``or any later version'' applies to it, you have the option of Xfollowing the terms and conditions either of that specified version or Xof any later version that has been published (not as a draft) by the XFree Software Foundation. If the Document does not specify a version Xnumber of this License, you may choose any version ever published (not Xas a draft) by the Free Software Foundation. X@end enumerate X X@page X@appendixsubsec ADDENDUM: How to use this License for your documents X XTo use this License in a document you have written, include a copy of Xthe License in the document and put the following copyright and Xlicense notices just after the title page: X X@smallexample X@group X Copyright (C) @var{year} @var{your name}. X Permission is granted to copy, distribute and/or modify this document X under the terms of the GNU Free Documentation License, Version 1.1 X or any later version published by the Free Software Foundation; X with the Invariant Sections being @var{list their titles}, with the X Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. X A copy of the license is included in the section entitled ``GNU X Free Documentation License''. X@end group X@end smallexample X XIf you have no Invariant Sections, write ``with no Invariant Sections'' Xinstead of saying which ones are invariant. If you have no XFront-Cover Texts, write ``no Front-Cover Texts'' instead of X``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. X XIf your document contains nontrivial examples of program code, we Xrecommend releasing these examples in parallel under your choice of Xfree software license, such as the GNU General Public License, Xto permit their use in free software. X X@c Local Variables: X@c ispell-local-pdict: "ispell-dict" X@c End: X END-of-contrib/diff/doc/fdl.texi echo x - contrib/diff/doc/Makefile.am sed 's/^X//' >contrib/diff/doc/Makefile.am << 'END-of-contrib/diff/doc/Makefile.am' X# Makefile for GNU diffutils documentation. X X# Copyright (C) 2001, 2002 Free Software Foundation, Inc. X X## This program is free software; you can redistribute it and/or modify X## it under the terms of the GNU General Public License as published by X## the Free Software Foundation; either version 2, or (at your option) X## any later version. X X## This program is distributed in the hope that it will be useful, X## but WITHOUT ANY WARRANTY; without even the implied warranty of X## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X## GNU General Public License for more details. X X## You should have received a copy of the GNU General Public License X## along with this program; if not, write to the Free Software Foundation, X## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. X XAM_MAKEINFOFLAGS = --no-split X Xinfo_TEXINFOS = diff.texi Xdiff_TEXINFOS = fdl.texi X XEXTRA_DIST = diagmeet.note END-of-contrib/diff/doc/Makefile.am echo x - contrib/diff/doc/stamp-vti sed 's/^X//' >contrib/diff/doc/stamp-vti << 'END-of-contrib/diff/doc/stamp-vti' X@set UPDATED 5 April 2002 X@set UPDATED-MONTH April 2002 X@set EDITION 2.8.1 X@set VERSION 2.8.1 END-of-contrib/diff/doc/stamp-vti echo x - contrib/diff/doc/version.texi sed 's/^X//' >contrib/diff/doc/version.texi << 'END-of-contrib/diff/doc/version.texi' X@set UPDATED 5 April 2002 X@set UPDATED-MONTH April 2002 X@set EDITION 2.8.1 X@set VERSION 2.8.1 END-of-contrib/diff/doc/version.texi echo x - contrib/diff/doc/diff.texi sed 's/^X//' >contrib/diff/doc/diff.texi << 'END-of-contrib/diff/doc/diff.texi' X\input texinfo @c -*-texinfo-*- X@comment $Id$ X@comment %**start of header X@setfilename diff.info X@include version.texi X@settitle Comparing and Merging Files X@syncodeindex vr cp X@setchapternewpage odd X@comment %**end of header X@copying XThis manual is for GNU Diffutils X(version @value{VERSION}, @value{UPDATED}), Xand documents the @sc{gnu} @command{diff}, @command{diff3}, X@command{sdiff}, and @command{cmp} commands for showing the Xdifferences between files and the @sc{gnu} @command{patch} command for Xusing their output to update files. X XCopyright @copyright{} 1992, 1993, 1994, 1998, 2001, 2002 Free XSoftware Foundation, Inc. X X@quotation XPermission is granted to copy, distribute and/or modify this document Xunder the terms of the GNU Free Documentation License, Version 1.1 or Xany later version published by the Free Software Foundation; with no XInvariant Sections, with the Front-Cover texts being ``A GNU Manual,'' Xand with the Back-Cover Texts as in (a) below. A copy of the Xlicense is included in the section entitled ``GNU Free Documentation XLicense.'' X X(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify Xthis GNU Manual, like GNU software. Copies published by the Free XSoftware Foundation raise funds for GNU development.'' X@end quotation X@end copying X X@c Debian install-info (up through at least version 1.9.20) uses only the X@c first dircategory. Put this one first, as it is more useful in practice. X@dircategory Individual utilities X@direntry X* cmp: (diff)Invoking cmp. Compare 2 files byte by byte. X* diff: (diff)Invoking diff. Compare 2 files line by line. X* diff3: (diff)Invoking diff3. Compare 3 files line by line. X* patch: (diff)Invoking patch. Apply a patch to a file. X* sdiff: (diff)Invoking sdiff. Merge 2 files side-by-side. X@end direntry X X@dircategory GNU packages X@direntry X* Diff: (diff). Comparing and merging files. X@end direntry X X@titlepage X@title Comparing and Merging Files X@subtitle for Diffutils @value{VERSION} and @code{patch} 2.5.4 X@subtitle @value{UPDATED} X@author David MacKenzie, Paul Eggert, and Richard Stallman X@page X@vskip 0pt plus 1filll X@insertcopying X@end titlepage X X@shortcontents X@contents X X@ifnottex X@node Top X@top Comparing and Merging Files X X@insertcopying X@end ifnottex X X@menu X* Overview:: Preliminary information. X* Comparison:: What file comparison means. X X* Output Formats:: Formats for two-way difference reports. X* Incomplete Lines:: Lines that lack trailing newlines. X* Comparing Directories:: Comparing files and directories. X* Adjusting Output:: Making @command{diff} output prettier. X* diff Performance:: Making @command{diff} smarter or faster. X X* Comparing Three Files:: Formats for three-way difference reports. X* diff3 Merging:: Merging from a common ancestor. X X* Interactive Merging:: Interactive merging with @command{sdiff}. X X* Merging with patch:: Using @command{patch} to change old files into new ones. X* Making Patches:: Tips for making and using patch distributions. X X* Invoking cmp:: Compare two files byte by byte. X* Invoking diff:: Compare two files line by line. X* Invoking diff3:: Compare three files line by line. X* Invoking patch:: Apply a diff file to an original. X* Invoking sdiff:: Side-by-side merge of file differences. X X* Standards conformance:: Conformance to the @sc{posix} standard. X* Projects:: If you've found a bug or other shortcoming. X X* Copying This Manual:: How to make copies of this manual. X* Index:: Index. X@end menu X X@node Overview X@unnumbered Overview X@cindex overview of @command{diff} and @command{patch} X XComputer users often find occasion to ask how two files differ. Perhaps Xone file is a newer version of the other file. Or maybe the two files Xstarted out as identical copies but were changed by different people. X XYou can use the @command{diff} command to show differences between two Xfiles, or each corresponding file in two directories. @command{diff} Xoutputs differences between files line by line in any of several Xformats, selectable by command line options. This set of differences is Xoften called a @dfn{diff} or @dfn{patch}. For files that are identical, X@command{diff} normally produces no output; for binary (non-text) files, X@command{diff} normally reports only that they are different. X XYou can use the @command{cmp} command to show the byte and line numbers Xwhere two files differ. @command{cmp} can also show all the bytes Xthat differ between the two files, side by side. A way to compare Xtwo files character by character is the Emacs command @kbd{M-x Xcompare-windows}. @xref{Other Window, , Other Window, emacs, The @sc{gnu} XEmacs Manual}, for more information on that command. X XYou can use the @command{diff3} command to show differences among three Xfiles. When two people have made independent changes to a common Xoriginal, @command{diff3} can report the differences between the original Xand the two changed versions, and can produce a merged file that Xcontains both persons' changes together with warnings about conflicts. X XYou can use the @command{sdiff} command to merge two files interactively. X XYou can use the set of differences produced by @command{diff} to distribute Xupdates to text files (such as program source code) to other people. XThis method is especially useful when the differences are small compared Xto the complete files. Given @command{diff} output, you can use the X@command{patch} program to update, or @dfn{patch}, a copy of the file. If you Xthink of @command{diff} as subtracting one file from another to produce Xtheir difference, you can think of @command{patch} as adding the difference Xto one file to reproduce the other. X XThis manual first concentrates on making diffs, and later shows how to Xuse diffs to update files. X X@sc{gnu} @command{diff} was written by Paul Eggert, Mike Haertel, XDavid Hayes, Richard Stallman, and Len Tower. Wayne Davison designed and Ximplemented the unified output format. The basic algorithm is described Xin ``An O(ND) Difference Algorithm and its Variations'', Eugene W. Myers, X@cite{Algorithmica} Vol.@: 1 No.@: 2, 1986, pp.@: 251--266; and in ``A File XComparison Program'', Webb Miller and Eugene W. Myers, X@cite{Software---Practice and Experience} Vol.@: 15 No.@: 11, 1985, Xpp.@: 1025--1040. X@c From: "Gene Myers" X@c They are about the same basic algorithm; the Algorithmica X@c paper gives a rigorous treatment and the sub-algorithm for X@c delivering scripts and should be the primary reference, but X@c both should be mentioned. XThe algorithm was independently discovered as described in X``Algorithms for Approximate String Matching'', XE. Ukkonen, @cite{Information and Control} Vol.@: 64, 1985, pp.@: 100--118. X@c From: "Gene Myers" X@c Date: Wed, 29 Sep 1993 08:27:55 MST X@c Ukkonen should be given credit for also discovering the algorithm used X@c in GNU diff. X X@sc{gnu} @command{diff3} was written by Randy Smith. @sc{gnu} X@command{sdiff} was written by Thomas Lord. @sc{gnu} @command{cmp} Xwas written by Torbjorn Granlund and David MacKenzie. X X@command{patch} was written mainly by Larry Wall and Paul Eggert; Xseveral @sc{gnu} enhancements were contributed by Wayne Davison and XDavid MacKenzie. Parts of this manual are adapted from a manual page Xwritten by Larry Wall, with his permission. X X@node Comparison X@chapter What Comparison Means X@cindex introduction X XThere are several ways to think about the differences between two files. XOne way to think of the differences is as a series of lines that were Xdeleted from, inserted in, or changed in one file to produce the other Xfile. @command{diff} compares two files line by line, finds groups of Xlines that differ, and reports each group of differing lines. It can Xreport the differing lines in several formats, which have different Xpurposes. X X@sc{gnu} @command{diff} can show whether files are different without detailing Xthe differences. It also provides ways to suppress certain kinds of Xdifferences that are not important to you. Most commonly, such Xdifferences are changes in the amount of white space between words or Xlines. @command{diff} also provides ways to suppress differences in Xalphabetic case or in lines that match a regular expression that you Xprovide. These options can accumulate; for example, you can ignore Xchanges in both white space and alphabetic case. X XAnother way to think of the differences between two files is as a Xsequence of pairs of bytes that can be either identical or Xdifferent. @command{cmp} reports the differences between two files Xbyte by byte, instead of line by line. As a result, it is often Xmore useful than @command{diff} for comparing binary files. For text Xfiles, @command{cmp} is useful mainly when you want to know only whether Xtwo files are identical, or whether one file is a prefix of the other. X XTo illustrate the effect that considering changes byte by byte Xcan have compared with considering them line by line, think of what Xhappens if a single newline character is added to the beginning of a Xfile. If that file is then compared with an otherwise identical file Xthat lacks the newline at the beginning, @command{diff} will report that a Xblank line has been added to the file, while @command{cmp} will report that Xalmost every byte of the two files differs. X X@command{diff3} normally compares three input files line by line, finds Xgroups of lines that differ, and reports each group of differing lines. XIts output is designed to make it easy to inspect two different sets of Xchanges to the same file. X X@menu X* Hunks:: Groups of differing lines. X* White Space:: Suppressing differences in white space. X* Blank Lines:: Suppressing differences in blank lines. X* Case Folding:: Suppressing differences in alphabetic case. X* Specified Folding:: Suppressing differences that match regular expressions. X* Brief:: Summarizing which files are different. X* Binary:: Comparing binary files or forcing text comparisons. X@end menu X X@node Hunks X@section Hunks X@cindex hunks X XWhen comparing two files, @command{diff} finds sequences of lines common to Xboth files, interspersed with groups of differing lines called X@dfn{hunks}. Comparing two identical files yields one sequence of Xcommon lines and no hunks, because no lines differ. Comparing two Xentirely different files yields no common lines and one large hunk that Xcontains all lines of both files. In general, there are many ways to Xmatch up lines between two given files. @command{diff} tries to minimize Xthe total hunk size by finding large sequences of common lines Xinterspersed with small hunks of differing lines. X XFor example, suppose the file @file{F} contains the three lines X@samp{a}, @samp{b}, @samp{c}, and the file @file{G} contains the same Xthree lines in reverse order @samp{c}, @samp{b}, @samp{a}. If X@command{diff} finds the line @samp{c} as common, then the command X@samp{diff F G} produces this output: X X@example X1,2d0 X< a X< b X3a2,3 X> b X> a X@end example X X@noindent XBut if @command{diff} notices the common line @samp{b} instead, it produces Xthis output: X X@example X1c1 X< a X--- X> c X3c3 X< c X--- X> a X@end example X X@noindent XIt is also possible to find @samp{a} as the common line. @command{diff} Xdoes not always find an optimal matching between the files; it takes Xshortcuts to run faster. But its output is usually close to the Xshortest possible. You can adjust this tradeoff with the X@option{--minimal} option (@pxref{diff Performance}). X X@node White Space X@section Suppressing Differences in Blank and Tab Spacing X@cindex blank and tab difference suppression X@cindex tab and blank difference suppression X XThe @option{-E} and @option{--ignore-tab-expansion} options ignore the Xdistinction between tabs and spaces on input. A tab is considered to be Xequivalent to the number of spaces to the next tab stop. @command{diff} Xassumes that tab stops are set every 8 print columns. X XThe @option{-b} and @option{--ignore-space-change} options are stronger. XThey ignore white space at line end, and consider all other sequences of Xone or more white space characters to be equivalent. With these Xoptions, @command{diff} considers the following two lines to be equivalent, Xwhere @samp{$} denotes the line end: X X@example XHere lyeth muche rychnesse in lytell space. -- John Heywood$ XHere lyeth muche rychnesse in lytell space. -- John Heywood $ X@end example X XThe @option{-w} and @option{--ignore-all-space} options are stronger still. XThey ignore difference even if one line has white space where Xthe other line has none. @dfn{White space} characters include Xtab, newline, vertical tab, form feed, carriage return, and space; Xsome locales may define additional characters to be white space. XWith these options, @command{diff} considers the Xfollowing two lines to be equivalent, where @samp{$} denotes the line Xend and @samp{^M} denotes a carriage return: X X@example XHere lyeth muche rychnesse in lytell space.-- John Heywood$ X He relyeth much erychnes seinly tells pace. --John Heywood ^M$ X@end example X X@node Blank Lines X@section Suppressing Differences in Blank Lines X@cindex blank line difference suppression X XThe @option{-B} and @option{--ignore-blank-lines} options ignore insertions Xor deletions of blank lines. These options affect only lines Xthat are completely empty; they do not affect lines that look empty but Xcontain space or tab characters. With these options, for example, a Xfile containing X@example X1. A point is that which has no part. X X2. A line is breadthless length. X-- Euclid, The Elements, I X@end example X@noindent Xis considered identical to a file containing X@example X1. A point is that which has no part. X2. A line is breadthless length. X X X-- Euclid, The Elements, I X@end example X X@node Case Folding X@section Suppressing Case Differences X@cindex case difference suppression X X@sc{gnu} @command{diff} can treat lower case letters as equivalent to their Xupper case counterparts, so that, for example, it considers @samp{Funky XStuff}, @samp{funky STUFF}, and @samp{fUNKy stuFf} to all be the same. XTo request this, use the @option{-i} or @option{--ignore-case} option. X X@node Specified Folding X@section Suppressing Lines Matching a Regular Expression X@cindex regular expression suppression X XTo ignore insertions and deletions of lines that match a X@command{grep}-style regular expression, use the @option{-I X@var{regexp}} or @option{--ignore-matching-lines=@var{regexp}} option. XYou should escape Xregular expressions that contain shell metacharacters to prevent the Xshell from expanding them. For example, @samp{diff -I '^[[:digit:]]'} ignores Xall changes to lines beginning with a digit. X XHowever, @option{-I} only ignores the insertion or deletion of lines that Xcontain the regular expression if every changed line in the hunk---every Xinsertion and every deletion---matches the regular expression. In other Xwords, for each nonignorable change, @command{diff} prints the complete set Xof changes in its vicinity, including the ignorable ones. X XYou can specify more than one regular expression for lines to ignore by Xusing more than one @option{-I} option. @command{diff} tries to match each Xline against each regular expression. X X@node Brief X@section Summarizing Which Files Differ X@cindex summarizing which files differ X@cindex brief difference reports X XWhen you only want to find out whether files are different, and you Xdon't care what the differences are, you can use the summary output Xformat. In this format, instead of showing the differences between the Xfiles, @command{diff} simply reports whether files differ. The @option{-q} Xand @option{--brief} options select this output format. X XThis format is especially useful when comparing the contents of two Xdirectories. It is also much faster than doing the normal line by line Xcomparisons, because @command{diff} can stop analyzing the files as soon as Xit knows that there are any differences. X XYou can also get a brief indication of whether two files differ by using X@command{cmp}. For files that are identical, @command{cmp} produces no Xoutput. When the files differ, by default, @command{cmp} outputs the byte Xand line number where the first difference occurs. You can use Xthe @option{-s} option to suppress that information, so that @command{cmp} Xproduces no output and reports whether the files differ using only its Xexit status (@pxref{Invoking cmp}). X X@c Fix this. XUnlike @command{diff}, @command{cmp} cannot compare directories; it can only Xcompare two files. X X@node Binary X@section Binary Files and Forcing Text Comparisons X@cindex binary file diff X@cindex text versus binary diff X XIf @command{diff} thinks that either of the two files it is comparing is Xbinary (a non-text file), it normally treats that pair of files much as Xif the summary output format had been selected (@pxref{Brief}), and Xreports only that the binary files are different. This is because line Xby line comparisons are usually not meaningful for binary files. X X@command{diff} determines whether a file is text or binary by checking the Xfirst few bytes in the file; the exact number of bytes is system Xdependent, but it is typically several thousand. If every byte in Xthat part of the file is non-null, @command{diff} considers the file to be Xtext; otherwise it considers the file to be binary. X XSometimes you might want to force @command{diff} to consider files to be Xtext. For example, you might be comparing text files that contain Xnull characters; @command{diff} would erroneously decide that those are Xnon-text files. Or you might be comparing documents that are in a Xformat used by a word processing system that uses null characters to Xindicate special formatting. You can force @command{diff} to consider all Xfiles to be text files, and compare them line by line, by using the X@option{-a} or @option{--text} option. If the files you compare using this Xoption do not in fact contain text, they will probably contain few Xnewline characters, and the @command{diff} output will consist of hunks Xshowing differences between long lines of whatever characters the files Xcontain. X XYou can also force @command{diff} to consider all files to be binary files, Xand report only whether they differ (but not how). Use the X@option{-q} or @option{--brief} option for this. X XDiffering binary files are considered to cause trouble because the Xresulting @command{diff} output does not capture all the differences. XThis trouble causes @command{diff} to exit with status 2. However, Xthis trouble cannot occur with the @option{--a} or @option{--text} Xoption, or with the @option{-q} or @option{--brief} option, as these Xoptions both cause @command{diff} to treat binary files like text Xfiles. X XIn operating systems that distinguish between text and binary files, X@command{diff} normally reads and writes all data as text. Use the X@option{--binary} option to force @command{diff} to read and write binary Xdata instead. This option has no effect on a @sc{posix}-compliant system Xlike @sc{gnu} or traditional Unix. However, many personal computer Xoperating systems represent the end of a line with a carriage return Xfollowed by a newline. On such systems, @command{diff} normally ignores Xthese carriage returns on input and generates them at the end of each Xoutput line, but with the @option{--binary} option @command{diff} treats Xeach carriage return as just another input character, and does not Xgenerate a carriage return at the end of each output line. This can be Xuseful when dealing with non-text files that are meant to be Xinterchanged with @sc{posix}-compliant systems. X XThe @option{--strip-trailing-cr} causes @command{diff} to treat input Xlines that end in carriage return followed by newline as if they end Xin plain newline. This can be useful when comparing text that is Ximperfectly imported from many personal computer operating systems. XThis option affects how lines are read, which in turn affects how they Xare compared and output. X XIf you want to compare two files byte by byte, you can use the X@command{cmp} program with the @option{-l} option to show the values Xof each differing byte in the two files. With @sc{gnu} @command{cmp}, Xyou can also use the @option{-b} option to show the @sc{ascii} Xrepresentation of those bytes. @xref{Invoking cmp}, for more Xinformation. X XIf @command{diff3} thinks that any of the files it is comparing is binary X(a non-text file), it normally reports an error, because such Xcomparisons are usually not useful. @command{diff3} uses the same test as X@command{diff} to decide whether a file is binary. As with @command{diff}, if Xthe input files contain a few non-text bytes but otherwise are like Xtext files, you can force @command{diff3} to consider all files to be text Xfiles and compare them line by line by using the @option{-a} or X@option{--text} options. X X@node Output Formats X@chapter @command{diff} Output Formats X@cindex output formats X@cindex format of @command{diff} output X X@command{diff} has several mutually exclusive options for output format. XThe following sections describe each format, illustrating how X@command{diff} reports the differences between two sample input files. X X@menu X* Sample diff Input:: Sample @command{diff} input files for examples. X* Normal:: Showing differences without surrounding text. X* Context:: Showing differences with the surrounding text. X* Side by Side:: Showing differences in two columns. X* Scripts:: Generating scripts for other programs. X* If-then-else:: Merging files with if-then-else. X@end menu X X@node Sample diff Input X@section Two Sample Input Files X@cindex @command{diff} sample input X@cindex sample input for @command{diff} X XHere are two sample files that we will use in numerous examples to Xillustrate the output of @command{diff} and how various options can change Xit. X XThis is the file @file{lao}: X X@example XThe Way that can be told of is not the eternal Way; XThe name that can be named is not the eternal name. XThe Nameless is the origin of Heaven and Earth; XThe Named is the mother of all things. XTherefore let there always be non-being, X so we may see their subtlety, XAnd let there always be being, X so we may see their outcome. XThe two are the same, XBut after they are produced, X they have different names. X@end example X XThis is the file @file{tzu}: X X@example XThe Nameless is the origin of Heaven and Earth; XThe named is the mother of all things. X XTherefore let there always be non-being, X so we may see their subtlety, XAnd let there always be being, X so we may see their outcome. XThe two are the same, XBut after they are produced, X they have different names. XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X@end example X XIn this example, the first hunk contains just the first two lines of X@file{lao}, the second hunk contains the fourth line of @file{lao} Xopposing the second and third lines of @file{tzu}, and the last hunk Xcontains just the last three lines of @file{tzu}. X X@node Normal X@section Showing Differences Without Context X@cindex normal output format X@cindex @samp{<} output format X XThe ``normal'' @command{diff} output format shows each hunk of differences Xwithout any surrounding context. Sometimes such output is the clearest Xway to see how lines have changed, without the clutter of nearby Xunchanged lines (although you can get similar results with the context Xor unified formats by using 0 lines of context). However, this format Xis no longer widely used for sending out patches; for that purpose, the Xcontext format (@pxref{Context Format}) and the unified format X(@pxref{Unified Format}) are superior. Normal format is the default for Xcompatibility with older versions of @command{diff} and the @sc{posix} Xstandard. Use the @option{--normal} option to select this output Xformat explicitly. X X@menu X* Detailed Normal:: A detailed description of normal output format. X* Example Normal:: Sample output in the normal format. X@end menu X X@node Detailed Normal X@subsection Detailed Description of Normal Format X XThe normal output format consists of one or more hunks of differences; Xeach hunk shows one area where the files differ. Normal format hunks Xlook like this: X X@example X@var{change-command} X< @var{from-file-line} X< @var{from-file-line}@dots{} X--- X> @var{to-file-line} X> @var{to-file-line}@dots{} X@end example X XThere are three types of change commands. Each consists of a line Xnumber or comma-separated range of lines in the first file, a single Xcharacter indicating the kind of change to make, and a line number or Xcomma-separated range of lines in the second file. All line numbers are Xthe original line numbers in each file. The types of change commands Xare: X X@table @samp X@item @var{l}a@var{r} XAdd the lines in range @var{r} of the second file after line @var{l} of Xthe first file. For example, @samp{8a12,15} means append lines 12--15 Xof file 2 after line 8 of file 1; or, if changing file 2 into file 1, Xdelete lines 12--15 of file 2. X X@item @var{f}c@var{t} XReplace the lines in range @var{f} of the first file with lines in range X@var{t} of the second file. This is like a combined add and delete, but Xmore compact. For example, @samp{5,7c8,10} means change lines 5--7 of Xfile 1 to read as lines 8--10 of file 2; or, if changing file 2 into Xfile 1, change lines 8--10 of file 2 to read as lines 5--7 of file 1. X X@item @var{r}d@var{l} XDelete the lines in range @var{r} from the first file; line @var{l} is where Xthey would have appeared in the second file had they not been deleted. XFor example, @samp{5,7d3} means delete lines 5--7 of file 1; or, if Xchanging file 2 into file 1, append lines 5--7 of file 1 after line 3 of Xfile 2. X@end table X X@node Example Normal X@subsection An Example of Normal Format X XHere is the output of the command @samp{diff lao tzu} X(@pxref{Sample diff Input}, for the complete contents of the two files). XNotice that it shows only the lines that are different between the two Xfiles. X X@example X1,2d0 X< The Way that can be told of is not the eternal Way; X< The name that can be named is not the eternal name. X4c2,3 X< The Named is the mother of all things. X--- X> The named is the mother of all things. X> X11a11,13 X> They both may be called deep and profound. X> Deeper and more profound, X> The door of all subtleties! X@end example X X@node Context X@section Showing Differences in Their Context X@cindex context output format X@cindex @samp{!} output format X XUsually, when you are looking at the differences between files, you will Xalso want to see the parts of the files near the lines that differ, to Xhelp you understand exactly what has changed. These nearby parts of the Xfiles are called the @dfn{context}. X X@sc{gnu} @command{diff} provides two output formats that show context Xaround the differing lines: @dfn{context format} and @dfn{unified Xformat}. It can optionally show in which function or section of the Xfile the differing lines are found. X XIf you are distributing new versions of files to other people in the Xform of @command{diff} output, you should use one of the output formats Xthat show context so that they can apply the diffs even if they have Xmade small changes of their own to the files. @command{patch} can apply Xthe diffs in this case by searching in the files for the lines of Xcontext around the differing lines; if those lines are actually a few Xlines away from where the diff says they are, @command{patch} can adjust Xthe line numbers accordingly and still apply the diff correctly. X@xref{Imperfect}, for more information on using @command{patch} to apply Ximperfect diffs. X X@menu X* Context Format:: An output format that shows surrounding lines. X* Unified Format:: A more compact output format that shows context. X* Sections:: Showing which sections of the files differences are in. X* Alternate Names:: Showing alternate file names in context headers. X@end menu X X@node Context Format X@subsection Context Format X XThe context output format shows several lines of context around the Xlines that differ. It is the standard format for distributing updates Xto source code. X XTo select this output format, use the @option{-C @var{lines}}, X@option{--context@r{[}=@var{lines}@r{]}}, or @option{-c} option. The Xargument @var{lines} that some of these options take is the number of Xlines of context to show. If you do not specify @var{lines}, it Xdefaults to three. For proper operation, @command{patch} typically needs Xat least two lines of context. X X@menu X* Detailed Context:: A detailed description of the context output format. X* Example Context:: Sample output in context format. X* Less Context:: Another sample with less context. X@end menu X X@node Detailed Context X@subsubsection Detailed Description of Context Format X XThe context output format starts with a two-line header, which looks Xlike this: X X@example X*** @var{from-file} @var{from-file-modification-time} X--- @var{to-file} @var{to-file-modification time} X@end example X X@noindent X@vindex LC_TIME X@cindex time stamp format, context diffs XThe time stamp normally looks like @samp{2002-02-21 23:30:39.942229878 X-0800} to indicate the date, time with fractional seconds, and time Xzone in @uref{ftp://ftp.isi.edu/in-notes/rfc2822.txt, Internet RFC X2822 format}. However, a traditional time stamp like @samp{Thu Feb 21 X23:30:39 2002} is used if the @env{LC_TIME} locale category is either X@samp{C} or @samp{POSIX}. X XYou can change the header's content with the X@option{--label=@var{label}} option; see @ref{Alternate Names}. X XNext come one or more hunks of differences; each hunk shows one area Xwhere the files differ. Context format hunks look like this: X X@example X*************** X*** @var{from-file-line-range} **** X @var{from-file-line} X @var{from-file-line}@dots{} X--- @var{to-file-line-range} ---- X @var{to-file-line} X @var{to-file-line}@dots{} X@end example X XThe lines of context around the lines that differ start with two space Xcharacters. The lines that differ between the two files start with one Xof the following indicator characters, followed by a space character: X X@table @samp X@item ! XA line that is part of a group of one or more lines that changed between Xthe two files. There is a corresponding group of lines marked with X@samp{!} in the part of this hunk for the other file. X X@item + XAn ``inserted'' line in the second file that corresponds to nothing in Xthe first file. X X@item - XA ``deleted'' line in the first file that corresponds to nothing in the Xsecond file. X@end table X XIf all of the changes in a hunk are insertions, the lines of X@var{from-file} are omitted. If all of the changes are deletions, the Xlines of @var{to-file} are omitted. X X@node Example Context X@subsubsection An Example of Context Format X XHere is the output of @samp{diff -c lao tzu} (@pxref{Sample diff Input}, Xfor the complete contents of the two files). Notice that up to three Xlines that are not different are shown around each line that is Xdifferent; they are the context lines. Also notice that the first two Xhunks have run together, because their contents overlap. X X@example X*** lao 2002-02-21 23:30:39.942229878 -0800 X--- tzu 2002-02-21 23:30:50.442260588 -0800 X*************** X*** 1,7 **** X- The Way that can be told of is not the eternal Way; X- The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X! The Named is the mother of all things. X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X--- 1,6 ---- X The Nameless is the origin of Heaven and Earth; X! The named is the mother of all things. X! X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X*************** X*** 9,11 **** X--- 8,13 ---- X The two are the same, X But after they are produced, X they have different names. X+ They both may be called deep and profound. X+ Deeper and more profound, X+ The door of all subtleties! X@end example X X@node Less Context X@subsubsection An Example of Context Format with Less Context X XHere is the output of @samp{diff -C 1 lao tzu} (@pxref{Sample diff XInput}, for the complete contents of the two files). Notice that at Xmost one context line is reported here. X X@example X*** lao 2002-02-21 23:30:39.942229878 -0800 X--- tzu 2002-02-21 23:30:50.442260588 -0800 X*************** X*** 1,5 **** X- The Way that can be told of is not the eternal Way; X- The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X! The Named is the mother of all things. X Therefore let there always be non-being, X--- 1,4 ---- X The Nameless is the origin of Heaven and Earth; X! The named is the mother of all things. X! X Therefore let there always be non-being, X*************** X*** 11 **** X--- 10,13 ---- X they have different names. X+ They both may be called deep and profound. X+ Deeper and more profound, X+ The door of all subtleties! X@end example X X@node Unified Format X@subsection Unified Format X@cindex unified output format X@cindex @samp{+-} output format X XThe unified output format is a variation on the context format that is Xmore compact because it omits redundant context lines. To select this Xoutput format, use the @option{-U @var{lines}}, X@option{--unified@r{[}=@var{lines}@r{]}}, or @option{-u} Xoption. The argument @var{lines} is the number of lines of context to Xshow. When it is not given, it defaults to three. X XAt present, only @sc{gnu} @command{diff} can produce this format and Xonly @sc{gnu} @command{patch} can automatically apply diffs in this Xformat. For proper operation, @command{patch} typically needs at Xleast three lines of context. X X@menu X* Detailed Unified:: A detailed description of unified format. X* Example Unified:: Sample output in unified format. X@end menu X X@node Detailed Unified X@subsubsection Detailed Description of Unified Format X XThe unified output format starts with a two-line header, which looks Xlike this: X X@example X--- @var{from-file} @var{from-file-modification-time} X+++ @var{to-file} @var{to-file-modification-time} X@end example X X@noindent X@cindex time stamp format, unified diffs XThe time stamp looks like @samp{2002-02-21 23:30:39.942229878 -0800} Xto indicate the date, time with fractional seconds, and time zone. X XYou can change the header's content with the X@option{--label=@var{label}} option; see @xref{Alternate Names}. X XNext come one or more hunks of differences; each hunk shows one area Xwhere the files differ. Unified format hunks look like this: X X@example X@@@@ @var{from-file-range} @var{to-file-range} @@@@ X @var{line-from-either-file} X @var{line-from-either-file}@dots{} X@end example X XThe lines common to both files begin with a space character. The lines Xthat actually differ between the two files have one of the following Xindicator characters in the left print column: X X@table @samp X@item + XA line was added here to the first file. X X@item - XA line was removed here from the first file. X@end table X X@node Example Unified X@subsubsection An Example of Unified Format X XHere is the output of the command @samp{diff -u lao tzu} X(@pxref{Sample diff Input}, for the complete contents of the two files): X X@example X--- lao 2002-02-21 23:30:39.942229878 -0800 X+++ tzu 2002-02-21 23:30:50.442260588 -0800 X@@@@ -1,7 +1,6 @@@@ X-The Way that can be told of is not the eternal Way; X-The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X-The Named is the mother of all things. X+The named is the mother of all things. X+ X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X@@@@ -9,3 +8,6 @@@@ X The two are the same, X But after they are produced, X they have different names. X+They both may be called deep and profound. X+Deeper and more profound, X+The door of all subtleties! X@end example X X@node Sections X@subsection Showing Which Sections Differences Are in X@cindex headings X@cindex section headings X XSometimes you might want to know which part of the files each change Xfalls in. If the files are source code, this could mean which function Xwas changed. If the files are documents, it could mean which chapter or Xappendix was changed. @sc{gnu} @command{diff} can show this by displaying the Xnearest section heading line that precedes the differing lines. Which Xlines are ``section headings'' is determined by a regular expression. X X@menu X* Specified Headings:: Showing headings that match regular expressions. X* C Function Headings:: Showing headings of C functions. X@end menu X X@node Specified Headings X@subsubsection Showing Lines That Match Regular Expressions X@cindex specified headings X@cindex regular expression matching headings X XTo show in which sections differences occur for files that are not Xsource code for C or similar languages, use the @option{-F @var{regexp}} Xor @option{--show-function-line=@var{regexp}} option. @command{diff} Xconsiders lines that match the @command{grep}-style regular expression X@var{regexp} to be the beginning Xof a section of the file. Here are suggested regular expressions for Xsome common languages: X X@c Please add to this list, e.g. Fortran, Pascal, Perl, Python. X@table @samp X@item ^[[:alpha:]$_] XC, C++, Prolog X@item ^( XLisp X@item ^@@node XTexinfo X@end table X XThis option does not automatically select an output format; in order to Xuse it, you must select the context format (@pxref{Context Format}) or Xunified format (@pxref{Unified Format}). In other output formats it Xhas no effect. X XThe @option{-F} and @option{--show-function-line} options find the nearest Xunchanged line that precedes each hunk of differences and matches the Xgiven regular expression. Then they add that line to the end of the Xline of asterisks in the context format, or to the @samp{@@@@} line in Xunified format. If no matching line exists, they leave the output for Xthat hunk unchanged. If that line is more than 40 characters long, they Xoutput only the first 40 characters. You can specify more than one Xregular expression for such lines; @command{diff} tries to match each line Xagainst each regular expression, starting with the last one given. This Xmeans that you can use @option{-p} and @option{-F} together, if you wish. X X@node C Function Headings X@subsubsection Showing C Function Headings X@cindex C function headings X@cindex function headings, C X XTo show in which functions differences occur for C and similar Xlanguages, you can use the @option{-p} or @option{--show-c-function} option. XThis option automatically defaults to the context output format X(@pxref{Context Format}), with the default number of lines of context. XYou can override that number with @option{-C @var{lines}} elsewhere in the Xcommand line. You can override both the format and the number with X@option{-U @var{lines}} elsewhere in the command line. X XThe @option{-p} and @option{--show-c-function} options are equivalent to X@option{-F '^[[:alpha:]$_]'} if the unified format is specified, otherwise X@option{-c -F '^[[:alpha:]$_]'} (@pxref{Specified Headings}). @sc{gnu} X@command{diff} provides them for the sake of convenience. X X@node Alternate Names X@subsection Showing Alternate File Names X@cindex alternate file names X@cindex file name alternates X XIf you are comparing two files that have meaningless or uninformative Xnames, you might want @command{diff} to show alternate names in the header Xof the context and unified output formats. To do this, use the X@option{--label=@var{label}} option. The first time Xyou give this option, its argument replaces the name and date of the Xfirst file in the header; the second time, its argument replaces the Xname and date of the second file. If you give this option more than Xtwice, @command{diff} reports an error. The @option{--label} option does not Xaffect the file names in the @command{pr} header when the @option{-l} or X@option{--paginate} option is used (@pxref{Pagination}). X XHere are the first two lines of the output from @samp{diff -C 2 X--label=original --label=modified lao tzu}: X X@example X*** original X--- modified X@end example X X@node Side by Side X@section Showing Differences Side by Side X@cindex side by side X@cindex two-column output X@cindex columnar output X X@command{diff} can produce a side by side difference listing of two files. XThe files are listed in two columns with a gutter between them. The Xgutter contains one of the following markers: X X@table @asis X@item white space XThe corresponding lines are in common. That is, either the lines are Xidentical, or the difference is ignored because of one of the X@option{--ignore} options (@pxref{White Space}). X X@item @samp{|} XThe corresponding lines differ, and they are either both complete Xor both incomplete. X X@item @samp{<} XThe files differ and only the first file contains the line. X X@item @samp{>} XThe files differ and only the second file contains the line. X X@item @samp{(} XOnly the first file contains the line, but the difference is ignored. X X@item @samp{)} XOnly the second file contains the line, but the difference is ignored. X X@item @samp{\} XThe corresponding lines differ, and only the first line is incomplete. X X@item @samp{/} XThe corresponding lines differ, and only the second line is incomplete. X@end table X XNormally, an output line is incomplete if and only if the lines that it Xcontains are incomplete; @xref{Incomplete Lines}. However, when an Xoutput line represents two differing lines, one might be incomplete Xwhile the other is not. In this case, the output line is complete, Xbut its the gutter is marked @samp{\} if the first line is incomplete, X@samp{/} if the second line is. X XSide by side format is sometimes easiest to read, but it has limitations. XIt generates much wider output than usual, and truncates lines that are Xtoo long to fit. Also, it relies on lining up output more heavily than Xusual, so its output looks particularly bad if you use varying Xwidth fonts, nonstandard tab stops, or nonprinting characters. X XYou can use the @command{sdiff} command to interactively merge side by side Xdifferences. @xref{Interactive Merging}, for more information on merging files. X X@menu X* Side by Side Format:: Controlling side by side output format. X* Example Side by Side:: Sample side by side output. X@end menu X X@node Side by Side Format X@subsection Controlling Side by Side Format X@cindex side by side format X XThe @option{-y} or @option{--side-by-side} option selects side by side Xformat. Because side by side output lines contain two input lines, the Xoutput is wider than usual: normally 130 print columns, which can fit Xonto a traditional printer line. You can set the width of the output Xwith the @option{-W @var{columns}} or @option{--width=@var{columns}} Xoption. The output is split into two halves of equal width, separated by a Xsmall gutter to mark differences; the right half is aligned to a tab Xstop so that tabs line up. Input lines that are too long to fit in half Xof an output line are truncated for output. X XThe @option{--left-column} option prints only the left column of two Xcommon lines. The @option{--suppress-common-lines} option suppresses Xcommon lines entirely. X X@node Example Side by Side X@subsection An Example of Side by Side Format X XHere is the output of the command @samp{diff -y -W 72 lao tzu} X(@pxref{Sample diff Input}, for the complete contents of the two files). X X@example XThe Way that can be told of is n < XThe name that can be named is no < XThe Nameless is the origin of He The Nameless is the origin of He XThe Named is the mother of all t | The named is the mother of all t X > XTherefore let there always be no Therefore let there always be no X so we may see their subtlety, so we may see their subtlety, XAnd let there always be being, And let there always be being, X so we may see their outcome. so we may see their outcome. XThe two are the same, The two are the same, XBut after they are produced, But after they are produced, X they have different names. they have different names. X > They both may be called deep and X > Deeper and more profound, X > The door of all subtleties! X@end example X X@node Scripts X@section Making Edit Scripts X@cindex script output formats X XSeveral output modes produce command scripts for editing @var{from-file} Xto produce @var{to-file}. X X@menu X* ed Scripts:: Using @command{diff} to produce commands for @command{ed}. X* Forward ed:: Making forward @command{ed} scripts. X* RCS:: A special @command{diff} output format used by @sc{rcs}. X@end menu X X@node ed Scripts X@subsection @command{ed} Scripts X@cindex @command{ed} script output format X X@command{diff} can produce commands that direct the @command{ed} text editor Xto change the first file into the second file. Long ago, this was the Xonly output mode that was suitable for editing one file into another Xautomatically; today, with @command{patch}, it is almost obsolete. Use the X@option{-e} or @option{--ed} option to select this output format. X XLike the normal format (@pxref{Normal}), this output format does not Xshow any context; unlike the normal format, it does not include the Xinformation necessary to apply the diff in reverse (to produce the first Xfile if all you have is the second file and the diff). X XIf the file @file{d} contains the output of @samp{diff -e old new}, then Xthe command @samp{(cat d && echo w) | ed - old} edits @file{old} to make Xit a copy of @file{new}. More generally, if @file{d1}, @file{d2}, X@dots{}, @file{dN} contain the outputs of @samp{diff -e old new1}, X@samp{diff -e new1 new2}, @dots{}, @samp{diff -e newN-1 newN}, Xrespectively, then the command @samp{(cat d1 d2 @dots{} dN && echo w) | Xed - old} edits @file{old} to make it a copy of @file{newN}. X X@menu X* Detailed ed:: A detailed description of @command{ed} format. X* Example ed:: A sample @command{ed} script. X@end menu X X@node Detailed ed X@subsubsection Detailed Description of @command{ed} Format X XThe @command{ed} output format consists of one or more hunks of Xdifferences. The changes closest to the ends of the files come first so Xthat commands that change the number of lines do not affect how X@command{ed} interprets line numbers in succeeding commands. @command{ed} Xformat hunks look like this: X X@example X@var{change-command} X@var{to-file-line} X@var{to-file-line}@dots{} X. X@end example X XBecause @command{ed} uses a single period on a line to indicate the end of Xinput, @sc{gnu} @command{diff} protects lines of changes that contain a single Xperiod on a line by writing two periods instead, then writing a Xsubsequent @command{ed} command to change the two periods into one. The X@command{ed} format cannot represent an incomplete line, so if the second Xfile ends in a changed incomplete line, @command{diff} reports an error and Xthen pretends that a newline was appended. X XThere are three types of change commands. Each consists of a line Xnumber or comma-separated range of lines in the first file and a single Xcharacter indicating the kind of change to make. All line numbers are Xthe original line numbers in the file. The types of change commands Xare: X X@table @samp X@item @var{l}a XAdd text from the second file after line @var{l} in the first file. For Xexample, @samp{8a} means to add the following lines after line 8 of file X1. X X@item @var{r}c XReplace the lines in range @var{r} in the first file with the following Xlines. Like a combined add and delete, but more compact. For example, X@samp{5,7c} means change lines 5--7 of file 1 to read as the text file X2. X X@item @var{r}d XDelete the lines in range @var{r} from the first file. For example, X@samp{5,7d} means delete lines 5--7 of file 1. X@end table X X@node Example ed X@subsubsection Example @command{ed} Script X XHere is the output of @samp{diff -e lao tzu} (@pxref{Sample Xdiff Input}, for the complete contents of the two files): X X@example X11a XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X. X4c XThe named is the mother of all things. X X. X1,2d X@end example X X@node Forward ed X@subsection Forward @command{ed} Scripts X@cindex forward @command{ed} script output format X X@command{diff} can produce output that is like an @command{ed} script, but Xwith hunks in forward (front to back) order. The format of the commands Xis also changed slightly: command characters precede the lines they Xmodify, spaces separate line numbers in ranges, and no attempt is made Xto disambiguate hunk lines consisting of a single period. Like X@command{ed} format, forward @command{ed} format cannot represent incomplete Xlines. X XForward @command{ed} format is not very useful, because neither @command{ed} Xnor @command{patch} can apply diffs in this format. It exists mainly for Xcompatibility with older versions of @command{diff}. Use the @option{-f} or X@option{--forward-ed} option to select it. X X@node RCS X@subsection @sc{rcs} Scripts X@cindex @sc{rcs} script output format X XThe @sc{rcs} output format is designed specifically for use by the Revision XControl System, which is a set of free programs used for organizing Xdifferent versions and systems of files. Use the @option{-n} or X@option{--rcs} option to select this output format. It is like the Xforward @command{ed} format (@pxref{Forward ed}), but it can represent Xarbitrary changes to the contents of a file because it avoids the Xforward @command{ed} format's problems with lines consisting of a single Xperiod and with incomplete lines. Instead of ending text sections with Xa line consisting of a single period, each command specifies the number Xof lines it affects; a combination of the @samp{a} and @samp{d} Xcommands are used instead of @samp{c}. Also, if the second file ends Xin a changed incomplete line, then the output also ends in an Xincomplete line. X XHere is the output of @samp{diff -n lao tzu} (@pxref{Sample Xdiff Input}, for the complete contents of the two files): X X@example Xd1 2 Xd4 1 Xa4 2 XThe named is the mother of all things. X Xa11 3 XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X@end example X X@node If-then-else X@section Merging Files with If-then-else X@cindex merged output format X@cindex if-then-else output format X@cindex C if-then-else output format X@cindex @command{ifdef} output format X XYou can use @command{diff} to merge two files of C source code. The output Xof @command{diff} in this format contains all the lines of both files. XLines common to both files are output just once; the differing parts are Xseparated by the C preprocessor directives @code{#ifdef @var{name}} or X@code{#ifndef @var{name}}, @code{#else}, and @code{#endif}. When Xcompiling the output, you select which version to use by either defining Xor leaving undefined the macro @var{name}. X XTo merge two files, use @command{diff} with the @option{-D @var{name}} or X@option{--ifdef=@var{name}} option. The argument @var{name} is the C Xpreprocessor identifier to use in the @code{#ifdef} and @code{#ifndef} Xdirectives. X XFor example, if you change an instance of @code{wait (&s)} to X@code{waitpid (-1, &s, 0)} and then merge the old and new files with Xthe @option{--ifdef=HAVE_WAITPID} option, then the affected part of your code Xmight look like this: X X@example X do @{ X#ifndef HAVE_WAITPID X if ((w = wait (&s)) < 0 && errno != EINTR) X#else /* HAVE_WAITPID */ X if ((w = waitpid (-1, &s, 0)) < 0 && errno != EINTR) X#endif /* HAVE_WAITPID */ X return w; X @} while (w != child); X@end example X XYou can specify formats for languages other than C by using line group Xformats and line formats, as described in the next sections. X X@menu X* Line Group Formats:: Formats for general if-then-else line groups. X* Line Formats:: Formats for each line in a line group. X* Detailed If-then-else:: A detailed description of if-then-else format. X* Example If-then-else:: Sample if-then-else format output. X@end menu X X@node Line Group Formats X@subsection Line Group Formats X@cindex line group formats X@cindex formats for if-then-else line groups X XLine group formats let you specify formats suitable for many Xapplications that allow if-then-else input, including programming Xlanguages and text formatting languages. A line group format specifies Xthe output format for a contiguous group of similar lines. X XFor example, the following command compares the TeX files @file{old} Xand @file{new}, and outputs a merged file in which old regions are Xsurrounded by @samp{\begin@{em@}}-@samp{\end@{em@}} lines, and new Xregions are surrounded by @samp{\begin@{bf@}}-@samp{\end@{bf@}} lines. X X@example Xdiff \ X --old-group-format='\begin@{em@} X%<\end@{em@} X' \ X --new-group-format='\begin@{bf@} X%>\end@{bf@} X' \ X old new X@end example X XThe following command is equivalent to the above example, but it is a Xlittle more verbose, because it spells out the default line group formats. X X@example Xdiff \ X --old-group-format='\begin@{em@} X%<\end@{em@} X' \ X --new-group-format='\begin@{bf@} X%>\end@{bf@} X' \ X --unchanged-group-format='%=' \ X --changed-group-format='\begin@{em@} X%<\end@{em@} X\begin@{bf@} X%>\end@{bf@} X' \ X old new X@end example X XHere is a more advanced example, which outputs a diff listing with Xheaders containing line numbers in a ``plain English'' style. X X@example Xdiff \ X --unchanged-group-format='' \ X --old-group-format='-------- %dn line%(n=1?:s) deleted at %df: X%<' \ X --new-group-format='-------- %dN line%(N=1?:s) added after %de: X%>' \ X --changed-group-format='-------- %dn line%(n=1?:s) changed at %df: X%<-------- to: X%>' \ X old new X@end example X XTo specify a line group format, use @command{diff} with one of the options Xlisted below. You can specify up to four line group formats, one for Xeach kind of line group. You should quote @var{format}, because it Xtypically contains shell metacharacters. X X@table @option X@item --old-group-format=@var{format} XThese line groups are hunks containing only lines from the first file. XThe default old group format is the same as the changed group format if Xit is specified; otherwise it is a format that outputs the line group as-is. X X@item --new-group-format=@var{format} XThese line groups are hunks containing only lines from the second Xfile. The default new group format is same as the changed group Xformat if it is specified; otherwise it is a format that outputs the Xline group as-is. X X@item --changed-group-format=@var{format} XThese line groups are hunks containing lines from both files. The Xdefault changed group format is the concatenation of the old and new Xgroup formats. X X@item --unchanged-group-format=@var{format} XThese line groups contain lines common to both files. The default Xunchanged group format is a format that outputs the line group as-is. X@end table X XIn a line group format, ordinary characters represent themselves; Xconversion specifications start with @samp{%} and have one of the Xfollowing forms. X X@table @samp X@item %< Xstands for the lines from the first file, including the trailing newline. XEach line is formatted according to the old line format (@pxref{Line Formats}). X X@item %> Xstands for the lines from the second file, including the trailing newline. XEach line is formatted according to the new line format. X X@item %= Xstands for the lines common to both files, including the trailing newline. XEach line is formatted according to the unchanged line format. X X@item %% Xstands for @samp{%}. X X@item %c'@var{C}' Xwhere @var{C} is a single character, stands for @var{C}. X@var{C} may not be a backslash or an apostrophe. XFor example, @samp{%c':'} stands for a colon, even inside Xthe then-part of an if-then-else format, which a colon would Xnormally terminate. X X@item %c'\@var{O}' Xwhere @var{O} is a string of 1, 2, or 3 octal digits, Xstands for the character with octal code @var{O}. XFor example, @samp{%c'\0'} stands for a null character. X X@item @var{F}@var{n} Xwhere @var{F} is a @code{printf} conversion specification and @var{n} is one Xof the following letters, stands for @var{n}'s value formatted with @var{F}. X X@table @samp X@item e XThe line number of the line just before the group in the old file. X X@item f XThe line number of the first line in the group in the old file; Xequals @var{e} + 1. X X@item l XThe line number of the last line in the group in the old file. X X@item m XThe line number of the line just after the group in the old file; Xequals @var{l} + 1. X X@item n XThe number of lines in the group in the old file; equals @var{l} - @var{f} + 1. X X@item E, F, L, M, N XLikewise, for lines in the new file. X X@end table X X@vindex LC_NUMERIC XThe @code{printf} conversion specification can be @samp{%d}, X@samp{%o}, @samp{%x}, or @samp{%X}, specifying decimal, octal, Xlower case hexadecimal, or upper case hexadecimal output Xrespectively. After the @samp{%} the following options can appear in Xsequence: a series of zero or more flags; an integer Xspecifying the minimum field width; and a period followed by an Xoptional integer specifying the minimum number of digits. XThe flags are @samp{-} for left-justification, @samp{'} for separating Xthe digit into groups as specified by the @env{LC_NUMERIC} locale category, Xand @samp{0} for padding with zeros instead of spaces. XFor example, @samp{%5dN} prints the number of new lines in the group Xin a field of width 5 characters, using the @code{printf} format @code{"%5d"}. X X@item (@var{A}=@var{B}?@var{T}:@var{E}) XIf @var{A} equals @var{B} then @var{T} else @var{E}. X@var{A} and @var{B} are each either a decimal constant Xor a single letter interpreted as above. XThis format spec is equivalent to @var{T} if X@var{A}'s value equals @var{B}'s; otherwise it is equivalent to @var{E}. X XFor example, @samp{%(N=0?no:%dN) line%(N=1?:s)} is equivalent to X@samp{no lines} if @var{N} (the number of lines in the group in the the Xnew file) is 0, to @samp{1 line} if @var{N} is 1, and to @samp{%dN lines} Xotherwise. X@end table X X@node Line Formats X@subsection Line Formats X@cindex line formats X XLine formats control how each line taken from an input file is Xoutput as part of a line group in if-then-else format. X XFor example, the following command outputs text with a one-character Xchange indicator to the left of the text. The first character of output Xis @samp{-} for deleted lines, @samp{|} for added lines, and a space for Xunchanged lines. The formats contain newline characters where newlines Xare desired on output. X X@example Xdiff \ X --old-line-format='-%l X' \ X --new-line-format='|%l X' \ X --unchanged-line-format=' %l X' \ X old new X@end example X XTo specify a line format, use one of the following options. You should Xquote @var{format}, since it often contains shell metacharacters. X X@table @option X@item --old-line-format=@var{format} Xformats lines just from the first file. X X@item --new-line-format=@var{format} Xformats lines just from the second file. X X@item --unchanged-line-format=@var{format} Xformats lines common to both files. X X@item --line-format=@var{format} Xformats all lines; in effect, it sets all three above options simultaneously. X@end table X XIn a line format, ordinary characters represent themselves; Xconversion specifications start with @samp{%} and have one of the Xfollowing forms. X X@table @samp X@item %l Xstands for the contents of the line, not counting its trailing Xnewline (if any). This format ignores whether the line is incomplete; X@xref{Incomplete Lines}. X X@item %L Xstands for the contents of the line, including its trailing newline X(if any). If a line is incomplete, this format preserves its Xincompleteness. X X@item %% Xstands for @samp{%}. X X@item %c'@var{C}' Xwhere @var{C} is a single character, stands for @var{C}. X@var{C} may not be a backslash or an apostrophe. XFor example, @samp{%c':'} stands for a colon. X X@item %c'\@var{O}' Xwhere @var{O} is a string of 1, 2, or 3 octal digits, Xstands for the character with octal code @var{O}. XFor example, @samp{%c'\0'} stands for a null character. X X@item @var{F}n Xwhere @var{F} is a @code{printf} conversion specification, Xstands for the line number formatted with @var{F}. XFor example, @samp{%.5dn} prints the line number using the X@code{printf} format @code{"%.5d"}. @xref{Line Group Formats}, for Xmore about printf conversion specifications. X X@end table X XThe default line format is @samp{%l} followed by a newline character. X XIf the input contains tab characters and it is important that they line Xup on output, you should ensure that @samp{%l} or @samp{%L} in a line Xformat is just after a tab stop (e.g.@: by preceding @samp{%l} or X@samp{%L} with a tab character), or you should use the @option{-t} or X@option{--expand-tabs} option. X XTaken together, the line and line group formats let you specify many Xdifferent formats. For example, the following command uses a format Xsimilar to normal @command{diff} format. You can tailor this command Xto get fine control over @command{diff} output. X X@example Xdiff \ X --old-line-format='< %l X' \ X --new-line-format='> %l X' \ X --old-group-format='%df%(f=l?:,%dl)d%dE X%<' \ X --new-group-format='%dea%dF%(F=L?:,%dL) X%>' \ X --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL) X%<--- X%>' \ X --unchanged-group-format='' \ X old new X@end example X X@node Detailed If-then-else X@subsection Detailed Description of If-then-else Format X XFor lines common to both files, @command{diff} uses the unchanged line Xgroup format. For each hunk of differences in the merged output Xformat, if the hunk contains only lines from the first file, X@command{diff} uses the old line group format; if the hunk contains only Xlines from the second file, @command{diff} uses the new group format; Xotherwise, @command{diff} uses the changed group format. X XThe old, new, and unchanged line formats specify the output format of Xlines from the first file, lines from the second file, and lines common Xto both files, respectively. X XThe option @option{--ifdef=@var{name}} is equivalent to Xthe following sequence of options using shell syntax: X X@example X--old-group-format='#ifndef @var{name} X%<#endif /* ! @var{name} */ X' \ X--new-group-format='#ifdef @var{name} X%>#endif /* @var{name} */ X' \ X--unchanged-group-format='%=' \ X--changed-group-format='#ifndef @var{name} X%<#else /* @var{name} */ X%>#endif /* @var{name} */ X' X@end example X XYou should carefully check the @command{diff} output for proper nesting. XFor example, when using the @option{-D @var{name}} or X@option{--ifdef=@var{name}} option, you should check that if the Xdiffering lines contain any of the C preprocessor directives X@samp{#ifdef}, @samp{#ifndef}, @samp{#else}, @samp{#elif}, or X@samp{#endif}, they are nested properly and match. If they don't, you Xmust make corrections manually. It is a good idea to carefully check Xthe resulting code anyway to make sure that it really does what you Xwant it to; depending on how the input files were produced, the output Xmight contain duplicate or otherwise incorrect code. X XThe @command{patch} @option{-D @var{name}} option behaves like Xthe @command{diff} @option{-D @var{name}} option, except it operates on Xa file and a diff to produce a merged file; @xref{patch Options}. X X@node Example If-then-else X@subsection An Example of If-then-else Format X XHere is the output of @samp{diff -DTWO lao tzu} (@pxref{Sample Xdiff Input}, for the complete contents of the two files): X X@example X#ifndef TWO XThe Way that can be told of is not the eternal Way; XThe name that can be named is not the eternal name. X#endif /* ! TWO */ XThe Nameless is the origin of Heaven and Earth; X#ifndef TWO XThe Named is the mother of all things. X#else /* TWO */ XThe named is the mother of all things. X X#endif /* TWO */ XTherefore let there always be non-being, X so we may see their subtlety, XAnd let there always be being, X so we may see their outcome. XThe two are the same, XBut after they are produced, X they have different names. X#ifdef TWO XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X#endif /* TWO */ X@end example X X@node Incomplete Lines X@chapter Incomplete Lines X@cindex incomplete lines X@cindex full lines X@cindex newline treatment by @command{diff} X XWhen an input file ends in a non-newline character, its last line is Xcalled an @dfn{incomplete line} because its last character is not a Xnewline. All other lines are called @dfn{full lines} and end in a Xnewline character. Incomplete lines do not match full lines unless Xdifferences in white space are ignored (@pxref{White Space}). X XAn incomplete line is normally distinguished on output from a full line Xby a following line that starts with @samp{\}. However, the @sc{rcs} format X(@pxref{RCS}) outputs the incomplete line as-is, without any trailing Xnewline or following line. The side by side format normally represents Xincomplete lines as-is, but in some cases uses a @samp{\} or @samp{/} Xgutter marker; @xref{Side by Side}. The if-then-else line format Xpreserves a line's incompleteness with @samp{%L}, and discards the Xnewline with @samp{%l}; @xref{Line Formats}. Finally, with the X@command{ed} and forward @command{ed} output formats (@pxref{Output Formats}) X@command{diff} cannot represent an incomplete line, so it pretends there Xwas a newline and reports an error. X XFor example, suppose @file{F} and @file{G} are one-byte files that Xcontain just @samp{f} and @samp{g}, respectively. Then @samp{diff F G} Xoutputs X X@example X1c1 X< f X\ No newline at end of file X--- X> g X\ No newline at end of file X@end example X X@noindent X(The exact message may differ in non-English locales.) X@samp{diff -n F G} outputs the following without a trailing newline: X X@example Xd1 1 Xa1 1 Xg X@end example X X@noindent X@samp{diff -e F G} reports two errors and outputs the following: X X@example X1c Xg X. X@end example X X@node Comparing Directories X@chapter Comparing Directories X X@vindex LC_COLLATE XYou can use @command{diff} to compare some or all of the files in two Xdirectory trees. When both file name arguments to @command{diff} are Xdirectories, it compares each file that is contained in both Xdirectories, examining file names in alphabetical order as specified by Xthe @env{LC_COLLATE} locale category. Normally X@command{diff} is silent about pairs of files that contain no differences, Xbut if you use the @option{-s} or @option{--report-identical-files} option, Xit reports pairs of identical files. Normally @command{diff} reports Xsubdirectories common to both directories without comparing Xsubdirectories' files, but if you use the @option{-r} or X@option{--recursive} option, it compares every corresponding pair of files Xin the directory trees, as many levels deep as they go. X XFor file names that are in only one of the directories, @command{diff} Xnormally does not show the contents of the file that exists; it reports Xonly that the file exists in that directory and not in the other. You Xcan make @command{diff} act as though the file existed but was empty in the Xother directory, so that it outputs the entire contents of the file that Xactually exists. (It is output as either an insertion or a Xdeletion, depending on whether it is in the first or the second Xdirectory given.) To do this, use the @option{-N} or @option{--new-file} Xoption. X XIf the older directory contains one or more large files that are not in Xthe newer directory, you can make the patch smaller by using the X@option{--unidirectional-new-file} option instead of @option{-N}. XThis option is like @option{-N} except that it only inserts the contents Xof files that appear in the second directory but not the first (that is, Xfiles that were added). At the top of the patch, write instructions for Xthe user applying the patch to remove the files that were deleted before Xapplying the patch. @xref{Making Patches}, for more discussion of Xmaking patches for distribution. X XTo ignore some files while comparing directories, use the @option{-x X@var{pattern}} or @option{--exclude=@var{pattern}} option. This option Xignores any files or subdirectories whose base names match the shell Xpattern @var{pattern}. Unlike in the shell, a period at the start of Xthe base of a file name matches a wildcard at the start of a pattern. XYou should enclose @var{pattern} in quotes so that the shell does not Xexpand it. For example, the option @option{-x '*.[ao]'} ignores any file Xwhose name ends with @samp{.a} or @samp{.o}. X XThis option accumulates if you specify it more than once. For example, Xusing the options @option{-x 'RCS' -x '*,v'} ignores any file or Xsubdirectory whose base name is @samp{RCS} or ends with @samp{,v}. X XIf you need to give this option many times, you can instead put the Xpatterns in a file, one pattern per line, and use the @option{-X X@var{file}} or @option{--exclude-from=@var{file}} option. X XIf you have been comparing two directories and stopped partway through, Xlater you might want to continue where you left off. You can do this by Xusing the @option{-S @var{file}} or @option{--starting-file=@var{file}} Xoption. This compares only the file @var{file} and all alphabetically Xlater files in the topmost directory level. X XIf two directories differ only in that file names are lower case in Xone directory and upper case in the upper, @command{diff} normally Xreports many differences because it compares file names in a Xcase sensitive way. With the @option{--ignore-file-name-case} option, X@command{diff} ignores case differences in file names, so that for example Xthe contents of the file @file{Tao} in one directory are compared to Xthe contents of the file @file{TAO} in the other. The X@option{--no-ignore-file-name-case} option cancels the effect of the X@option{--ignore-file-name-case} option, reverting to the default Xbehavior. X XIf an @option{-x @var{pattern}}, @option{--exclude=@var{pattern}}, X@option{-X @var{file}}, or @option{--exclude-from=@var{file}} option Xis specified while the @option{--ignore-file-name-case} option is in Xeffect, case is ignored when excluding file names matching the Xspecified patterns. X X@node Adjusting Output X@chapter Making @command{diff} Output Prettier X X@command{diff} provides several ways to adjust the appearance of its output. XThese adjustments can be applied to any output format. X X@menu X* Tabs:: Preserving the alignment of tab stops. X* Pagination:: Page numbering and time-stamping @command{diff} output. X@end menu X X@node Tabs X@section Preserving Tab Stop Alignment X@cindex tab stop alignment X@cindex aligning tab stops X XThe lines of text in some of the @command{diff} output formats are preceded Xby one or two characters that indicate whether the text is inserted, Xdeleted, or changed. The addition of those characters can cause tabs to Xmove to the next tab stop, throwing off the alignment of columns in the Xline. @sc{gnu} @command{diff} provides two ways to make tab-aligned columns Xline up correctly. X XThe first way is to have @command{diff} convert all tabs into the correct Xnumber of spaces before outputting them; select this method with the X@option{-t} or @option{--expand-tabs} option. @command{diff} assumes that Xtab stops are set every 8 print columns. To use this form of output with X@command{patch}, you must give @command{patch} the @option{-l} or X@option{--ignore-white-space} option (@pxref{Changed White Space}, for more Xinformation). X XThe other method for making tabs line up correctly is to add a tab Xcharacter instead of a space after the indicator character at the Xbeginning of the line. This ensures that all following tab characters Xare in the same position relative to tab stops that they were in the Xoriginal files, so that the output is aligned correctly. Its Xdisadvantage is that it can make long lines too long to fit on one line Xof the screen or the paper. It also does not work with the unified Xoutput format, which does not have a space character after the change Xtype indicator character. Select this method with the @option{-T} or X@option{--initial-tab} option. X X@node Pagination X@section Paginating @command{diff} Output X@cindex paginating @command{diff} output X XIt can be convenient to have long output page-numbered and time-stamped. XThe @option{-l} and @option{--paginate} options do this by sending the X@command{diff} output through the @command{pr} program. Here is what the page Xheader might look like for @samp{diff -lc lao tzu}: X X@example X2002-02-22 14:20 diff -lc lao tzu Page 1 X@end example X X@node diff Performance X@chapter @command{diff} Performance Tradeoffs X@cindex performance of @command{diff} X X@sc{gnu} @command{diff} runs quite efficiently; however, in some circumstances Xyou can cause it to run faster or produce a more compact set of changes. X XOne way to improve @command{diff} performance is to use hard or Xsymbolic links to files instead of copies. This improves performance Xbecause @command{diff} normally does not need to read two hard or Xsymbolic links to the same file, since their contents must be Xidentical. For example, suppose you copy a large directory hierarchy, Xmake a few changes to the copy, and then often use @samp{diff -r} to Xcompare the original to the copy. If the original files are Xread-only, you can greatly improve performance by creating the copy Xusing hard or symbolic links (e.g., with @sc{gnu} @samp{cp -lR} or X@samp{cp -sR}). Before editing a file in the copy for the first time, Xyou should break the link and replace it with a regular copy. X XYou can also affect the performance of @sc{gnu} @command{diff} by Xgiving it options that change the way it compares files. XPerformance has more than one dimension. These options improve one Xaspect of performance at the cost of another, or they improve Xperformance in some cases while hurting it in others. X XThe way that @sc{gnu} @command{diff} determines which lines have changed always Xcomes up with a near-minimal set of differences. Usually it is good Xenough for practical purposes. If the @command{diff} output is large, you Xmight want @command{diff} to use a modified algorithm that sometimes Xproduces a smaller set of differences. The @option{-d} or X@option{--minimal} option does this; however, it can also cause X@command{diff} to run more slowly than usual, so it is not the default Xbehavior. X XWhen the files you are comparing are large and have small groups of Xchanges scattered throughout them, you can use the X@option{--speed-large-files} option to make a different modification to Xthe algorithm that @command{diff} uses. If the input files have a constant Xsmall density of changes, this option speeds up the comparisons without Xchanging the output. If not, @command{diff} might produce a larger set of Xdifferences; however, the output will still be correct. X XNormally @command{diff} discards the prefix and suffix that is common to Xboth files before it attempts to find a minimal set of differences. XThis makes @command{diff} run faster, but occasionally it may produce Xnon-minimal output. The @option{--horizon-lines=@var{lines}} option Xprevents @command{diff} from discarding the last @var{lines} lines of the Xprefix and the first @var{lines} lines of the suffix. This gives X@command{diff} further opportunities to find a minimal output. X XSuppose a run of changed lines includes a sequence of lines at one end Xand there is an identical sequence of lines just outside the other end. XThe @command{diff} command is free to choose which identical sequence is Xincluded in the hunk. In this case, @command{diff} normally shifts the Xhunk's boundaries when this merges adjacent hunks, or shifts a hunk's Xlines towards the end of the file. Merging hunks can make the output Xlook nicer in some cases. X X@node Comparing Three Files X@chapter Comparing Three Files X@cindex comparing three files X@cindex format of @command{diff3} output X XUse the program @command{diff3} to compare three files and show any Xdifferences among them. (@command{diff3} can also merge files; see X@ref{diff3 Merging}). X XThe ``normal'' @command{diff3} output format shows each hunk of Xdifferences without surrounding context. Hunks are labeled depending Xon whether they are two-way or three-way, and lines are annotated by Xtheir location in the input files. X X@xref{Invoking diff3}, for more information on how to run @command{diff3}. X X@menu X* Sample diff3 Input:: Sample @command{diff3} input for examples. X* Detailed diff3 Normal:: A detailed description of normal output format. X* diff3 Hunks:: The format of normal output format. X* Example diff3 Normal:: Sample output in the normal format. X@end menu X X@node Sample diff3 Input X@section A Third Sample Input File X@cindex @command{diff3} sample input X@cindex sample input for @command{diff3} X XHere is a third sample file that will be used in examples to illustrate Xthe output of @command{diff3} and how various options can change it. The Xfirst two files are the same that we used for @command{diff} (@pxref{Sample Xdiff Input}). This is the third sample file, called @file{tao}: X X@example XThe Way that can be told of is not the eternal Way; XThe name that can be named is not the eternal name. XThe Nameless is the origin of Heaven and Earth; XThe named is the mother of all things. X XTherefore let there always be non-being, X so we may see their subtlety, XAnd let there always be being, X so we may see their result. XThe two are the same, XBut after they are produced, X they have different names. X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X@end example X X@node Detailed diff3 Normal X@section Detailed Description of @command{diff3} Normal Format X XEach hunk begins with a line marked @samp{====}. Three-way hunks have Xplain @samp{====} lines, and two-way hunks have @samp{1}, @samp{2}, or X@samp{3} appended to specify which of the three input files differ in Xthat hunk. The hunks contain copies of two or three sets of input Xlines each preceded by one or two commands identifying where the lines Xcame from. X XNormally, two spaces precede each copy of an input line to distinguish Xit from the commands. But with the @option{-T} or @option{--initial-tab} Xoption, @command{diff3} uses a tab instead of two spaces; this lines up Xtabs correctly. @xref{Tabs}, for more information. X XCommands take the following forms: X X@table @samp X@item @var{file}:@var{l}a XThis hunk appears after line @var{l} of file @var{file}, and Xcontains no lines in that file. To edit this file to yield the other Xfiles, one must append hunk lines taken from the other files. For Xexample, @samp{1:11a} means that the hunk follows line 11 in the first Xfile and contains no lines from that file. X X@item @var{file}:@var{r}c XThis hunk contains the lines in the range @var{r} of file @var{file}. XThe range @var{r} is a comma-separated pair of line numbers, or just one Xnumber if the range is a singleton. To edit this file to yield the Xother files, one must change the specified lines to be the lines taken Xfrom the other files. For example, @samp{2:11,13c} means that the hunk Xcontains lines 11 through 13 from the second file. X@end table X XIf the last line in a set of input lines is incomplete X(@pxref{Incomplete Lines}), it is distinguished on output from a full Xline by a following line that starts with @samp{\}. X X@node diff3 Hunks X@section @command{diff3} Hunks X@cindex hunks for @command{diff3} X@cindex @command{diff3} hunks X XGroups of lines that differ in two or three of the input files are Xcalled @dfn{diff3 hunks}, by analogy with @command{diff} hunks X(@pxref{Hunks}). If all three input files differ in a @command{diff3} Xhunk, the hunk is called a @dfn{three-way hunk}; if just two input files Xdiffer, it is a @dfn{two-way hunk}. X XAs with @command{diff}, several solutions are possible. When comparing the Xfiles @samp{A}, @samp{B}, and @samp{C}, @command{diff3} normally finds X@command{diff3} hunks by merging the two-way hunks output by the two Xcommands @samp{diff A B} and @samp{diff A C}. This does not necessarily Xminimize the size of the output, but exceptions should be rare. X XFor example, suppose @file{F} contains the three lines @samp{a}, X@samp{b}, @samp{f}, @file{G} contains the lines @samp{g}, @samp{b}, X@samp{g}, and @file{H} contains the lines @samp{a}, @samp{b}, X@samp{h}. @samp{diff3 F G H} might output the following: X X@example X====2 X1:1c X3:1c X a X2:1c X g X==== X1:3c X f X2:3c X g X3:3c X h X@end example X X@noindent Xbecause it found a two-way hunk containing @samp{a} in the first and Xthird files and @samp{g} in the second file, then the single line X@samp{b} common to all three files, then a three-way hunk containing Xthe last line of each file. X X@node Example diff3 Normal X@section An Example of @command{diff3} Normal Format X XHere is the output of the command @samp{diff3 lao tzu tao} X(@pxref{Sample diff3 Input}, for the complete contents of the files). XNotice that it shows only the lines that are different among the three Xfiles. X X@example X====2 X1:1,2c X3:1,2c X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X2:0a X====1 X1:4c X The Named is the mother of all things. X2:2,3c X3:4,5c X The named is the mother of all things. X X====3 X1:8c X2:7c X so we may see their outcome. X3:9c X so we may see their result. X==== X1:11a X2:11,13c X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X3:13,14c X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X@end example X X@node diff3 Merging X@chapter Merging From a Common Ancestor X@cindex merging from a common ancestor X XWhen two people have made changes to copies of the same file, X@command{diff3} can produce a merged output that contains both sets of Xchanges together with warnings about conflicts. X XOne might imagine programs with names like @command{diff4} and @command{diff5} Xto compare more than three files simultaneously, but in practice the Xneed rarely arises. You can use @command{diff3} to merge three or more Xsets of changes to a file by merging two change sets at a time. X X@command{diff3} can incorporate changes from two modified versions into a Xcommon preceding version. This lets you merge the sets of changes Xrepresented by the two newer files. Specify the common ancestor version Xas the second argument and the two newer versions as the first and third Xarguments, like this: X X@example Xdiff3 @var{mine} @var{older} @var{yours} X@end example X X@noindent XYou can remember the order of the arguments by noting that they are in Xalphabetical order. X X@cindex conflict X@cindex overlap XYou can think of this as subtracting @var{older} from @var{yours} and Xadding the result to @var{mine}, or as merging into @var{mine} the Xchanges that would turn @var{older} into @var{yours}. This merging is Xwell-defined as long as @var{mine} and @var{older} match in the Xneighborhood of each such change. This fails to be true when all three Xinput files differ or when only @var{older} differs; we call this Xa @dfn{conflict}. When all three input files differ, we call the Xconflict an @dfn{overlap}. X X@command{diff3} gives you several ways to handle overlaps and conflicts. XYou can omit overlaps or conflicts, or select only overlaps, Xor mark conflicts with special @samp{<<<<<<<} and @samp{>>>>>>>} lines. X X@command{diff3} can output the merge results as an @command{ed} script that Xthat can be applied to the first file to yield the merged output. XHowever, it is usually better to have @command{diff3} generate the merged Xoutput directly; this bypasses some problems with @command{ed}. X X@menu X* Which Changes:: Selecting changes to incorporate. X* Marking Conflicts:: Marking conflicts. X* Bypassing ed:: Generating merged output directly. X* Merging Incomplete Lines:: How @command{diff3} merges incomplete lines. X* Saving the Changed File:: Emulating System V behavior. X@end menu X X@node Which Changes X@section Selecting Which Changes to Incorporate X@cindex overlapping change, selection of X@cindex unmerged change X XYou can select all unmerged changes from @var{older} to @var{yours} for merging Xinto @var{mine} with the @option{-e} or @option{--ed} option. You can Xselect only the nonoverlapping unmerged changes with @option{-3} or X@option{--easy-only}, and you can select only the overlapping changes with X@option{-x} or @option{--overlap-only}. X XThe @option{-e}, @option{-3} and @option{-x} options select only X@dfn{unmerged changes}, i.e.@: changes where @var{mine} and @var{yours} Xdiffer; they ignore changes from @var{older} to @var{yours} where X@var{mine} and @var{yours} are identical, because they assume that such Xchanges have already been merged. If this assumption is not a safe Xone, you can use the @option{-A} or @option{--show-all} option X(@pxref{Marking Conflicts}). X XHere is the output of the command @command{diff3} with each of these three Xoptions (@pxref{Sample diff3 Input}, for the complete contents of the files). XNotice that @option{-e} outputs the union of the disjoint sets of changes Xoutput by @option{-3} and @option{-x}. X XOutput of @samp{diff3 -e lao tzu tao}: X@example X11a X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X. X8c X so we may see their result. X. X@end example X XOutput of @samp{diff3 -3 lao tzu tao}: X@example X8c X so we may see their result. X. X@end example X XOutput of @samp{diff3 -x lao tzu tao}: X@example X11a X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X. X@end example X X@node Marking Conflicts X@section Marking Conflicts X@cindex conflict marking X@cindex @samp{<<<<<<<} for marking conflicts X X@command{diff3} can mark conflicts in the merged output by Xbracketing them with special marker lines. A conflict Xthat comes from two files @var{A} and @var{B} is marked as follows: X X@example X<<<<<<< @var{A} X@r{lines from @var{A}} X======= X@r{lines from @var{B}} X>>>>>>> @var{B} X@end example X XA conflict that comes from three files @var{A}, @var{B} and @var{C} is Xmarked as follows: X X@example X<<<<<<< @var{A} X@r{lines from @var{A}} X||||||| @var{B} X@r{lines from @var{B}} X======= X@r{lines from @var{C}} X>>>>>>> @var{C} X@end example X XThe @option{-A} or @option{--show-all} option acts like the @option{-e} Xoption, except that it brackets conflicts, and it outputs all changes Xfrom @var{older} to @var{yours}, not just the unmerged changes. Thus, Xgiven the sample input files (@pxref{Sample diff3 Input}), @samp{diff3 X-A lao tzu tao} puts brackets around the conflict where only @file{tzu} Xdiffers: X X@example X<<<<<<< tzu X======= XThe Way that can be told of is not the eternal Way; XThe name that can be named is not the eternal name. X>>>>>>> tao X@end example X XAnd it outputs the three-way conflict as follows: X X@example X<<<<<<< lao X||||||| tzu XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X>>>>>>> tao X@end example X XThe @option{-E} or @option{--show-overlap} option outputs less information Xthan the @option{-A} or @option{--show-all} option, because it outputs only Xunmerged changes, and it never outputs the contents of the second Xfile. Thus the @option{-E} option acts like the @option{-e} option, Xexcept that it brackets the first and third files from three-way Xoverlapping changes. Similarly, @option{-X} acts like @option{-x}, except Xit brackets all its (necessarily overlapping) changes. For example, Xfor the three-way overlapping change above, the @option{-E} and @option{-X} Xoptions output the following: X X@example X<<<<<<< lao X======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X>>>>>>> tao X@end example X XIf you are comparing files that have meaningless or uninformative names, Xyou can use the @option{-L @var{label}} or @option{--label=@var{label}} Xoption to show alternate names in the @samp{<<<<<<<}, @samp{|||||||} Xand @samp{>>>>>>>} brackets. This option can be given up to three Xtimes, once for each input file. Thus @samp{diff3 -A -L X -L Y -L Z A XB C} acts like @samp{diff3 -A A B C}, except that the output looks like Xit came from files named @samp{X}, @samp{Y} and @samp{Z} rather than Xfrom files named @samp{A}, @samp{B} and @samp{C}. X X@node Bypassing ed X@section Generating the Merged Output Directly X@cindex merged @command{diff3} format X XWith the @option{-m} or @option{--merge} option, @command{diff3} outputs the Xmerged file directly. This is more efficient than using @command{ed} to Xgenerate it, and works even with non-text files that @command{ed} would Xreject. If you specify @option{-m} without an @command{ed} script option, X@option{-A} (@option{--show-all}) is assumed. X XFor example, the command @samp{diff3 -m lao tzu tao} X(@pxref{Sample diff3 Input} for a copy of the input files) would output Xthe following: X X@example X<<<<<<< tzu X======= XThe Way that can be told of is not the eternal Way; XThe name that can be named is not the eternal name. X>>>>>>> tao XThe Nameless is the origin of Heaven and Earth; XThe Named is the mother of all things. XTherefore let there always be non-being, X so we may see their subtlety, XAnd let there always be being, X so we may see their result. XThe two are the same, XBut after they are produced, X they have different names. X<<<<<<< lao X||||||| tzu XThey both may be called deep and profound. XDeeper and more profound, XThe door of all subtleties! X======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X>>>>>>> tao X@end example X X@node Merging Incomplete Lines X@section How @command{diff3} Merges Incomplete Lines X@cindex incomplete line merging X XWith @option{-m}, incomplete lines (@pxref{Incomplete Lines}) are simply Xcopied to the output as they are found; if the merged output ends in an Xconflict and one of the input files ends in an incomplete Xline, succeeding @samp{|||||||}, @samp{=======} or @samp{>>>>>>>} Xbrackets appear somewhere other than the start of a line because Xthey are appended to the incomplete line. X XWithout @option{-m}, if an @command{ed} script option is specified and an Xincomplete line is found, @command{diff3} generates a warning and acts as Xif a newline had been present. X X@node Saving the Changed File X@section Saving the Changed File X@cindex System V @command{diff3} compatibility X XTraditional Unix @command{diff3} generates an @command{ed} script without the Xtrailing @samp{w} and @samp{q} commands that save the changes. XSystem V @command{diff3} generates these extra commands. @sc{gnu} X@command{diff3} normally behaves like traditional Unix X@command{diff3}, but with the @option{-i} option it behaves like XSystem V @command{diff3} and appends the @samp{w} and @samp{q} Xcommands. X XThe @option{-i} option requires one of the @command{ed} script options X@option{-AeExX3}, and is incompatible with the merged output option X@option{-m}. X X@node Interactive Merging X@chapter Interactive Merging with @command{sdiff} X@cindex diff merging X@cindex interactive merging X XWith @command{sdiff}, you can merge two files interactively based on a Xside-by-side @option{-y} format comparison (@pxref{Side by Side}). Use X@option{-o @var{file}} or @option{--output=@var{file}} to specify where to Xput the merged text. @xref{Invoking sdiff}, for more details on the Xoptions to @command{sdiff}. X XAnother way to merge files interactively is to use the Emacs Lisp Xpackage @command{emerge}. @xref{emerge, , emerge, emacs, The @sc{gnu} Emacs XManual}, for more information. X X@menu X* sdiff Option Summary:: Summary of @command{sdiff} options. X* Merge Commands:: Merging two files interactively. X@end menu X X@node sdiff Option Summary X@section Specifying @command{diff} Options to @command{sdiff} X@cindex @command{sdiff} output format X XThe following @command{sdiff} options have the same meaning as for X@command{diff}. @xref{diff Options}, for the use of these options. X X@example X-a -b -d -i -t -v X-B -E -I @var{regexp} X X--ignore-blank-lines --ignore-case X--ignore-matching-lines=@var{regexp} --ignore-space-change X--ignore-tab-expansion X--left-column --minimal --speed-large-files X--strip-trailing-cr --suppress-common-lines --expand-tabs X--text --version --width=@var{columns} X@end example X XFor historical reasons, @command{sdiff} has alternate names for some Xoptions. The @option{-l} option is equivalent to the X@option{--left-column} option, and similarly @option{-s} is equivalent Xto @option{--suppress-common-lines}. The meaning of the @command{sdiff} X@option{-w} and @option{-W} options is interchanged from that of X@command{diff}: with @command{sdiff}, @option{-w @var{columns}} is Xequivalent to @option{--width=@var{columns}}, and @option{-W} is Xequivalent to @option{--ignore-all-space}. @command{sdiff} without the X@option{-o} option is equivalent to @command{diff} with the @option{-y} Xor @option{--side-by-side} option (@pxref{Side by Side}). X X@node Merge Commands X@section Merge Commands X@cindex merge commands X@cindex merging interactively X XGroups of common lines, with a blank gutter, are copied from the first Xfile to the output. After each group of differing lines, @command{sdiff} Xprompts with @samp{%} and pauses, waiting for one of the following Xcommands. Follow each command with @key{RET}. X X@table @samp X@item e XDiscard both versions. XInvoke a text editor on an empty temporary file, Xthen copy the resulting file to the output. X X@item eb XConcatenate the two versions, edit the result in a temporary file, Xthen copy the edited result to the output. X X@item ed XLike @samp{eb}, except precede each version with a header that Xshows what file and lines the version came from. X X@item el XEdit a copy of the left version, then copy the result to the output. X X@item er XEdit a copy of the right version, then copy the result to the output. X X@item l XCopy the left version to the output. X X@item q XQuit. X X@item r XCopy the right version to the output. X X@item s XSilently copy common lines. X X@item v XVerbosely copy common lines. This is the default. X@end table X X@vindex EDITOR XThe text editor invoked is specified by the @env{EDITOR} environment Xvariable if it is set. The default is system-dependent. X X@node Merging with patch X@chapter Merging with @command{patch} X X@command{patch} takes comparison output produced by @command{diff} and applies Xthe differences to a copy of the original file, producing a patched Xversion. With @command{patch}, you can distribute just the changes to a Xset of files instead of distributing the entire file set; your Xcorrespondents can apply @command{patch} to update their copy of the files Xwith your changes. @command{patch} automatically determines the diff Xformat, skips any leading or trailing headers, and uses the headers to Xdetermine which file to patch. This lets your correspondents feed a Xmail message containing a difference listing directly to X@command{patch}. X X@command{patch} detects and warns about common problems like forward Xpatches. It saves any patches that it could not apply. It can also maintain a X@code{patchlevel.h} file to ensure that your correspondents apply Xdiffs in the proper order. X X@command{patch} accepts a series of diffs in its standard input, usually Xseparated by headers that specify which file to patch. It applies X@command{diff} hunks (@pxref{Hunks}) one by one. If a hunk does not Xexactly match the original file, @command{patch} uses heuristics to try to Xpatch the file as well as it can. If no approximate match can be found, X@command{patch} rejects the hunk and skips to the next hunk. @command{patch} Xnormally replaces each file @var{f} with its new version, putting reject Xhunks (if any) into @samp{@var{f}.rej}. X X@xref{Invoking patch}, for detailed information on the options to X@command{patch}. X X@menu X* patch Input:: Selecting the type of @command{patch} input. X* Revision Control:: Getting files from @sc{rcs}, @sc{sccs}, etc. X* Imperfect:: Dealing with imperfect patches. X* Creating and Removing:: Creating and removing files with a patch. X* Patching Time Stamps:: Updating time stamps on patched files. X* Multiple Patches:: Handling multiple patches in a file. X* patch Directories:: Changing directory and stripping directories. X* Backups:: Whether backup files are made. X* Backup Names:: Backup file names. X* Reject Names:: Reject file names. X* patch Messages:: Messages and questions @command{patch} can produce. X* patch and POSIX:: Conformance to the @sc{posix} standard. X* patch and Tradition:: @sc{gnu} versus traditional @command{patch}. X@end menu X X@node patch Input X@section Selecting the @command{patch} Input Format X@cindex @command{patch} input format X X@command{patch} normally determines which @command{diff} format the patch Xfile uses by examining its contents. For patch files that contain Xparticularly confusing leading text, you might need to use one of the Xfollowing options to force @command{patch} to interpret the patch file as a Xcertain format of diff. The output formats listed here are the only Xones that @command{patch} can understand. X X@table @option X@item -c X@itemx --context Xcontext diff. X X@item -e X@itemx --ed X@command{ed} script. X X@item -n X@itemx --normal Xnormal diff. X X@item -u X@itemx --unified Xunified diff. X@end table X X@node Revision Control X@section Revision Control X@cindex revision control X@cindex version control X@cindex @sc{rcs} X@cindex ClearCase X@cindex @sc{sccs} X XIf a nonexistent input file is under a revision control system Xsupported by @command{patch}, @command{patch} normally asks the user Xwhether to get (or check out) the file from the revision control Xsystem. Patch currently supports @sc{rcs}, ClearCase and @sc{sccs}. XUnder @sc{rcs} and @sc{sccs}, @command{patch} also asks when the input Xfile is read-only and matches the default version in the revision Xcontrol system. X X@vindex PATCH_GET XThe @option{-g @var{num}} or @option{--get=@var{num}} affects access Xto files under supported revision control systems. If @var{num} is Xpositive, @command{patch} gets the file without asking the user; if Xzero, @command{patch} neither asks the user nor gets the file; and if Xnegative, @command{patch} asks the user before getting the file. The Xdefault value of @var{num} is given by the value of the X@env{PATCH_GET} environment variable if it is set; if not, the default Xvalue is zero if @command{patch} is conforming to @sc{posix}, negative Xotherwise. @xref{patch and POSIX}. X X@vindex VERSION_CONTROL XThe choice of revision control system is unaffected by the X@env{VERSION_CONTROL} environment variable (@pxref{Backup Names}). X X@node Imperfect X@section Applying Imperfect Patches X@cindex imperfect patch application X X@command{patch} tries to skip any leading text in the patch file, Xapply the diff, and then skip any trailing text. Thus you can feed a Xmail message directly to @command{patch}, and it should work. If the Xentire diff is indented by a constant amount of white space, X@command{patch} automatically ignores the indentation. If a context Xdiff contains trailing carriage return on each line, @command{patch} Xautomatically ignores the carriage return. If a context diff has been Xencapsulated by prepending @w{@samp{- }} to lines beginning with @samp{-} Xas per @uref{ftp://ftp.isi.edu/in-notes/rfc934.txt, Internet RFC 934}, X@command{patch} automatically unencapsulates the input. X XHowever, certain other types of imperfect input require user Xintervention or testing. X X@menu X* Changed White Space:: When tabs and spaces don't match exactly. X* Reversed Patches:: Applying reversed patches correctly. X* Inexact:: Helping @command{patch} find close matches. X* Dry Runs:: Predicting what @command{patch} will do. X@end menu X X@node Changed White Space X@subsection Applying Patches with Changed White Space X@cindex white space in patches X XSometimes mailers, editors, or other programs change spaces into tabs, Xor vice versa. If this happens to a patch file or an input file, the Xfiles might look the same, but @command{patch} will not be able to match Xthem properly. If this problem occurs, use the @option{-l} or X@option{--ignore-white-space} option, which makes @command{patch} compare Xblank characters (i.e.@: spaces and tabs) loosely so that any nonempty Xsequence of blanks in the patch file matches any nonempty sequence of Xblanks in the input files. Non-blank Xcharacters must still match exactly. Each line of the context must Xstill match a line in the input file. X X@node Reversed Patches X@subsection Applying Reversed Patches X@cindex reversed patches X XSometimes people run @command{diff} with the new file first instead of Xsecond. This creates a diff that is ``reversed''. To apply such Xpatches, give @command{patch} the @option{-R} or @option{--reverse} option. X@command{patch} then attempts to swap each hunk around before applying it. XRejects come out in the swapped format. X XOften @command{patch} can guess that the patch is reversed. If the first Xhunk of a patch fails, @command{patch} reverses the hunk to see if it can Xapply it that way. If it can, @command{patch} asks you if you want to have Xthe @option{-R} option set; if it can't, @command{patch} continues to apply Xthe patch normally. This method cannot detect a reversed patch if it is Xa normal diff and the first command is an append (which should have been Xa delete) since appends always succeed, because a null context matches Xanywhere. But most patches add or change lines rather than delete them, Xso most reversed normal diffs begin with a delete, which fails, and X@command{patch} notices. X XIf you apply a patch that you have already applied, @command{patch} thinks Xit is a reversed patch and offers to un-apply the patch. This could be Xconstrued as a feature. If you did this inadvertently and you don't Xwant to un-apply the patch, just answer @samp{n} to this offer and to Xthe subsequent ``apply anyway'' question---or type @kbd{C-c} to kill the X@command{patch} process. X X@node Inexact X@subsection Helping @command{patch} Find Inexact Matches X@cindex inexact patches X@cindex fuzz factor when patching X XFor context diffs, and to a lesser extent normal diffs, @command{patch} can Xdetect when the line numbers mentioned in the patch are incorrect, and Xit attempts to find the correct place to apply each hunk of the patch. XAs a first guess, it takes the line number mentioned in the hunk, plus Xor minus any offset used in applying the previous hunk. If that is not Xthe correct place, @command{patch} scans both forward and backward for a Xset of lines matching the context given in the hunk. X XFirst @command{patch} looks for a place where all lines of the context Xmatch. If it cannot find such a place, and it is reading a context or Xunified diff, and the maximum fuzz factor is set to 1 or more, then X@command{patch} makes another scan, ignoring the first and last line of Xcontext. If that fails, and the maximum fuzz factor is set to 2 or Xmore, it makes another scan, ignoring the first two and last two lines Xof context are ignored. It continues similarly if the maximum fuzz Xfactor is larger. X XThe @option{-F @var{lines}} or @option{--fuzz=@var{lines}} option sets the Xmaximum fuzz factor to @var{lines}. This option only applies to context Xand unified diffs; it ignores up to @var{lines} lines while looking for Xthe place to install a hunk. Note that a larger fuzz factor increases Xthe odds of making a faulty patch. The default fuzz factor is 2; there Xis no point to setting it to more than the number of lines of context Xin the diff, ordinarily 3. X XIf @command{patch} cannot find a place to install a hunk of the patch, it Xwrites the hunk out to a reject file (@pxref{Reject Names}, for information Xon how reject files are named). It writes out rejected hunks in context Xformat no matter what form the input patch is in. If the input is a Xnormal or @command{ed} diff, many of the contexts are simply null. The Xline numbers on the hunks in the reject file may be different from those Xin the patch file: they show the approximate location where @command{patch} Xthinks the failed hunks belong in the new file rather than in the old Xone. X XIf the @option{--verbose} option is given, then Xas it completes each hunk @command{patch} tells you whether the hunk Xsucceeded or failed, and if it failed, on which line (in the new file) X@command{patch} thinks the hunk should go. If this is different from the Xline number specified in the diff, it tells you the offset. A single Xlarge offset @emph{may} indicate that @command{patch} installed a hunk in Xthe wrong place. @command{patch} also tells you if it used a fuzz factor Xto make the match, in which case you should also be slightly suspicious. X X@command{patch} cannot tell if the line numbers are off in an @command{ed} Xscript, and can only detect wrong line numbers in a normal diff when it Xfinds a change or delete command. It may have the same problem with a Xcontext diff using a fuzz factor equal to or greater than the number of Xlines of context shown in the diff (typically 3). In these cases, you Xshould probably look at a context diff between your original and patched Xinput files to see if the changes make sense. Compiling without errors Xis a pretty good indication that the patch worked, but not a guarantee. X XA patch against an empty file applies to a nonexistent file, and vice Xversa. @xref{Creating and Removing}. X X@command{patch} usually produces the correct results, even when it must Xmake many guesses. However, the results are guaranteed only when Xthe patch is applied to an exact copy of the file that the patch was Xgenerated from. X X@node Dry Runs X@subsection Predicting what @command{patch} will do X@cindex testing @command{patch} X@cindex dry runs for @command{patch} X XIt may not be obvious in advance what @command{patch} will do with a Xcomplicated or poorly formatted patch. If you are concerned that the Xinput might cause @command{patch} to modify the wrong files, you can Xuse the @option{--dry-run} option, which causes @command{patch} to Xprint the results of applying patches without actually changing any Xfiles. You can then inspect the diagnostics generated by the dry run Xto see whether @command{patch} will modify the files that you expect. XIf the patch does not do what you want, you can modify the patch (or Xthe other options to @command{patch}) and try another dry run. Once Xyou are satisfied with the proposed patch you can apply it by invoking X@command{patch} as before, but this time without the X@option{--dry-run} option. X X@node Creating and Removing X@section Creating and Removing Files X@cindex creating files X@cindex empty files, removing X@cindex removing empty files X XSometimes when comparing two directories, a file may exist in one Xdirectory but not the other. If you give @command{diff} the X@option{-N} or @option{--new-file} option, or if you supply an old or Xnew file that is named @file{/dev/null} or is empty and is dated the XEpoch (1970-01-01 00:00:00 UTC), @command{diff} outputs a patch that Xadds or deletes the contents of this file. When given such a patch, X@command{patch} normally creates a new file or removes the old file. XHowever, when conforming to @sc{posix} (@pxref{patch and POSIX}), X@command{patch} does not remove the old file, but leaves it empty. XThe @option{-E} or @option{--remove-empty-files} option causes X@command{patch} to remove output files that are empty after applying a Xpatch, even if the patch does not appear to be one that removed the Xfile. X XIf the patch appears to create a file that already exists, X@command{patch} asks for confirmation before applying the patch. X X@node Patching Time Stamps X@section Updating Time Stamps on Patched Files X@cindex time stamps on patched files X XWhen @command{patch} updates a file, it normally sets the file's Xlast-modified time stamp to the current time of day. If you are using X@command{patch} to track a software distribution, this can cause X@command{make} to incorrectly conclude that a patched file is out of Xdate. For example, if @file{syntax.c} depends on @file{syntax.y}, and X@command{patch} updates @file{syntax.c} and then @file{syntax.y}, then X@file{syntax.c} will normally appear to be out of date with respect to X@file{syntax.y} even though its contents are actually up to date. X XThe @option{-Z} or @option{--set-utc} option causes @command{patch} to Xset a patched file's modification and access times to the time stamps Xgiven in context diff headers. If the context diff headers do not Xspecify a time zone, they are assumed to use Coordinated Universal XTime (@sc{utc}, often known as @sc{gmt}). X XThe @option{-T} or @option{--set-time} option acts like @option{-Z} or X@option{--set-utc}, except that it assumes that the context diff Xheaders' time stamps use local time instead of @sc{utc}. This option Xis not recommended, because patches using local time cannot easily be Xused by people in other time zones, and because local time stamps are Xambiguous when local clocks move backwards during daylight-saving time Xadjustments. If the context diff headers specify a time zone, this Xoption is equivalent to @option{-Z} or @option{--set-utc}. X X@command{patch} normally refrains from setting a file's time stamps if Xthe file's original last-modified time stamp does not match the time Xgiven in the diff header, of if the file's contents do not exactly Xmatch the patch. However, if the @option{-f} or @option{--force} Xoption is given, the file's time stamps are set regardless. X XDue to the limitations of the current @command{diff} format, X@command{patch} cannot update the times of files whose contents have Xnot changed. Also, if you set file time stamps to values other than Xthe current time of day, you should also remove (e.g., with @samp{make Xclean}) all files that depend on the patched files, so that later Xinvocations of @command{make} do not get confused by the patched Xfiles' times. X X@node Multiple Patches X@section Multiple Patches in a File X@cindex multiple patches X@cindex intuiting file names from patches X XIf the patch file contains more than one patch, and if you do not Xspecify an input file on the command line, @command{patch} tries to Xapply each patch as if they came from separate patch files. This Xmeans that it determines the name of the file to patch for each patch, Xand that it examines the leading text before each patch for file names Xand prerequisite revision level (@pxref{Making Patches}, for more on Xthat topic). X X@command{patch} uses the following rules to intuit a file name from Xthe leading text before a patch. First, @command{patch} takes an Xordered list of candidate file names as follows: X X@itemize @bullet X@item XIf the header is that of a context diff, @command{patch} takes the old Xand new file names in the header. A name is ignored if it does not Xhave enough slashes to satisfy the @option{-p@var{num}} or X@option{--strip=@var{num}} option. The name @file{/dev/null} is also Xignored. X X@item XIf there is an @samp{Index:} line in the leading garbage and if either Xthe old and new names are both absent or if @command{patch} is Xconforming to @sc{posix}, @command{patch} takes the name in the X@samp{Index:} line. X X@item XFor the purpose of the following rules, the candidate file names are Xconsidered to be in the order (old, new, index), regardless of the Xorder that they appear in the header. X@end itemize X X@noindent XThen @command{patch} selects a file name from the candidate list as Xfollows: X X@itemize @bullet X@item XIf some of the named files exist, @command{patch} selects the first Xname if conforming to @sc{posix}, and the best name otherwise. X X@item XIf @command{patch} is not ignoring @sc{rcs}, ClearCase, and @sc{sccs} X(@pxref{Revision Control}), and no named files exist but an @sc{rcs}, XClearCase, or @sc{sccs} master is found, @command{patch} selects the Xfirst named file with an @sc{rcs}, ClearCase, or @sc{sccs} master. X X@item XIf no named files exist, no @sc{rcs}, ClearCase, or @sc{sccs} master Xwas found, some names are given, @command{patch} is not conforming to X@sc{posix}, and the patch appears to create a file, @command{patch} Xselects the best name requiring the creation of the fewest Xdirectories. X X@item XIf no file name results from the above heuristics, you are asked for Xthe name of the file to patch, and @command{patch} selects that name. X@end itemize X XTo determine the @dfn{best} of a nonempty list of file names, X@command{patch} first takes all the names with the fewest path name Xcomponents; of those, it then takes all the names with the shortest Xbasename; of those, it then takes all the shortest names; finally, it Xtakes the first remaining name. X X@xref{patch and POSIX}, to see whether @command{patch} is conforming Xto @sc{posix}. X X@node patch Directories X@section Applying Patches in Other Directories X@cindex directories and patch X@cindex patching directories X XThe @option{-d @var{directory}} or @option{--directory=@var{directory}} Xoption to @command{patch} makes directory @var{directory} the current Xdirectory for interpreting both file names in the patch file, and file Xnames given as arguments to other options (such as @option{-B} and X@option{-o}). For example, while in a mail reading program, you can patch Xa file in the @file{/usr/src/emacs} directory directly from a message Xcontaining the patch like this: X X@example X| patch -d /usr/src/emacs X@end example X XSometimes the file names given in a patch contain leading directories, Xbut you keep your files in a directory different from the one given in Xthe patch. In those cases, you can use the X@option{-p@var{number}} or @option{--strip=@var{number}} Xoption to set the file name strip count to @var{number}. The strip Xcount tells @command{patch} how many slashes, along with the directory Xnames between them, to strip from the front of file names. A sequence Xof one or more adjacent slashes is counted as a single slash. By Xdefault, @command{patch} strips off all leading directories, leaving Xjust the base file names. X XFor example, suppose the file name in the patch file is X@file{/gnu/src/emacs/etc/NEWS}. Using @option{-p0} gives the Xentire file name unmodified, @option{-p1} gives X@file{gnu/src/emacs/etc/NEWS} (no leading slash), @option{-p4} gives X@file{etc/NEWS}, and not specifying @option{-p} at all gives @file{NEWS}. X X@command{patch} looks for each file (after any slashes have been stripped) Xin the current directory, or if you used the @option{-d @var{directory}} Xoption, in that directory. X X@node Backups X@section Backup Files X@cindex backup file strategy X XNormally, @command{patch} creates a backup file if the patch does not Xexactly match the original input file, because in that case the Xoriginal data might not be recovered if you undo the patch with X@samp{patch -R} (@pxref{Reversed Patches}). However, when conforming Xto @sc{posix}, @command{patch} does not create backup files by Xdefault. @xref{patch and POSIX}. X XThe @option{-b} or @option{--backup} option causes @command{patch} to Xmake a backup file regardless of whether the patch matches the Xoriginal input. The @option{--backup-if-mismatch} option causes X@command{patch} to create backup files for mismatches files; this is Xthe default when not conforming to @sc{posix}. The X@option{--no-backup-if-mismatch} option causes @command{patch} to not Xcreate backup files, even for mismatched patches; this is the default Xwhen conforming to @sc{posix}. X XWhen backing up a file that does not exist, an empty, unreadable Xbackup file is created as a placeholder to represent the nonexistent Xfile. X X@node Backup Names X@section Backup File Names X@cindex backup file names X XNormally, @command{patch} renames an original input file into a backup Xfile by appending to its name the extension @samp{.orig}, or @samp{~} Xif using @samp{.orig} would make the backup file name too Xlong.@footnote{A coding error in @sc{gnu} @command{patch} version X2.5.4 causes it to always use @samp{~}, but this should be fixed in Xthe next release.} The @option{-z @var{backup-suffix}} or X@option{--suffix=@var{backup-suffix}} option causes @command{patch} to Xuse @var{backup-suffix} as the backup extension instead. X X@vindex SIMPLE_BACKUP_SUFFIX XAlternately, you can specify the extension for backup files with the X@env{SIMPLE_BACKUP_SUFFIX} environment variable, which the options Xoverride. X X@command{patch} can also create numbered backup files the way @sc{gnu} Emacs Xdoes. With this method, instead of having a single backup of each file, X@command{patch} makes a new backup file name each time it patches a file. XFor example, the backups of a file named @file{sink} would be called, Xsuccessively, @file{sink.~1~}, @file{sink.~2~}, @file{sink.~3~}, etc. X X@vindex PATCH_VERSION_CONTROL X@vindex VERSION_CONTROL XThe @option{-V @var{backup-style}} or X@option{--version-control=@var{backup-style}} option takes as an Xargument a method for creating backup file names. You can alternately Xcontrol the type of backups that @command{patch} makes with the X@env{PATCH_VERSION_CONTROL} environment variable, which the X@option{-V} option overrides. If @env{PATCH_VERSION_CONTROL} is not Xset, the @env{VERSION_CONTROL} environment variable is used instead. XPlease note that these options and variables control backup file Xnames; they do not affect the choice of revision control system X(@pxref{Revision Control}). X XThe values of these environment variables and the argument to the X@option{-V} option are like the @sc{gnu} Emacs @code{version-control} Xvariable (@pxref{Backup Names, , , emacs, The @sc{gnu} Emacs Manual}, Xfor more information on backup versions in Emacs). They also Xrecognize synonyms that are more descriptive. The valid values are Xlisted below; unique abbreviations are acceptable. X X@table @option X@item t X@itemx numbered XAlways make numbered backups. X X@item nil X@itemx existing XMake numbered backups of files that already have them, simple backups of Xthe others. This is the default. X X@item never X@itemx simple XAlways make simple backups. X@end table X XYou can also tell @command{patch} to prepend a prefix, such as a Xdirectory name, to produce backup file names. The @option{-B X@var{prefix}} or @option{--prefix=@var{prefix}} option makes backup Xfiles by prepending @var{prefix} to them. The @option{-Y X@var{prefix}} or @option{--basename-prefix=@var{prefix}} prepends X@var{prefix} to the last file name component of backup file names Xinstead; for example, @option{-Y ~} causes the backup name for X@file{dir/file.c} to be @file{dir/~file.c}. If you use either of Xthese prefix options, the suffix-based options are ignored. X XIf you specify the output file with the @option{-o} option, that file is Xthe one that is backed up, not the input file. X XOptions that affect the names of backup files do not affect whether Xbackups are made. For example, if you specify the X@option{--no-backup-if-mismatch} option, none of the options described Xin this section have any affect, because no backups are made. X X@node Reject Names X@section Reject File Names X@cindex reject file names X XThe names for reject files (files containing patches that X@command{patch} could not find a place to apply) are normally the name Xof the output file with @samp{.rej} appended (or @samp{#} if if using X@samp{.rej} would make the backup file name too long). X XAlternatively, you can tell @command{patch} to place all of the rejected Xpatches in a single file. The @option{-r @var{reject-file}} or X@option{--reject-file=@var{reject-file}} option uses @var{reject-file} as Xthe reject file name. X X@node patch Messages X@section Messages and Questions from @command{patch} X@cindex @command{patch} messages and questions X@cindex diagnostics from @command{patch} X@cindex messages from @command{patch} X X@command{patch} can produce a variety of messages, especially if it Xhas trouble decoding its input. In a few situations where it's not Xsure how to proceed, @command{patch} normally prompts you for more Xinformation from the keyboard. There are options to produce more or Xfewer messages, to have it not ask for keyboard input, and to Xaffect the way that file names are quoted in messages. X X@menu X* More or Fewer Messages:: Controlling the verbosity of @command{patch}. X* patch and Keyboard Input:: Inhibiting keyboard input. X* patch Quoting Style:: Quoting file names in diagnostics. X@end menu X X@command{patch} exits with status 0 if all hunks are applied successfully, X1 if some hunks cannot be applied, and 2 if there is more serious trouble. XWhen applying a set of patches in a loop, you should check the Xexit status, so you don't apply a later patch to a partially patched Xfile. X X@node More or Fewer Messages X@subsection Controlling the Verbosity of @command{patch} X@cindex verbose messages from @command{patch} X@cindex inhibit messages from @command{patch} X XYou can cause @command{patch} to produce more messages by using the X@option{--verbose} option. For example, when you give this option, Xthe message @samp{Hmm...} indicates that @command{patch} is reading text in Xthe patch file, attempting to determine whether there is a patch in that Xtext, and if so, what kind of patch it is. X XYou can inhibit all terminal output from @command{patch}, unless an error Xoccurs, by using the @option{-s}, @option{--quiet}, or @option{--silent} Xoption. X X@node patch and Keyboard Input X@subsection Inhibiting Keyboard Input X@cindex keyboard input to @command{patch} X XThere are two ways you can prevent @command{patch} from asking you any Xquestions. The @option{-f} or @option{--force} option assumes that you know Xwhat you are doing. It causes @command{patch} to do the following: X X@itemize @bullet X@item XSkip patches that do not contain file names in their headers. X X@item XPatch files even though they have the wrong version for the X@samp{Prereq:} line in the patch; X X@item XAssume that patches are not reversed even if they look like they are. X@end itemize X X@noindent XThe @option{-t} or @option{--batch} option is similar to @option{-f}, in that Xit suppresses questions, but it makes somewhat different assumptions: X X@itemize @bullet X@item XSkip patches that do not contain file names in their headers X(the same as @option{-f}). X X@item XSkip patches for which the file has the wrong version for the X@samp{Prereq:} line in the patch; X X@item XAssume that patches are reversed if they look like they are. X@end itemize X X@node patch Quoting Style X@subsection @command{patch} Quoting Style X@cindex quoting style X XWhen @command{patch} outputs a file name in a diagnostic message, it Xcan format the name in any of several ways. This can be useful to Xoutput file names unambiguously, even if they contain punctuation or Xspecial characters like newlines. The X@option{--quoting-style=@var{word}} option controls how names are Xoutput. The @var{word} should be one of the following: X X@table @samp X@item literal XOutput names as-is. X@item shell XQuote names for the shell if they contain shell metacharacters or would Xcause ambiguous output. X@item shell-always XQuote names for the shell, even if they would normally not require quoting. X@item c XQuote names as for a C language string. X@item escape XQuote as with @samp{c} except omit the surrounding double-quote Xcharacters. X@c The following are not yet implemented in patch 2.5.4. X@c @item clocale X@c Quote as with @samp{c} except use quotation marks appropriate for the X@c locale. X@c @item locale X@c @c Use @t instead of @samp to avoid duplicate quoting in some output styles. X@c Like @samp{clocale}, but quote @t{`like this'} instead of @t{"like X@c this"} in the default C locale. This looks nicer on many displays. X@end table X X@vindex QUOTING_STYLE XYou can specify the default value of the @option{--quoting-style} Xoption with the environment variable @env{QUOTING_STYLE}. If that Xenvironment variable is not set, the default value is @samp{shell}, Xbut this default may change in a future version of @command{patch}. X X@node patch and POSIX X@section @command{patch} and the @sc{posix} Standard X@cindex @sc{posix} X X@vindex POSIXLY_CORRECT XIf you specify the @option{--posix} option, or set the X@env{POSIXLY_CORRECT} environment variable, @command{patch} conforms Xmore strictly to the @sc{posix} standard, as follows: X X@itemize @bullet X@item XTake the first existing file from the list (old, new, index) Xwhen intuiting file names from diff headers. @xref{Multiple Patches}. X X@item XDo not remove files that are removed by a diff. X@xref{Creating and Removing}. X X@item XDo not ask whether to get files from @sc{rcs}, ClearCase, or X@sc{sccs}. @xref{Revision Control}. X X@item XRequire that all options precede the files in the command line. X X@item XDo not backup files, even when there is a mismatch. @xref{Backups}. X X@end itemize X X@node patch and Tradition X@section @sc{gnu} @command{patch} and Traditional @command{patch} X@cindex traditional @command{patch} X XThe current version of @sc{gnu} @command{patch} normally follows the X@sc{posix} standard. @xref{patch and POSIX}, for the few exceptions Xto this general rule. X XUnfortunately, @sc{posix} redefined the behavior of @command{patch} in Xseveral important ways. You should be aware of the following Xdifferences if you must interoperate with traditional @command{patch}, Xor with @sc{gnu} @command{patch} version 2.1 and earlier. X X@itemize @bullet X@item XIn traditional @command{patch}, the @option{-p} option's operand was Xoptional, and a bare @option{-p} was equivalent to @option{-p0}. The X@option{-p} option now requires an operand, and @option{-p@ 0} is now Xequivalent to @option{-p0}. For maximum compatibility, use options Xlike @option{-p0} and @option{-p1}. X XAlso, traditional @command{patch} simply counted slashes when Xstripping path prefixes; @command{patch} now counts pathname Xcomponents. That is, a sequence of one or more adjacent slashes now Xcounts as a single slash. For maximum portability, avoid sending Xpatches containing @file{//} in file names. X X@item XIn traditional @command{patch}, backups were enabled by default. This Xbehavior is now enabled with the @option{-b} or @option{--backup} Xoption. X XConversely, in @sc{posix} @command{patch}, backups are never made, Xeven when there is a mismatch. In @sc{gnu} @command{patch}, this Xbehavior is enabled with the @option{--no-backup-if-mismatch} option, Xor by conforming to @sc{posix}. X XThe @option{-b@ @var{suffix}} option of traditional @command{patch} is Xequivalent to the @samp{-b -z@ @var{suffix}} options of @sc{gnu} X@command{patch}. X X@item XTraditional @command{patch} used a complicated (and incompletely Xdocumented) method to intuit the name of the file to be patched from Xthe patch header. This method did not conform to @sc{posix}, and had Xa few gotchas. Now @command{patch} uses a different, equally Xcomplicated (but better documented) method that is optionally X@sc{posix}-conforming; we hope it has fewer gotchas. The two methods Xare compatible if the file names in the context diff header and the X@samp{Index:} line are all identical after prefix-stripping. Your Xpatch is normally compatible if each header's file names all contain Xthe same number of slashes. X X@item XWhen traditional @command{patch} asked the user a question, it sent Xthe question to standard error and looked for an answer from the first Xfile in the following list that was a terminal: standard error, Xstandard output, @file{/dev/tty}, and standard input. Now X@command{patch} sends questions to standard output and gets answers Xfrom @file{/dev/tty}. Defaults for some answers have been changed so Xthat @command{patch} never goes into an infinite loop when using Xdefault answers. X X@item XTraditional @command{patch} exited with a status value that counted Xthe number of bad hunks, or with status 1 if there was real trouble. XNow @command{patch} exits with status 1 if some hunks failed, or with X2 if there was real trouble. X X@item XLimit yourself to the following options when sending instructions Xmeant to be executed by anyone running @sc{gnu} @command{patch}, Xtraditional @command{patch}, or a @command{patch} that conforms to X@sc{posix}. Spaces are significant in the following list, and Xoperands are required. X X@example X@option{-c} X@option{-d @var{dir}} X@option{-D @var{define}} X@option{-e} X@option{-l} X@option{-n} X@option{-N} X@option{-o @var{outfile}} X@option{-p@var{num}} X@option{-R} X@option{-r @var{rejectfile}} X@end example X X@end itemize X X@node Making Patches X@chapter Tips for Making and Using Patches X XUse some common sense when making and using patches. For example, Xwhen sending bug fixes to a program's maintainer, send several small Xpatches, one per independent subject, instead of one large, Xharder-to-digest patch that covers all the subjects. X XHere are some other things you should keep in mind if you are going to Xdistribute patches for updating a software package. X X@menu X* Tips for Patch Producers:: Advice for making patches. X* Tips for Patch Consumers:: Advice for using patches. X* Avoiding Common Mistakes:: Avoiding common mistakes when using @command{patch}. X* Generating Smaller Patches:: How to generate smaller patches. X@end menu X X@node Tips for Patch Producers X@section Tips for Patch Producers X@cindex patch producer tips X XTo create a patch that changes an older version of a package into a Xnewer version, first make a copy of the older and newer versions in Xadjacent subdirectories. It is common to do that by unpacking X@command{tar} archives of the two versions. X XTo generate the patch, use the command @samp{diff -Naur @var{old} X@var{new}} where @var{old} and @var{new} identify the old and new Xdirectories. The names @var{old} and @var{new} should not contain any Xslashes. The @option{-N} option lets the patch create and remove Xfiles; @option{-a} lets the patch update non-text files; @option{-u} Xgenerates useful time stamps and enough context; and @option{-r} lets Xthe patch update subdirectories. Here is an example command, using XBourne shell syntax: X X@example Xdiff -Naur gcc-3.0.3 gcc-3.0.4 X@end example X XTell your recipients how to apply the patches. This should include Xwhich working directory to use, and which @command{patch} options to Xuse; the option @samp{-p1} is recommended. Test your procedure by Xpretending to be a recipient and applying your patches to a copy of Xthe original files. X X@xref{Avoiding Common Mistakes}, for how to avoid common mistakes when Xgenerating a patch. X X@node Tips for Patch Consumers X@section Tips for Patch Consumers X@cindex patch consumer tips X XA patch producer should tell recipients how to apply the patches, so Xthe first rule of thumb for a patch consumer is to follow the Xinstructions supplied with the patch. X X@sc{gnu} @command{diff} can analyze files with arbitrarily long lines Xand files that end in incomplete lines. However, older versions of X@command{patch} cannot patch such files. If you are having trouble Xapplying such patches, try upgrading to a recent version of @sc{gnu} X@command{patch}. X X@node Avoiding Common Mistakes X@section Avoiding Common Mistakes X@cindex common mistakes with patches X@cindex patch, common mistakes X XWhen producing a patch for multiple files, apply @command{diff} to Xdirectories whose names do not have slashes. This reduces confusion Xwhen the patch consumer specifies the @option{-p@var{number}} option, Xsince this option can have surprising results when the old and new Xfile names have different numbers of slashes. For example, do not Xsend a patch with a header that looks like this: X X@example Xdiff -Naur v2.0.29/prog/README prog/README X--- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800 X+++ prog/README 2002-03-17 20:49:32.442260588 -0800 X@end example X X@noindent Xbecause the two file names have different numbers of slashes, and Xdifferent versions of @command{patch} interpret the file names Xdifferently. To avoid confusion, send output that looks like this Xinstead: X X@example Xdiff -Naur v2.0.29/prog/README v2.0.30/prog/README X--- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800 X+++ v2.0.30/prog/README 2002-03-17 20:49:32.442260588 -0800 X@end example X XMake sure you have specified the file names correctly, either in a Xcontext diff header or with an @samp{Index:} line. Take care to not send out Xreversed patches, since these make people wonder whether they have Xalready applied the patch. X XAvoid sending patches that compare backup file names like X@file{README.orig} or @file{README~}, since this might confuse X@command{patch} into patching a backup file instead of the real file. XInstead, send patches that compare the same base file names in Xdifferent directories, e.g.@: @file{old/README} and @file{new/README}. X XTo save people from partially applying a patch before other patches that Xshould have gone before it, you can make the first patch in the patch Xfile update a file with a name like @file{patchlevel.h} or X@file{version.c}, which contains a patch level or version number. If Xthe input file contains the wrong version number, @command{patch} will Xcomplain immediately. X XAn even clearer way to prevent this problem is to put a @samp{Prereq:} Xline before the patch. If the leading text in the patch file contains a Xline that starts with @samp{Prereq:}, @command{patch} takes the next word Xfrom that line (normally a version number) and checks whether the next Xinput file contains that word, preceded and followed by either Xwhite space or a newline. If not, @command{patch} prompts you for Xconfirmation before proceeding. This makes it difficult to accidentally Xapply patches in the wrong order. X X@node Generating Smaller Patches X@section Generating Smaller Patches X@cindex patches, shrinking X XThe simplest way to generate a patch is to use @samp{diff -Naur} X(@pxref{Tips for Patch Producers}), but you might be able to reduce Xthe size of the patch by renaming or removing some files before making Xthe patch. If the older version of the package contains any files Xthat the newer version does not, or if any files have been renamed Xbetween the two versions, make a list of @command{rm} and @command{mv} Xcommands for the user to execute in the old version directory before Xapplying the patch. Then run those commands yourself in the scratch Xdirectory. X XIf there are any files that you don't need to include in the patch Xbecause they can easily be rebuilt from other files (for example, X@file{TAGS} and output from @command{yacc} and @command{makeinfo}), Xexclude them from the patch by giving @command{diff} the @option{-x X@var{pattern}} option (@pxref{Comparing Directories}). If you want Xyour patch to modify a derived file because your recipients lack tools Xto build it, make sure that the patch for the derived file follows any Xpatches for files that it depends on, so that the recipients' time Xstamps will not confuse @command{make}. X XNow you can create the patch using @samp{diff -Naur}. Make sure to Xspecify the scratch directory first and the newer directory second. X XAdd to the top of the patch a note telling the user any @command{rm} and X@command{mv} commands to run before applying the patch. Then you can Xremove the scratch directory. X XYou can also shrink the patch size by using fewer lines of context, Xbut bear in mind that @command{patch} typically needs at least two Xlines for proper operation when patches do not exactly match the input Xfiles. X X@node Invoking cmp X@chapter Invoking @command{cmp} X@cindex invoking @command{cmp} X@cindex @command{cmp} invocation X XThe @command{cmp} command compares two files, and if they differ, Xtells the first byte and line number where they differ. Bytes and Xlines are numbered starting with 1. The arguments of @command{cmp} Xare as follows: X X@example Xcmp @var{options}@dots{} @var{from-file} @r{[}@var{to-file} @r{[}@var{from-skip} @r{[}@var{to-skip}@r{]}@r{]}@r{]} X@end example X XThe file name @file{-} is always the standard input. @command{cmp} Xalso uses the standard input if one file name is omitted. The X@var{from-skip} and @var{to-skip} operands specify how many bytes to Xignore at the start of each file; they are equivalent to the X@option{--ignore-initial=@var{from-skip}:@var{to-skip}} option. X XAn exit status of 0 means no differences were found, 1 means some Xdifferences were found, and 2 means trouble. X X@menu X* cmp Options:: Summary of options to @command{cmp}. X@end menu X X@node cmp Options X@section Options to @command{cmp} X@cindex @command{cmp} options X@cindex options for @command{cmp} X XBelow is a summary of all of the options that @sc{gnu} @command{cmp} accepts. XMost options have two equivalent names, one of which is a single letter Xpreceded by @samp{-}, and the other of which is a long name preceded by X@samp{--}. Multiple single letter options (unless they take an Xargument) can be combined into a single command line word: @option{-bl} is Xequivalent to @option{-b -l}. X X@table @option X@item -b X@itemx --print-bytes XPrint the differing bytes. Display control bytes as a X@samp{^} followed by a letter of the alphabet and precede bytes Xthat have the high bit set with @samp{M-} (which stands for ``meta''). X X@item --help XOutput a summary of usage and then exit. X X@item -i @var{skip} X@itemx --ignore-initial=@var{skip} XIgnore any differences in the first @var{skip} bytes of the input Xfiles. Treat files with fewer than @var{skip} bytes as if they are Xempty. If @var{skip} is of the form X@option{@var{from-skip}:@var{to-skip}}, skip the first @var{from-skip} Xbytes of the first input file and the first @var{to-skip} bytes of the Xsecond. X X@item -l X@itemx --verbose XPrint the (decimal) byte numbers and (octal) values of all differing bytes. X X@item -n @var{count} X@itemx --bytes=@var{count} XCompare at most @var{count} input bytes. X X@item -s X@itemx --quiet X@itemx --silent XDo not print anything; only return an exit status indicating whether Xthe files differ. X X@item -v X@itemx --version XOutput version information and then exit. X@end table X XIn the above table, operands that are byte counts are normally Xdecimal, but may be preceded by @samp{0} for octal and @samp{0x} for Xhexadecimal. X XA byte count can be followed by a suffix to specify a multiple of that Xcount; in this case an omitted integer is understood to be 1. A bare Xsize letter, or one followed by @samp{iB}, specifies a multiple using Xpowers of 1024. A size letter followed by @samp{B} specifies powers Xof 1000 instead. For example, @option{-n 4M} and @option{-n 4MiB} are Xequivalent to @option{-n 4194304}, whereas @option{-n 4MB} is Xequivalent to @option{-n 4000000}. This notation is upward compatible Xwith the @uref{http://www.bipm.fr/enus/3_SI/si-prefixes.html, SI Xprefixes} for decimal multiples and with the X@uref{http://physics.nist.gov/cuu/Units/binary.html, IEC 60027-2 Xprefixes for binary multiples}. X XThe following suffixes are defined. Large sizes like @code{1Y} may be Xrejected by your computer due to limitations of its arithmetic. X X@table @samp X@item kB X@cindex kilobyte, definition of Xkilobyte: @math{10^3 = 1000}. X@item k X@itemx K X@itemx KiB X@cindex kibibyte, definition of Xkibibyte: @math{2^10 = 1024}. @samp{K} is special: the SI prefix is X@samp{k} and the IEC 60027-2 prefix is @samp{Ki}, but tradition and X@sc{posix} use @samp{k} to mean @samp{KiB}. X@item MB X@cindex megabyte, definition of Xmegabyte: @math{10^6 = 1,000,000}. X@item M X@itemx MiB X@cindex mebibyte, definition of Xmebibyte: @math{2^20 = 1,048,576}. X@item GB X@cindex gigabyte, definition of Xgigabyte: @math{10^9 = 1,000,000,000}. X@item G X@itemx GiB X@cindex gibibyte, definition of Xgibibyte: @math{2^30 = 1,073,741,824}. X@item TB X@cindex terabyte, definition of Xterabyte: @math{10^12 = 1,000,000,000,000}. X@item T X@itemx TiB X@cindex tebibyte, definition of Xtebibyte: @math{2^40 = 1,099,511,627,776}. X@item PB X@cindex petabyte, definition of Xpetabyte: @math{10^15 = 1,000,000,000,000,000}. X@item P X@itemx PiB X@cindex pebibyte, definition of Xpebibyte: @math{2^50 = 1,125,899,906,842,624}. X@item EB X@cindex exabyte, definition of Xexabyte: @math{10^18 = 1,000,000,000,000,000,000}. X@item E X@itemx EiB X@cindex exbibyte, definition of Xexbibyte: @math{2^60 = 1,152,921,504,606,846,976}. X@item ZB X@cindex zettabyte, definition of Xzettabyte: @math{10^21 = 1,000,000,000,000,000,000,000} X@item Z X@itemx ZiB X@math{2^70 = 1,180,591,620,717,411,303,424}. X(@samp{Zi} is a GNU extension to IEC 60027-2.) X@item YB X@cindex yottabyte, definition of Xyottabyte: @math{10^24 = 1,000,000,000,000,000,000,000,000}. X@item Y X@itemx YiB X@math{2^80 = 1,208,925,819,614,629,174,706,176}. X(@samp{Yi} is a GNU extension to IEC 60027-2.) X@end table X X@node Invoking diff X@chapter Invoking @command{diff} X@cindex invoking @command{diff} X@cindex @command{diff} invocation X XThe format for running the @command{diff} command is: X X@example Xdiff @var{options}@dots{} @var{files}@dots{} X@end example X XIn the simplest case, two file names @var{from-file} and X@var{to-file} are given, and @command{diff} compares the contents of X@var{from-file} and @var{to-file}. A file name of @file{-} stands for Xtext read from the standard input. As a special case, @samp{diff - -} Xcompares a copy of standard input to itself. X XIf one file is a directory and the other is not, @command{diff} compares Xthe file in the directory whose name is that of the non-directory. XThe non-directory file must not be @file{-}. X XIf two file names are given and both are directories, X@command{diff} compares corresponding files in both directories, in Xalphabetical order; this comparison is not recursive unless the X@option{-r} or @option{--recursive} option is given. @command{diff} never Xcompares the actual contents of a directory as if it were a file. The Xfile that is fully specified may not be standard input, because standard Xinput is nameless and the notion of ``file with the same name'' does not Xapply. X XIf the @option{--from-file=@var{file}} option is given, the number of Xfile names is arbitrary, and @var{file} is compared to each named file. XSimilarly, if the @option{--to-file=@var{file}} option is given, each Xnamed file is compared to @var{file}. X X@command{diff} options begin with @samp{-}, so normally file names Xmay not begin with @samp{-}. However, @option{--} as an Xargument by itself treats the remaining arguments as file names even if Xthey begin with @samp{-}. X XAn exit status of 0 means no differences were found, 1 means some Xdifferences were found, and 2 means trouble. X X@menu X* diff Options:: Summary of options to @command{diff}. X@end menu X X@node diff Options X@section Options to @command{diff} X@cindex @command{diff} options X@cindex options for @command{diff} X XBelow is a summary of all of the options that @sc{gnu} @command{diff} accepts. XMost options have two equivalent names, one of which is a single letter Xpreceded by @samp{-}, and the other of which is a long name preceded by X@samp{--}. Multiple single letter options (unless they take an Xargument) can be combined into a single command line word: @option{-ac} is Xequivalent to @option{-a -c}. Long named options can be abbreviated to Xany unique prefix of their name. Brackets ([ and ]) indicate that an Xoption takes an optional argument. X X@table @option X@item -a X@itemx --text XTreat all files as text and compare them line-by-line, even if they Xdo not seem to be text. @xref{Binary}. X X@item -b X@itemx --ignore-space-change XIgnore changes in amount of white space. @xref{White Space}. X X@item -B X@itemx --ignore-blank-lines XIgnore changes that just insert or delete blank lines. @xref{Blank XLines}. X X@item --binary XRead and write data in binary mode. @xref{Binary}. X X@item -c XUse the context output format, showing three lines of context. X@xref{Context Format}. X X@item -C @var{lines} X@itemx --context@r{[}=@var{lines}@r{]} XUse the context output format, showing @var{lines} (an integer) lines of Xcontext, or three if @var{lines} is not given. @xref{Context Format}. XFor proper operation, @command{patch} typically needs at least two lines of Xcontext. X XOn older systems, @command{diff} supports an obsolete option X@option{-@var{lines}} that has effect when combined with @option{-c} Xor @option{-p}. @sc{posix} 1003.1-2001 (@pxref{Standards Xconformance}) does not allow this; use @option{-C @var{lines}} Xinstead. X X@item --changed-group-format=@var{format} XUse @var{format} to output a line group containing differing lines from Xboth files in if-then-else format. @xref{Line Group Formats}. X X@item -d X@itemx --minimal XChange the algorithm perhaps find a smaller set of changes. This makes X@command{diff} slower (sometimes much slower). @xref{diff Performance}. X X@item -D @var{name} X@itemx --ifdef=@var{name} XMake merged @samp{#ifdef} format output, conditional on the preprocessor Xmacro @var{name}. @xref{If-then-else}. X X@item -e X@itemx --ed XMake output that is a valid @command{ed} script. @xref{ed Scripts}. X X@item -E X@itemx --ignore-tab-expansion XIgnore changes due to tab expansion. X@xref{White Space}. X X@item -f X@itemx --forward-ed XMake output that looks vaguely like an @command{ed} script but has changes Xin the order they appear in the file. @xref{Forward ed}. X X@item -F @var{regexp} X@itemx --show-function-line=@var{regexp} XIn context and unified format, for each hunk of differences, show some Xof the last preceding line that matches @var{regexp}. @xref{Specified XHeadings}. X X@item --from-file=@var{file} XCompare @var{file} to each operand; @var{file} may be a directory. X X@item --help XOutput a summary of usage and then exit. X X@item --horizon-lines=@var{lines} XDo not discard the last @var{lines} lines of the common prefix Xand the first @var{lines} lines of the common suffix. X@xref{diff Performance}. X X@item -i X@itemx --ignore-case XIgnore changes in case; consider upper- and lower-case letters Xequivalent. @xref{Case Folding}. X X@item -I @var{regexp} X@itemx --ignore-matching-lines=@var{regexp} XIgnore changes that just insert or delete lines that match @var{regexp}. X@xref{Specified Folding}. X X@item --ignore-file-name-case XIgnore case when comparing file names during recursive comparison. X@xref{Comparing Directories}. X X@item -l X@itemx --paginate XPass the output through @command{pr} to paginate it. @xref{Pagination}. X X@item --label=@var{label} XUse @var{label} instead of the file name in the context format X(@pxref{Context Format}) and unified format (@pxref{Unified Format}) Xheaders. @xref{RCS}. X X@item --left-column XPrint only the left column of two common lines in side by side format. X@xref{Side by Side Format}. X X@item --line-format=@var{format} XUse @var{format} to output all input lines in if-then-else format. X@xref{Line Formats}. X X@item -n X@itemx --rcs XOutput @sc{rcs}-format diffs; like @option{-f} except that each command Xspecifies the number of lines affected. @xref{RCS}. X X@item -N X@itemx --new-file XIn directory comparison, if a file is found in only one directory, Xtreat it as present but empty in the other directory. @xref{Comparing XDirectories}. X X@item --new-group-format=@var{format} XUse @var{format} to output a group of lines taken from just the second Xfile in if-then-else format. @xref{Line Group Formats}. X X@item --new-line-format=@var{format} XUse @var{format} to output a line taken from just the second file in Xif-then-else format. @xref{Line Formats}. X X@item --old-group-format=@var{format} XUse @var{format} to output a group of lines taken from just the first Xfile in if-then-else format. @xref{Line Group Formats}. X X@item --old-line-format=@var{format} XUse @var{format} to output a line taken from just the first file in Xif-then-else format. @xref{Line Formats}. X X@item -p X@itemx --show-c-function XShow which C function each change is in. @xref{C Function Headings}. X X@item -q X@itemx --brief XReport only whether the files differ, not the details of the Xdifferences. @xref{Brief}. X X@item -r X@itemx --recursive XWhen comparing directories, recursively compare any subdirectories Xfound. @xref{Comparing Directories}. X X@item -s X@itemx --report-identical-files XReport when two files are the same. @xref{Comparing Directories}. X X@item -S @var{file} X@itemx --starting-file=@var{file} XWhen comparing directories, start with the file @var{file}. This is Xused for resuming an aborted comparison. @xref{Comparing Directories}. X X@item --speed-large-files XUse heuristics to speed handling of large files that have numerous Xscattered small changes. @xref{diff Performance}. X X@item --strip-trailing-cr XStrip any trailing carriage return at the end of an input line. X@xref{Binary}. X X@item --suppress-common-lines XDo not print common lines in side by side format. X@xref{Side by Side Format}. X X@item -t X@itemx --expand-tabs XExpand tabs to spaces in the output, to preserve the alignment of tabs Xin the input files. @xref{Tabs}. X X@item -T X@itemx --initial-tab XOutput a tab rather than a space before the text of a line in normal or Xcontext format. This causes the alignment of tabs in the line to look Xnormal. @xref{Tabs}. X X@item --to-file=@var{file} XCompare each operand to @var{file}; @var{file} may be a directory. X X@item -u XUse the unified output format, showing three lines of context. X@xref{Unified Format}. X X@item --unchanged-group-format=@var{format} XUse @var{format} to output a group of common lines taken from both files Xin if-then-else format. @xref{Line Group Formats}. X X@item --unchanged-line-format=@var{format} XUse @var{format} to output a line common to both files in if-then-else Xformat. @xref{Line Formats}. X X@item --unidirectional-new-file XWhen comparing directories, if a file appears only in the second Xdirectory of the two, treat it as present but empty in the other. X@xref{Comparing Directories}. X X@item -U @var{lines} X@itemx --unified@r{[}=@var{lines}@r{]} XUse the unified output format, showing @var{lines} (an integer) lines of Xcontext, or three if @var{lines} is not given. @xref{Unified Format}. XFor proper operation, @command{patch} typically needs at least two lines of Xcontext. X XOn older systems, @command{diff} supports an obsolete option X@option{-@var{lines}} that has effect when combined with @option{-u}. X@sc{posix} 1003.1-2001 (@pxref{Standards conformance}) does not allow Xthis; use @option{-U @var{lines}} instead. X X@item -v X@itemx --version XOutput version information and then exit. X X@item -w X@itemx --ignore-all-space XIgnore white space when comparing lines. @xref{White Space}. X X@item -W @var{columns} X@itemx --width=@var{columns} XOutput at most @var{columns} (default 130) print columns per line in Xside by side format. @xref{Side by Side Format}. X X@item -x @var{pattern} X@itemx --exclude=@var{pattern} XWhen comparing directories, ignore files and subdirectories whose basenames Xmatch @var{pattern}. @xref{Comparing Directories}. X X@item -X @var{file} X@itemx --exclude-from=@var{file} XWhen comparing directories, ignore files and subdirectories whose basenames Xmatch any pattern contained in @var{file}. @xref{Comparing Directories}. X X@item -y X@itemx --side-by-side XUse the side by side output format. @xref{Side by Side Format}. X@end table X X@node Invoking diff3 X@chapter Invoking @command{diff3} X@cindex invoking @command{diff3} X@cindex @command{diff3} invocation X XThe @command{diff3} command compares three files and outputs descriptions Xof their differences. Its arguments are as follows: X X@example Xdiff3 @var{options}@dots{} @var{mine} @var{older} @var{yours} X@end example X XThe files to compare are @var{mine}, @var{older}, and @var{yours}. XAt most one of these three file names may be @file{-}, Xwhich tells @command{diff3} to read the standard input for that file. X XAn exit status of 0 means @command{diff3} was successful, 1 means some Xconflicts were found, and 2 means trouble. X X@menu X* diff3 Options:: Summary of options to @command{diff3}. X@end menu X X@node diff3 Options X@section Options to @command{diff3} X@cindex @command{diff3} options X@cindex options for @command{diff3} X XBelow is a summary of all of the options that @sc{gnu} @command{diff3} Xaccepts. Multiple single letter options (unless they take an argument) Xcan be combined into a single command line argument. X X@table @option X@item -a X@itemx --text XTreat all files as text and compare them line-by-line, even if they Xdo not appear to be text. @xref{Binary}. X X@item -A X@itemx --show-all XIncorporate all unmerged changes from @var{older} to @var{yours} into X@var{mine}, surrounding conflicts with bracket lines. X@xref{Marking Conflicts}. X X@item --diff-program=@var{program} XUse the compatible comparison program @var{program} to compare files Xinstead of @command{diff}. X X@item -e X@itemx --ed XGenerate an @command{ed} script that incorporates all the changes from X@var{older} to @var{yours} into @var{mine}. @xref{Which Changes}. X X@item -E X@itemx --show-overlap XLike @option{-e}, except bracket lines from overlapping changes' first Xand third files. X@xref{Marking Conflicts}. XWith @option{-E}, an overlapping change looks like this: X X@example X<<<<<<< @var{mine} X@r{lines from @var{mine}} X======= X@r{lines from @var{yours}} X>>>>>>> @var{yours} X@end example X X@item --help XOutput a summary of usage and then exit. X X@item -i XGenerate @samp{w} and @samp{q} commands at the end of the @command{ed} Xscript for System V compatibility. This option must be combined with Xone of the @option{-AeExX3} options, and may not be combined with @option{-m}. X@xref{Saving the Changed File}. X X@item -L @var{label} X@itemx --label=@var{label} XUse the label @var{label} for the brackets output by the @option{-A}, X@option{-E} and @option{-X} options. This option may be given up to three Xtimes, one for each input file. The default labels are the names of Xthe input files. Thus @samp{diff3 -L X -L Y -L Z -m A B C} acts like X@samp{diff3 -m A B C}, except that the output looks like it came from Xfiles named @samp{X}, @samp{Y} and @samp{Z} rather than from files Xnamed @samp{A}, @samp{B} and @samp{C}. @xref{Marking Conflicts}. X X@item -m X@itemx --merge XApply the edit script to the first file and send the result to standard Xoutput. Unlike piping the output from @command{diff3} to @command{ed}, this Xworks even for binary files and incomplete lines. @option{-A} is assumed Xif no edit script option is specified. @xref{Bypassing ed}. X X@item -T X@itemx --initial-tab XOutput a tab rather than two spaces before the text of a line in normal format. XThis causes the alignment of tabs in the line to look normal. @xref{Tabs}. X X@item -v X@itemx --version XOutput version information and then exit. X X@item -x X@itemx --overlap-only XLike @option{-e}, except output only the overlapping changes. X@xref{Which Changes}. X X@item -X XLike @option{-E}, except output only the overlapping changes. XIn other words, like @option{-x}, except bracket changes as in @option{-E}. X@xref{Marking Conflicts}. X X@item -3 X@itemx --easy-only XLike @option{-e}, except output only the nonoverlapping changes. X@xref{Which Changes}. X@end table X X@node Invoking patch X@chapter Invoking @command{patch} X@cindex invoking @command{patch} X@cindex @command{patch} invocation X XNormally @command{patch} is invoked like this: X X@example Xpatch <@var{patchfile} X@end example X XThe full format for invoking @command{patch} is: X X@example Xpatch @var{options}@dots{} @r{[}@var{origfile} @r{[}@var{patchfile}@r{]}@r{]} X@end example X XYou can also specify where to read the patch from with the @option{-i X@var{patchfile}} or @option{--input=@var{patchfile}} option. XIf you do not specify @var{patchfile}, or if @var{patchfile} is X@file{-}, @command{patch} reads the patch (that is, the @command{diff} output) Xfrom the standard input. X XIf you do not specify an input file on the command line, @command{patch} Xtries to intuit from the @dfn{leading text} (any text in the patch Xthat comes before the @command{diff} output) which file to edit. X@xref{Multiple Patches}. X XBy default, @command{patch} replaces the original input file with the Xpatched version, possibly after renaming the original file into a Xbackup file (@pxref{Backup Names}, for a description of how X@command{patch} names backup files). You can also specify where to Xput the output with the @option{-o @var{file}} or X@option{--output=@var{file}} option; however, do not use this option Xif @var{file} is one of the input files. X X@menu X* patch Options:: Summary table of options to @command{patch}. X@end menu X X@node patch Options X@section Options to @command{patch} X@cindex @command{patch} options X@cindex options for @command{patch} X XHere is a summary of all of the options that @sc{gnu} @command{patch} Xaccepts. @xref{patch and Tradition}, for which of these options are Xsafe to use in older versions of @command{patch}. X XMultiple single-letter options that do not take an argument can be Xcombined into a single command line argument with only one dash. X X@table @option X@item -b X@itemx --backup XBack up the original contents of each file, even if backups would Xnormally not be made. @xref{Backups}. X X@item -B @var{prefix} X@itemx --prefix=@var{prefix} XPrepend @var{prefix} to backup file names. @xref{Backup Names}. X X@item --backup-if-mismatch XBack up the original contents of each file if the patch does not Xexactly match the file. This is the default behavior when not Xconforming to @sc{posix}. @xref{Backups}. X X@item --binary XRead and write all files in binary mode, except for standard output Xand @file{/dev/tty}. This option has no effect on X@sc{posix}-conforming systems like @sc{gnu}/Linux. On systems where Xthis option makes a difference, the patch should be generated by X@samp{diff -a --binary}. @xref{Binary}. X X@item -c X@itemx --context XInterpret the patch file as a context diff. @xref{patch Input}. X X@item -d @var{directory} X@itemx --directory=@var{directory} XMake directory @var{directory} the current directory for interpreting Xboth file names in the patch file, and file names given as arguments to Xother options. @xref{patch Directories}. X X@item -D @var{name} X@itemx --ifdef=@var{name} XMake merged if-then-else output using @var{name}. @xref{If-then-else}. X X@item --dry-run XPrint the results of applying the patches without actually changing Xany files. @xref{Dry Runs}. X X@item -e X@itemx --ed XInterpret the patch file as an @command{ed} script. @xref{patch Input}. X X@item -E X@itemx --remove-empty-files XRemove output files that are empty after the patches have been applied. X@xref{Creating and Removing}. X X@item -f X@itemx --force XAssume that the user knows exactly what he or she is doing, and do not Xask any questions. @xref{patch Messages}. X X@item -F @var{lines} X@itemx --fuzz=@var{lines} XSet the maximum fuzz factor to @var{lines}. @xref{Inexact}. X X@item -g @var{num} X@itemx --get=@var{num} XIf @var{num} is positive, get input files from a revision control Xsystem as necessary; if zero, do not get the files; if negative, ask Xthe user whether to get the files. @xref{Revision Control}. X X@item --help XOutput a summary of usage and then exit. X X@item -i @var{patchfile} X@itemx --input=@var{patchfile} XRead the patch from @var{patchfile} rather than from standard input. X@xref{patch Options}. X X@item -l X@itemx --ignore-white-space XLet any sequence of blanks (spaces or tabs) in the patch file match Xany sequence of blanks in the input file. @xref{Changed White Space}. X X@item -n X@itemx --normal XInterpret the patch file as a normal diff. @xref{patch Input}. X X@item -N X@itemx --forward XIgnore patches that @command{patch} thinks are reversed or already applied. XSee also @option{-R}. @xref{Reversed Patches}. X X@item --no-backup-if-mismatch XDo not back up the original contents of files. This is the default Xbehavior when conforming to @sc{posix}. @xref{Backups}. X X@item -o @var{file} X@itemx --output=@var{file} XUse @var{file} as the output file name. @xref{patch Options}. X X@item -p@var{number} X@itemx --strip=@var{number} XSet the file name strip count to @var{number}. @xref{patch Directories}. X X@item --posix XConform to @sc{posix}, as if the @env{POSIXLY_CORRECT} environment Xvariable had been set. @xref{patch and POSIX}. X X@item --quoting-style=@var{word} XUse style @var{word} to quote names in diagnostics, as if the X@env{QUOTING_STYLE} environment variable had been set to @var{word}. X@xref{patch Quoting Style}. X X@item -r @var{reject-file} X@itemx --reject-file=@var{reject-file} XUse @var{reject-file} as the reject file name. @xref{Reject Names}. X X@item -R X@itemx --reverse XAssume that this patch was created with the old and new files swapped. X@xref{Reversed Patches}. X X@item -s X@itemx --quiet X@itemx --silent XWork silently unless an error occurs. @xref{patch Messages}. X X@item -t X@itemx --batch XDo not ask any questions. @xref{patch Messages}. X X@item -T X@itemx --set-time XSet the modification and access times of patched files from time Xstamps given in context diff headers, assuming that the context diff Xheaders use local time. @xref{Patching Time Stamps}. X X@item -u X@itemx --unified XInterpret the patch file as a unified diff. @xref{patch Input}. X X@item -v X@itemx --version XOutput version information and then exit. X X@item -V @var{backup-style} X@itemx --version=control=@var{backup-style} XSelect the naming convention for backup file names. @xref{Backup Names}. X X@item --verbose XPrint more diagnostics than usual. @xref{patch Messages}. X X@item -x @var{number} X@itemx --debug=@var{number} XSet internal debugging flags. Of interest only to @command{patch} Xpatchers. X X@item -Y @var{prefix} X@itemx --basename-prefix=@var{prefix} XPrepend @var{prefix} to base names of backup files. @xref{Backup Names}. X X@item -z @var{suffix} X@itemx --suffix=@var{suffix} XUse @var{suffix} as the backup extension instead of @samp{.orig} or X@samp{~}. @xref{Backup Names}. X X@item -Z X@itemx --set-utc XSet the modification and access times of patched files from time Xstamps given in context diff headers, assuming that the context diff Xheaders use @sc{utc}. @xref{Patching Time Stamps}. X X@end table X X@node Invoking sdiff X@chapter Invoking @command{sdiff} X@cindex invoking @command{sdiff} X@cindex @command{sdiff} invocation X XThe @command{sdiff} command merges two files and interactively outputs the Xresults. Its arguments are as follows: X X@example Xsdiff -o @var{outfile} @var{options}@dots{} @var{from-file} @var{to-file} X@end example X XThis merges @var{from-file} with @var{to-file}, with output to @var{outfile}. XIf @var{from-file} is a directory and @var{to-file} is not, @command{sdiff} Xcompares the file in @var{from-file} whose file name is that of @var{to-file}, Xand vice versa. @var{from-file} and @var{to-file} may not both be Xdirectories. X X@command{sdiff} options begin with @samp{-}, so normally @var{from-file} Xand @var{to-file} may not begin with @samp{-}. However, @option{--} as an Xargument by itself treats the remaining arguments as file names even if Xthey begin with @samp{-}. You may not use @file{-} as an input file. X X@command{sdiff} without @option{-o} (or @option{--output}) produces a Xside-by-side difference. This usage is obsolete; use the @option{-y} Xor @option{--side-by-side} option of @command{diff} instead. X XAn exit status of 0 means no differences were found, 1 means some Xdifferences were found, and 2 means trouble. X X@menu X* sdiff Options:: Summary of options to @command{diff}. X@end menu X X@node sdiff Options X@section Options to @command{sdiff} X@cindex @command{sdiff} options X@cindex options for @command{sdiff} X XBelow is a summary of all of the options that @sc{gnu} @command{sdiff} accepts. XEach option has two equivalent names, one of which is a single Xletter preceded by @samp{-}, and the other of which is a long name Xpreceded by @samp{--}. Multiple single letter options (unless they take Xan argument) can be combined into a single command line argument. Long Xnamed options can be abbreviated to any unique prefix of their name. X X@table @option X@item -a X@itemx --text XTreat all files as text and compare them line-by-line, even if they Xdo not appear to be text. @xref{Binary}. X X@item -b X@itemx --ignore-space-change XIgnore changes in amount of white space. @xref{White Space}. X X@item -B X@itemx --ignore-blank-lines XIgnore changes that just insert or delete blank lines. @xref{Blank XLines}. X X@item -d X@itemx --minimal XChange the algorithm to perhaps find a smaller set of changes. This Xmakes @command{sdiff} slower (sometimes much slower). @xref{diff XPerformance}. X X@item --diff-program=@var{program} XUse the compatible comparison program @var{program} to compare files Xinstead of @command{diff}. X X@item -E X@itemx --ignore-tab-expansion XIgnore changes due to tab expansion. X@xref{White Space}. X X@item --help XOutput a summary of usage and then exit. X X@item -i X@itemx --ignore-case XIgnore changes in case; consider upper- and lower-case to be the same. X@xref{Case Folding}. X X@item -I @var{regexp} X@itemx --ignore-matching-lines=@var{regexp} XIgnore changes that just insert or delete lines that match @var{regexp}. X@xref{Specified Folding}. X X@item -l X@itemx --left-column XPrint only the left column of two common lines. X@xref{Side by Side Format}. X X@item -o @var{file} X@itemx --output=@var{file} XPut merged output into @var{file}. This option is required for merging. X X@item -s X@itemx --suppress-common-lines XDo not print common lines. @xref{Side by Side Format}. X X@item --speed-large-files XUse heuristics to speed handling of large files that have numerous Xscattered small changes. @xref{diff Performance}. X X@item --strip-trailing-cr XStrip any trailing carriage return at the end of an input line. X@xref{Binary}. X X@item -t X@itemx --expand-tabs XExpand tabs to spaces in the output, to preserve the alignment of tabs Xin the input files. @xref{Tabs}. X X@item -v X@itemx --version XOutput version information and then exit. X X@item -w @var{columns} X@itemx --width=@var{columns} XOutput at most @var{columns} (default 130) print columns per line. X@xref{Side by Side Format}. Note that for historical reasons, this Xoption is @option{-W} in @command{diff}, @option{-w} in @command{sdiff}. X X@item -W X@itemx --ignore-all-space XIgnore white space when comparing lines. @xref{White Space}. XNote that for historical reasons, this option is @option{-w} in @command{diff}, X@option{-W} in @command{sdiff}. X@end table X X@node Standards conformance X@chapter Standards conformance X@cindex @sc{posix} X X@vindex POSIXLY_CORRECT XIn a few cases, the @sc{gnu} utilities' default behavior is Xincompatible with the @sc{posix} standard. To suppress these Xincompatibilities, define the @env{POSIXLY_CORRECT} environment Xvariable. Unless you are checking for @sc{posix} conformance, you Xprobably do not need to define @env{POSIXLY_CORRECT}. X XNormally options and operands can appear in any order, and programs act Xas if all the options appear before any operands. For example, X@samp{diff lao tzu -C 2} acts like @samp{diff -C 2 lao tzu}, since X@samp{2} is an option-argument of @option{-C}. However, if the X@env{POSIXLY_CORRECT} environment variable is set, options must appear Xbefore operands, unless otherwise specified for a particular command. X XNewer versions of @sc{posix} are occasionally incompatible with older Xversions. For example, older versions of @sc{posix} allowed the Xcommand @samp{diff -c -10} to have the same meaning as @samp{diff -C X10}, but @sc{posix} 1003.1-2001 @samp{diff} no longer allows Xdigit-string options like @option{-10}. X X@vindex _POSIX2_VERSION XThe @sc{gnu} utilities normally conform to the version of @sc{posix} Xthat is standard for your system. To cause them to conform to a Xdifferent version of @sc{posix}, define the @env{_POSIX2_VERSION} Xenvironment variable to a value of the form @var{yyyymm} specifying Xthe year and month the standard was adopted. Two values are currently Xsupported for @env{_POSIX2_VERSION}: @samp{199209} stands for X@sc{posix} 1003.2-1992, and @samp{200112} stands for @sc{posix} X1003.1-2001. For example, if you are running older software that Xassumes an older version of @sc{posix} and uses @samp{diff -c -10}, Xyou can work around the compatibility problems by setting X@samp{_POSIX2_VERSION=199209} in your environment. X X@node Projects X@chapter Future Projects X XHere are some ideas for improving @sc{gnu} @command{diff} and X@command{patch}. The @sc{gnu} project has identified some Ximprovements as potential programming projects for volunteers. You Xcan also help by reporting any bugs that you find. X XIf you are a programmer and would like to contribute something to the X@sc{gnu} project, please consider volunteering for one of these Xprojects. If you are seriously contemplating work, please write to X@email{gnu@@gnu.org} to coordinate with other volunteers. X X@menu X* Shortcomings:: Suggested projects for improvements. X* Bugs:: Reporting bugs. X@end menu X X@node Shortcomings X@section Suggested Projects for Improving @sc{gnu} @command{diff} and @command{patch} X@cindex projects for directories X XOne should be able to use @sc{gnu} @command{diff} to generate a patch from any Xpair of directory trees, and given the patch and a copy of one such Xtree, use @command{patch} to generate a faithful copy of the other. XUnfortunately, some changes to directory trees cannot be expressed using Xcurrent patch formats; also, @command{patch} does not handle some of the Xexisting formats. These shortcomings motivate the following suggested Xprojects. X X@menu X* Internationalization:: Handling multibyte and varying-width characters. X* Changing Structure:: Handling changes to the directory structure. X* Special Files:: Handling symbolic links, device special files, etc. X* Unusual File Names:: Handling file names that contain unusual characters. X* Time Stamp Order:: Outputting diffs in time stamp order. X* Ignoring Changes:: Ignoring certain changes while showing others. X* Speedups:: Improving performance. X@end menu X X@node Internationalization X@subsection Handling Multibyte and Varying-Width Characters X@cindex multibyte characters X@cindex varying-width characters X X@command{diff}, @command{diff3} and @command{sdiff} treat each line of Xinput as a string of unibyte characters. This can mishandle multibyte Xcharacters in some cases. For example, when asked to ignore spaces, X@command{diff} does not properly ignore a multibyte space character. X XAlso, @command{diff} currently assumes that each byte is one column Xwide, and this assumption is incorrect in some locales, e.g., locales Xthat use UTF-8 encoding. This causes problems with the @option{-y} or X@option{--side-by-side} option of @command{diff}. X XThese problems need to be fixed without unduly affecting the Xperformance of the utilities in unibyte environments. X XThe IBM GNU/Linux Technology Center Internationalization Team has Xproposed some patches to support internationalized @command{diff} X@uref{http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz}. XUnfortunately, these patches are incomplete and are to an older Xversion of @command{diff}, so more work needs to be done in this area. X X@node Changing Structure X@subsection Handling Changes to the Directory Structure X@cindex directory structure changes X X@command{diff} and @command{patch} do not handle some changes to directory Xstructure. For example, suppose one directory tree contains a directory Xnamed @samp{D} with some subsidiary files, and another contains a file Xwith the same name @samp{D}. @samp{diff -r} does not output enough Xinformation for @command{patch} to transform the directory subtree into Xthe file. X XThere should be a way to specify that a file has been removed without Xhaving to include its entire contents in the patch file. There should Xalso be a way to tell @command{patch} that a file was renamed, even if Xthere is no way for @command{diff} to generate such information. XThere should be a way to tell @command{patch} that a file's time stamp Xhas changed, even if its contents have not changed. X XThese problems can be fixed by extending the @command{diff} output format Xto represent changes in directory structure, and extending @command{patch} Xto understand these extensions. X X@node Special Files X@subsection Files that are Neither Directories Nor Regular Files X@cindex special files X XSome files are neither directories nor regular files: they are unusual Xfiles like symbolic links, device special files, named pipes, and Xsockets. Currently, @command{diff} treats symbolic links like regular files; Xit treats other special files like regular files if they are specified Xat the top level, but simply reports their presence when comparing Xdirectories. This means that @command{patch} cannot represent changes Xto such files. For example, if you change which file a symbolic link Xpoints to, @command{diff} outputs the difference between the two files, Xinstead of the change to the symbolic link. X X@c This might not be a good idea; is it wise for root to install devices X@c this way? X@command{diff} should optionally report changes to special files specially, Xand @command{patch} should be extended to understand these extensions. X X@node Unusual File Names X@subsection File Names that Contain Unusual Characters X@cindex file names with unusual characters X XWhen a file name contains an unusual character like a newline or Xwhite space, @samp{diff -r} generates a patch that @command{patch} cannot Xparse. The problem is with format of @command{diff} output, not just with X@command{patch}, because with odd enough file names one can cause X@command{diff} to generate a patch that is syntactically correct but Xpatches the wrong files. The format of @command{diff} output should be Xextended to handle all possible file names. X X@node Time Stamp Order X@subsection Outputting Diffs in Time Stamp Order X XApplying @command{patch} to a multiple-file diff can result in files Xwhose time stamps are out of order. @sc{gnu} @command{patch} has Xoptions to restore the time stamps of the updated files X(@pxref{Patching Time Stamps}), but sometimes it is useful to generate Xa patch that works even if the recipient does not have @sc{gnu} patch, Xor does not use these options. One way to do this would be to Ximplement a @command{diff} option to output diffs in time stamp order. X X@node Ignoring Changes X@subsection Ignoring Certain Changes X XIt would be nice to have a feature for specifying two strings, one in X@var{from-file} and one in @var{to-file}, which should be considered to Xmatch. Thus, if the two strings are @samp{foo} and @samp{bar}, then if Xtwo lines differ only in that @samp{foo} in file 1 corresponds to X@samp{bar} in file 2, the lines are treated as identical. X XIt is not clear how general this feature can or should be, or Xwhat syntax should be used for it. X XA partial substitute is to filter one or both files before comparing, Xe.g.: X X@example Xsed 's/foo/bar/g' file1 | diff - file2 X@end example X XHowever, this outputs the filtered text, not the original. X X@node Speedups X@subsection Improving Performance X XWhen comparing two large directory structures, one of which was Xoriginally copied from the other with time stamps preserved (e.g., Xwith @samp{cp -pR}), it would greatly improve performance if an option Xtold @command{diff} to assume that two files with the same size and Xtime stamps have the same content. @xref{diff Performance}. X X@node Bugs X@section Reporting Bugs X@cindex bug reports X@cindex reporting bugs X XIf you think you have found a bug in @sc{gnu} @command{cmp}, X@command{diff}, @command{diff3}, or @command{sdiff}, please report it Xby electronic mail to the X@uref{http://mail.gnu.org/mailman/listinfo/bug-gnu-utils,GNU utilities Xbug report mailing list} @email{bug-gnu-utils@@gnu.org}. Please send Xbug reports for @sc{gnu} @command{patch} to X@email{bug-patch@@gnu.org}. Send as precise a description of the Xproblem as you can, including the output of the @option{--version} Xoption and sample input files that produce the bug, if applicable. If Xyou have a nontrivial fix for the bug, please send it as well. If you Xhave a patch, please send it too. It may simplify the maintainer's Xjob if the patch is relative to a recent test release, which you can Xfind in the directory @uref{ftp://alpha.gnu.org/gnu/diffutils/}. X X@node Copying This Manual X@appendix Copying This Manual X X@menu X* GNU Free Documentation License:: License for copying this manual. X@end menu X X@include fdl.texi X X@node Index X@appendix Index X X@printindex cp X X@bye END-of-contrib/diff/doc/diff.texi echo x - contrib/diff/doc/diagmeet.note sed 's/^X//' >contrib/diff/doc/diagmeet.note << 'END-of-contrib/diff/doc/diagmeet.note' XHere is a comparison matrix which shows a case in which Xit is possible for the forward and backward scan in `diag' Xto meet along a nonzero length of diagonal simultaneous X(so that bdiag[d] and fdiag[d] are not equal) Xeven though there is no snake on that diagonal at the meeting point. X X X 85 1 1 1 159 1 1 17 X 1 2 3 4 X60 X 1 2 X1 X 2 2 3 4 X71 X 3 3 4 5 X85 X 4 3 4 5 X17 X 5 4 5 X1 X 6 4 5 6 X183 X 7 5 6 7 X10 X 8 6 7 X1 X 9 6 7 8 X12 X 7 8 9 10 X13 X 10 8 9 10 X14 X 10 9 10 X17 X 10 10 X1 X 10 9 10 X1 X 8 10 10 10 X183 X 8 7 9 9 9 X10 X 7 6 8 9 8 8 X1 X 6 5 7 7 X1 X 5 6 6 X1 X 5 5 5 X50 X 5 4 4 4 X1 X 4 3 3 X85 X 5 4 3 2 2 X1 X 2 1 X17 X 5 4 3 2 1 1 X1 X 1 0 X 85 1 1 1 159 1 1 17 X X X X X X X X X END-of-contrib/diff/doc/diagmeet.note echo x - contrib/diff/doc/diff.info sed 's/^X//' >contrib/diff/doc/diff.info << 'END-of-contrib/diff/doc/diff.info' XThis is diff.info, produced by makeinfo version 4.2 from diff.texi. X XThis manual is for GNU Diffutils (version 2.8.1, 5 April 2002), and Xdocuments the GNU `diff', `diff3', `sdiff', and `cmp' commands for Xshowing the differences between files and the GNU `patch' command for Xusing their output to update files. X X Copyright (C) 1992, 1993, 1994, 1998, 2001, 2002 Free Software XFoundation, Inc. X X Permission is granted to copy, distribute and/or modify this X document under the terms of the GNU Free Documentation License, X Version 1.1 or any later version published by the Free Software X Foundation; with no Invariant Sections, with the Front-Cover texts X being "A GNU Manual," and with the Back-Cover Texts as in (a) X below. A copy of the license is included in the section entitled X "GNU Free Documentation License." X X (a) The FSF's Back-Cover Text is: "You have freedom to copy and X modify this GNU Manual, like GNU software. Copies published by X the Free Software Foundation raise funds for GNU development." X XINFO-DIR-SECTION Individual utilities XSTART-INFO-DIR-ENTRY X* cmp: (diff)Invoking cmp. Compare 2 files byte by byte. X* diff: (diff)Invoking diff. Compare 2 files line by line. X* diff3: (diff)Invoking diff3. Compare 3 files line by line. X* patch: (diff)Invoking patch. Apply a patch to a file. X* sdiff: (diff)Invoking sdiff. Merge 2 files side-by-side. XEND-INFO-DIR-ENTRY X XINFO-DIR-SECTION GNU packages XSTART-INFO-DIR-ENTRY X* Diff: (diff). Comparing and merging files. XEND-INFO-DIR-ENTRY X X XFile: diff.info, Node: Top, Next: Overview, Up: (dir) X XComparing and Merging Files X*************************** X XThis manual is for GNU Diffutils (version 2.8.1, 5 April 2002), and Xdocuments the GNU `diff', `diff3', `sdiff', and `cmp' commands for Xshowing the differences between files and the GNU `patch' command for Xusing their output to update files. X X Copyright (C) 1992, 1993, 1994, 1998, 2001, 2002 Free Software XFoundation, Inc. X X Permission is granted to copy, distribute and/or modify this X document under the terms of the GNU Free Documentation License, X Version 1.1 or any later version published by the Free Software X Foundation; with no Invariant Sections, with the Front-Cover texts X being "A GNU Manual," and with the Back-Cover Texts as in (a) X below. A copy of the license is included in the section entitled X "GNU Free Documentation License." X X (a) The FSF's Back-Cover Text is: "You have freedom to copy and X modify this GNU Manual, like GNU software. Copies published by X the Free Software Foundation raise funds for GNU development." X X* Menu: X X* Overview:: Preliminary information. X* Comparison:: What file comparison means. X X* Output Formats:: Formats for two-way difference reports. X* Incomplete Lines:: Lines that lack trailing newlines. X* Comparing Directories:: Comparing files and directories. X* Adjusting Output:: Making `diff' output prettier. X* diff Performance:: Making `diff' smarter or faster. X X* Comparing Three Files:: Formats for three-way difference reports. X* diff3 Merging:: Merging from a common ancestor. X X* Interactive Merging:: Interactive merging with `sdiff'. X X* Merging with patch:: Using `patch' to change old files into new ones. X* Making Patches:: Tips for making and using patch distributions. X X* Invoking cmp:: Compare two files byte by byte. X* Invoking diff:: Compare two files line by line. X* Invoking diff3:: Compare three files line by line. X* Invoking patch:: Apply a diff file to an original. X* Invoking sdiff:: Side-by-side merge of file differences. X X* Standards conformance:: Conformance to the POSIX standard. X* Projects:: If you've found a bug or other shortcoming. X X* Copying This Manual:: How to make copies of this manual. X* Index:: Index. X X XFile: diff.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top X XOverview X******** X X Computer users often find occasion to ask how two files differ. XPerhaps one file is a newer version of the other file. Or maybe the Xtwo files started out as identical copies but were changed by different Xpeople. X X You can use the `diff' command to show differences between two Xfiles, or each corresponding file in two directories. `diff' outputs Xdifferences between files line by line in any of several formats, Xselectable by command line options. This set of differences is often Xcalled a "diff" or "patch". For files that are identical, `diff' Xnormally produces no output; for binary (non-text) files, `diff' Xnormally reports only that they are different. X X You can use the `cmp' command to show the byte and line numbers Xwhere two files differ. `cmp' can also show all the bytes that differ Xbetween the two files, side by side. A way to compare two files Xcharacter by character is the Emacs command `M-x compare-windows'. X*Note Other Window: (emacs)Other Window, for more information on that Xcommand. X X You can use the `diff3' command to show differences among three Xfiles. When two people have made independent changes to a common Xoriginal, `diff3' can report the differences between the original and Xthe two changed versions, and can produce a merged file that contains Xboth persons' changes together with warnings about conflicts. X X You can use the `sdiff' command to merge two files interactively. X X You can use the set of differences produced by `diff' to distribute Xupdates to text files (such as program source code) to other people. XThis method is especially useful when the differences are small compared Xto the complete files. Given `diff' output, you can use the `patch' Xprogram to update, or "patch", a copy of the file. If you think of X`diff' as subtracting one file from another to produce their Xdifference, you can think of `patch' as adding the difference to one Xfile to reproduce the other. X X This manual first concentrates on making diffs, and later shows how Xto use diffs to update files. X X GNU `diff' was written by Paul Eggert, Mike Haertel, David Hayes, XRichard Stallman, and Len Tower. Wayne Davison designed and Ximplemented the unified output format. The basic algorithm is described Xin "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers, X`Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A File XComparison Program", Webb Miller and Eugene W. Myers, X`Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040. XThe algorithm was independently discovered as described in "Algorithms Xfor Approximate String Matching", E. Ukkonen, `Information and Control' XVol. 64, 1985, pp. 100-118. X X GNU `diff3' was written by Randy Smith. GNU `sdiff' was written by XThomas Lord. GNU `cmp' was written by Torbjorn Granlund and David XMacKenzie. X X `patch' was written mainly by Larry Wall and Paul Eggert; several XGNU enhancements were contributed by Wayne Davison and David MacKenzie. XParts of this manual are adapted from a manual page written by Larry XWall, with his permission. X X XFile: diff.info, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top X XWhat Comparison Means X********************* X X There are several ways to think about the differences between two Xfiles. One way to think of the differences is as a series of lines Xthat were deleted from, inserted in, or changed in one file to produce Xthe other file. `diff' compares two files line by line, finds groups of Xlines that differ, and reports each group of differing lines. It can Xreport the differing lines in several formats, which have different Xpurposes. X X GNU `diff' can show whether files are different without detailing Xthe differences. It also provides ways to suppress certain kinds of Xdifferences that are not important to you. Most commonly, such Xdifferences are changes in the amount of white space between words or Xlines. `diff' also provides ways to suppress differences in alphabetic Xcase or in lines that match a regular expression that you provide. XThese options can accumulate; for example, you can ignore changes in Xboth white space and alphabetic case. X X Another way to think of the differences between two files is as a Xsequence of pairs of bytes that can be either identical or different. X`cmp' reports the differences between two files byte by byte, instead Xof line by line. As a result, it is often more useful than `diff' for Xcomparing binary files. For text files, `cmp' is useful mainly when Xyou want to know only whether two files are identical, or whether one Xfile is a prefix of the other. X X To illustrate the effect that considering changes byte by byte can Xhave compared with considering them line by line, think of what happens Xif a single newline character is added to the beginning of a file. If Xthat file is then compared with an otherwise identical file that lacks Xthe newline at the beginning, `diff' will report that a blank line has Xbeen added to the file, while `cmp' will report that almost every byte Xof the two files differs. X X `diff3' normally compares three input files line by line, finds Xgroups of lines that differ, and reports each group of differing lines. XIts output is designed to make it easy to inspect two different sets of Xchanges to the same file. X X* Menu: X X* Hunks:: Groups of differing lines. X* White Space:: Suppressing differences in white space. X* Blank Lines:: Suppressing differences in blank lines. X* Case Folding:: Suppressing differences in alphabetic case. X* Specified Folding:: Suppressing differences that match regular expressions. X* Brief:: Summarizing which files are different. X* Binary:: Comparing binary files or forcing text comparisons. X X XFile: diff.info, Node: Hunks, Next: White Space, Up: Comparison X XHunks X===== X X When comparing two files, `diff' finds sequences of lines common to Xboth files, interspersed with groups of differing lines called "hunks". XComparing two identical files yields one sequence of common lines and Xno hunks, because no lines differ. Comparing two entirely different Xfiles yields no common lines and one large hunk that contains all lines Xof both files. In general, there are many ways to match up lines Xbetween two given files. `diff' tries to minimize the total hunk size Xby finding large sequences of common lines interspersed with small Xhunks of differing lines. X X For example, suppose the file `F' contains the three lines `a', `b', X`c', and the file `G' contains the same three lines in reverse order X`c', `b', `a'. If `diff' finds the line `c' as common, then the command X`diff F G' produces this output: X X 1,2d0 X < a X < b X 3a2,3 X > b X > a X XBut if `diff' notices the common line `b' instead, it produces this Xoutput: X X 1c1 X < a X --- X > c X 3c3 X < c X --- X > a X XIt is also possible to find `a' as the common line. `diff' does not Xalways find an optimal matching between the files; it takes shortcuts Xto run faster. But its output is usually close to the shortest Xpossible. You can adjust this tradeoff with the `--minimal' option X(*note diff Performance::). X X XFile: diff.info, Node: White Space, Next: Blank Lines, Prev: Hunks, Up: Comparison X XSuppressing Differences in Blank and Tab Spacing X================================================ X X The `-E' and `--ignore-tab-expansion' options ignore the distinction Xbetween tabs and spaces on input. A tab is considered to be equivalent Xto the number of spaces to the next tab stop. `diff' assumes that tab Xstops are set every 8 print columns. X X The `-b' and `--ignore-space-change' options are stronger. They Xignore white space at line end, and consider all other sequences of one Xor more white space characters to be equivalent. With these options, X`diff' considers the following two lines to be equivalent, where `$' Xdenotes the line end: X X Here lyeth muche rychnesse in lytell space. -- John Heywood$ X Here lyeth muche rychnesse in lytell space. -- John Heywood $ X X The `-w' and `--ignore-all-space' options are stronger still. They Xignore difference even if one line has white space where the other line Xhas none. "White space" characters include tab, newline, vertical tab, Xform feed, carriage return, and space; some locales may define Xadditional characters to be white space. With these options, `diff' Xconsiders the following two lines to be equivalent, where `$' denotes Xthe line end and `^M' denotes a carriage return: X X Here lyeth muche rychnesse in lytell space.-- John Heywood$ X He relyeth much erychnes seinly tells pace. --John Heywood ^M$ X X XFile: diff.info, Node: Blank Lines, Next: Case Folding, Prev: White Space, Up: Comparison X XSuppressing Differences in Blank Lines X====================================== X X The `-B' and `--ignore-blank-lines' options ignore insertions or Xdeletions of blank lines. These options affect only lines that are Xcompletely empty; they do not affect lines that look empty but contain Xspace or tab characters. With these options, for example, a file Xcontaining X 1. A point is that which has no part. X X 2. A line is breadthless length. X -- Euclid, The Elements, I X Xis considered identical to a file containing X 1. A point is that which has no part. X 2. A line is breadthless length. X X X -- Euclid, The Elements, I X X XFile: diff.info, Node: Case Folding, Next: Specified Folding, Prev: Blank Lines, Up: Comparison X XSuppressing Case Differences X============================ X X GNU `diff' can treat lower case letters as equivalent to their upper Xcase counterparts, so that, for example, it considers `Funky Stuff', X`funky STUFF', and `fUNKy stuFf' to all be the same. To request this, Xuse the `-i' or `--ignore-case' option. X X XFile: diff.info, Node: Specified Folding, Next: Brief, Prev: Case Folding, Up: Comparison X XSuppressing Lines Matching a Regular Expression X=============================================== X X To ignore insertions and deletions of lines that match a X`grep'-style regular expression, use the `-I REGEXP' or X`--ignore-matching-lines=REGEXP' option. You should escape regular Xexpressions that contain shell metacharacters to prevent the shell from Xexpanding them. For example, `diff -I '^[[:digit:]]'' ignores all Xchanges to lines beginning with a digit. X X However, `-I' only ignores the insertion or deletion of lines that Xcontain the regular expression if every changed line in the hunk--every Xinsertion and every deletion--matches the regular expression. In other Xwords, for each nonignorable change, `diff' prints the complete set of Xchanges in its vicinity, including the ignorable ones. X X You can specify more than one regular expression for lines to ignore Xby using more than one `-I' option. `diff' tries to match each line Xagainst each regular expression. X X XFile: diff.info, Node: Brief, Next: Binary, Prev: Specified Folding, Up: Comparison X XSummarizing Which Files Differ X============================== X X When you only want to find out whether files are different, and you Xdon't care what the differences are, you can use the summary output Xformat. In this format, instead of showing the differences between the Xfiles, `diff' simply reports whether files differ. The `-q' and X`--brief' options select this output format. X X This format is especially useful when comparing the contents of two Xdirectories. It is also much faster than doing the normal line by line Xcomparisons, because `diff' can stop analyzing the files as soon as it Xknows that there are any differences. X X You can also get a brief indication of whether two files differ by Xusing `cmp'. For files that are identical, `cmp' produces no output. XWhen the files differ, by default, `cmp' outputs the byte and line Xnumber where the first difference occurs. You can use the `-s' option Xto suppress that information, so that `cmp' produces no output and Xreports whether the files differ using only its exit status (*note XInvoking cmp::). X X Unlike `diff', `cmp' cannot compare directories; it can only compare Xtwo files. X X XFile: diff.info, Node: Binary, Prev: Brief, Up: Comparison X XBinary Files and Forcing Text Comparisons X========================================= X X If `diff' thinks that either of the two files it is comparing is Xbinary (a non-text file), it normally treats that pair of files much as Xif the summary output format had been selected (*note Brief::), and Xreports only that the binary files are different. This is because line Xby line comparisons are usually not meaningful for binary files. X X `diff' determines whether a file is text or binary by checking the Xfirst few bytes in the file; the exact number of bytes is system Xdependent, but it is typically several thousand. If every byte in that Xpart of the file is non-null, `diff' considers the file to be text; Xotherwise it considers the file to be binary. X X Sometimes you might want to force `diff' to consider files to be Xtext. For example, you might be comparing text files that contain null Xcharacters; `diff' would erroneously decide that those are non-text Xfiles. Or you might be comparing documents that are in a format used Xby a word processing system that uses null characters to indicate Xspecial formatting. You can force `diff' to consider all files to be Xtext files, and compare them line by line, by using the `-a' or X`--text' option. If the files you compare using this option do not in Xfact contain text, they will probably contain few newline characters, Xand the `diff' output will consist of hunks showing differences between Xlong lines of whatever characters the files contain. X X You can also force `diff' to consider all files to be binary files, Xand report only whether they differ (but not how). Use the `-q' or X`--brief' option for this. X X Differing binary files are considered to cause trouble because the Xresulting `diff' output does not capture all the differences. This Xtrouble causes `diff' to exit with status 2. However, this trouble Xcannot occur with the `--a' or `--text' option, or with the `-q' or X`--brief' option, as these options both cause `diff' to treat binary Xfiles like text files. X X In operating systems that distinguish between text and binary files, X`diff' normally reads and writes all data as text. Use the `--binary' Xoption to force `diff' to read and write binary data instead. This Xoption has no effect on a POSIX-compliant system like GNU or Xtraditional Unix. However, many personal computer operating systems Xrepresent the end of a line with a carriage return followed by a Xnewline. On such systems, `diff' normally ignores these carriage Xreturns on input and generates them at the end of each output line, but Xwith the `--binary' option `diff' treats each carriage return as just Xanother input character, and does not generate a carriage return at the Xend of each output line. This can be useful when dealing with non-text Xfiles that are meant to be interchanged with POSIX-compliant systems. X X The `--strip-trailing-cr' causes `diff' to treat input lines that Xend in carriage return followed by newline as if they end in plain Xnewline. This can be useful when comparing text that is imperfectly Ximported from many personal computer operating systems. This option Xaffects how lines are read, which in turn affects how they are compared Xand output. X X If you want to compare two files byte by byte, you can use the `cmp' Xprogram with the `-l' option to show the values of each differing byte Xin the two files. With GNU `cmp', you can also use the `-b' option to Xshow the ASCII representation of those bytes. *Note Invoking cmp::, Xfor more information. X X If `diff3' thinks that any of the files it is comparing is binary (a Xnon-text file), it normally reports an error, because such comparisons Xare usually not useful. `diff3' uses the same test as `diff' to decide Xwhether a file is binary. As with `diff', if the input files contain a Xfew non-text bytes but otherwise are like text files, you can force X`diff3' to consider all files to be text files and compare them line by Xline by using the `-a' or `--text' options. X X XFile: diff.info, Node: Output Formats, Next: Incomplete Lines, Prev: Comparison, Up: Top X X`diff' Output Formats X********************* X X `diff' has several mutually exclusive options for output format. XThe following sections describe each format, illustrating how `diff' Xreports the differences between two sample input files. X X* Menu: X X* Sample diff Input:: Sample `diff' input files for examples. X* Normal:: Showing differences without surrounding text. X* Context:: Showing differences with the surrounding text. X* Side by Side:: Showing differences in two columns. X* Scripts:: Generating scripts for other programs. X* If-then-else:: Merging files with if-then-else. X X XFile: diff.info, Node: Sample diff Input, Next: Normal, Up: Output Formats X XTwo Sample Input Files X====================== X X Here are two sample files that we will use in numerous examples to Xillustrate the output of `diff' and how various options can change it. X X This is the file `lao': X X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X The Named is the mother of all things. X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X so we may see their outcome. X The two are the same, X But after they are produced, X they have different names. X X This is the file `tzu': X X The Nameless is the origin of Heaven and Earth; X The named is the mother of all things. X X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X so we may see their outcome. X The two are the same, X But after they are produced, X they have different names. X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X X In this example, the first hunk contains just the first two lines of X`lao', the second hunk contains the fourth line of `lao' opposing the Xsecond and third lines of `tzu', and the last hunk contains just the Xlast three lines of `tzu'. X X XFile: diff.info, Node: Normal, Next: Context, Prev: Sample diff Input, Up: Output Formats X XShowing Differences Without Context X=================================== X X The "normal" `diff' output format shows each hunk of differences Xwithout any surrounding context. Sometimes such output is the clearest Xway to see how lines have changed, without the clutter of nearby Xunchanged lines (although you can get similar results with the context Xor unified formats by using 0 lines of context). However, this format Xis no longer widely used for sending out patches; for that purpose, the Xcontext format (*note Context Format::) and the unified format (*note XUnified Format::) are superior. Normal format is the default for Xcompatibility with older versions of `diff' and the POSIX standard. XUse the `--normal' option to select this output format explicitly. X X* Menu: X X* Detailed Normal:: A detailed description of normal output format. X* Example Normal:: Sample output in the normal format. X X XFile: diff.info, Node: Detailed Normal, Next: Example Normal, Up: Normal X XDetailed Description of Normal Format X------------------------------------- X X The normal output format consists of one or more hunks of Xdifferences; each hunk shows one area where the files differ. Normal Xformat hunks look like this: X X CHANGE-COMMAND X < FROM-FILE-LINE X < FROM-FILE-LINE... X --- X > TO-FILE-LINE X > TO-FILE-LINE... X X There are three types of change commands. Each consists of a line Xnumber or comma-separated range of lines in the first file, a single Xcharacter indicating the kind of change to make, and a line number or Xcomma-separated range of lines in the second file. All line numbers are Xthe original line numbers in each file. The types of change commands Xare: X X`LaR' X Add the lines in range R of the second file after line L of the X first file. For example, `8a12,15' means append lines 12-15 of X file 2 after line 8 of file 1; or, if changing file 2 into file 1, X delete lines 12-15 of file 2. X X`FcT' X Replace the lines in range F of the first file with lines in range X T of the second file. This is like a combined add and delete, but X more compact. For example, `5,7c8,10' means change lines 5-7 of X file 1 to read as lines 8-10 of file 2; or, if changing file 2 into X file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1. X X`RdL' X Delete the lines in range R from the first file; line L is where X they would have appeared in the second file had they not been X deleted. For example, `5,7d3' means delete lines 5-7 of file 1; X or, if changing file 2 into file 1, append lines 5-7 of file 1 X after line 3 of file 2. X X XFile: diff.info, Node: Example Normal, Prev: Detailed Normal, Up: Normal X XAn Example of Normal Format X--------------------------- X X Here is the output of the command `diff lao tzu' (*note Sample diff XInput::, for the complete contents of the two files). Notice that it Xshows only the lines that are different between the two files. X X 1,2d0 X < The Way that can be told of is not the eternal Way; X < The name that can be named is not the eternal name. X 4c2,3 X < The Named is the mother of all things. X --- X > The named is the mother of all things. X > X 11a11,13 X > They both may be called deep and profound. X > Deeper and more profound, X > The door of all subtleties! X X XFile: diff.info, Node: Context, Next: Side by Side, Prev: Normal, Up: Output Formats X XShowing Differences in Their Context X==================================== X X Usually, when you are looking at the differences between files, you Xwill also want to see the parts of the files near the lines that Xdiffer, to help you understand exactly what has changed. These nearby Xparts of the files are called the "context". X X GNU `diff' provides two output formats that show context around the Xdiffering lines: "context format" and "unified format". It can Xoptionally show in which function or section of the file the differing Xlines are found. X X If you are distributing new versions of files to other people in the Xform of `diff' output, you should use one of the output formats that Xshow context so that they can apply the diffs even if they have made Xsmall changes of their own to the files. `patch' can apply the diffs Xin this case by searching in the files for the lines of context around Xthe differing lines; if those lines are actually a few lines away from Xwhere the diff says they are, `patch' can adjust the line numbers Xaccordingly and still apply the diff correctly. *Note Imperfect::, for Xmore information on using `patch' to apply imperfect diffs. X X* Menu: X X* Context Format:: An output format that shows surrounding lines. X* Unified Format:: A more compact output format that shows context. X* Sections:: Showing which sections of the files differences are in. X* Alternate Names:: Showing alternate file names in context headers. X X XFile: diff.info, Node: Context Format, Next: Unified Format, Up: Context X XContext Format X-------------- X X The context output format shows several lines of context around the Xlines that differ. It is the standard format for distributing updates Xto source code. X X To select this output format, use the `-C LINES', X`--context[=LINES]', or `-c' option. The argument LINES that some of Xthese options take is the number of lines of context to show. If you Xdo not specify LINES, it defaults to three. For proper operation, X`patch' typically needs at least two lines of context. X X* Menu: X X* Detailed Context:: A detailed description of the context output format. X* Example Context:: Sample output in context format. X* Less Context:: Another sample with less context. X X XFile: diff.info, Node: Detailed Context, Next: Example Context, Up: Context Format X XDetailed Description of Context Format X...................................... X X The context output format starts with a two-line header, which looks Xlike this: X X *** FROM-FILE FROM-FILE-MODIFICATION-TIME X --- TO-FILE TO-FILE-MODIFICATION TIME X XThe time stamp normally looks like `2002-02-21 23:30:39.942229878 X-0800' to indicate the date, time with fractional seconds, and time Xzone in Internet RFC 2822 format X(ftp://ftp.isi.edu/in-notes/rfc2822.txt). However, a traditional time Xstamp like `Thu Feb 21 23:30:39 2002' is used if the `LC_TIME' locale Xcategory is either `C' or `POSIX'. X X You can change the header's content with the `--label=LABEL' option; Xsee *Note Alternate Names::. X X Next come one or more hunks of differences; each hunk shows one area Xwhere the files differ. Context format hunks look like this: X X *************** X *** FROM-FILE-LINE-RANGE **** X FROM-FILE-LINE X FROM-FILE-LINE... X --- TO-FILE-LINE-RANGE ---- X TO-FILE-LINE X TO-FILE-LINE... X X The lines of context around the lines that differ start with two Xspace characters. The lines that differ between the two files start Xwith one of the following indicator characters, followed by a space Xcharacter: X X`!' X A line that is part of a group of one or more lines that changed X between the two files. There is a corresponding group of lines X marked with `!' in the part of this hunk for the other file. X X`+' X An "inserted" line in the second file that corresponds to nothing X in the first file. X X`-' X A "deleted" line in the first file that corresponds to nothing in X the second file. X X If all of the changes in a hunk are insertions, the lines of XFROM-FILE are omitted. If all of the changes are deletions, the lines Xof TO-FILE are omitted. X X XFile: diff.info, Node: Example Context, Next: Less Context, Prev: Detailed Context, Up: Context Format X XAn Example of Context Format X............................ X X Here is the output of `diff -c lao tzu' (*note Sample diff Input::, Xfor the complete contents of the two files). Notice that up to three Xlines that are not different are shown around each line that is Xdifferent; they are the context lines. Also notice that the first two Xhunks have run together, because their contents overlap. X X *** lao 2002-02-21 23:30:39.942229878 -0800 X --- tzu 2002-02-21 23:30:50.442260588 -0800 X *************** X *** 1,7 **** X - The Way that can be told of is not the eternal Way; X - The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X ! The Named is the mother of all things. X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X --- 1,6 ---- X The Nameless is the origin of Heaven and Earth; X ! The named is the mother of all things. X ! X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X *************** X *** 9,11 **** X --- 8,13 ---- X The two are the same, X But after they are produced, X they have different names. X + They both may be called deep and profound. X + Deeper and more profound, X + The door of all subtleties! X X XFile: diff.info, Node: Less Context, Prev: Example Context, Up: Context Format X XAn Example of Context Format with Less Context X.............................................. X X Here is the output of `diff -C 1 lao tzu' (*note Sample diff XInput::, for the complete contents of the two files). Notice that at Xmost one context line is reported here. X X *** lao 2002-02-21 23:30:39.942229878 -0800 X --- tzu 2002-02-21 23:30:50.442260588 -0800 X *************** X *** 1,5 **** X - The Way that can be told of is not the eternal Way; X - The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X ! The Named is the mother of all things. X Therefore let there always be non-being, X --- 1,4 ---- X The Nameless is the origin of Heaven and Earth; X ! The named is the mother of all things. X ! X Therefore let there always be non-being, X *************** X *** 11 **** X --- 10,13 ---- X they have different names. X + They both may be called deep and profound. X + Deeper and more profound, X + The door of all subtleties! X X XFile: diff.info, Node: Unified Format, Next: Sections, Prev: Context Format, Up: Context X XUnified Format X-------------- X X The unified output format is a variation on the context format that Xis more compact because it omits redundant context lines. To select Xthis output format, use the `-U LINES', `--unified[=LINES]', or `-u' Xoption. The argument LINES is the number of lines of context to show. XWhen it is not given, it defaults to three. X X At present, only GNU `diff' can produce this format and only GNU X`patch' can automatically apply diffs in this format. For proper Xoperation, `patch' typically needs at least three lines of context. X X* Menu: X X* Detailed Unified:: A detailed description of unified format. X* Example Unified:: Sample output in unified format. X X XFile: diff.info, Node: Detailed Unified, Next: Example Unified, Up: Unified Format X XDetailed Description of Unified Format X...................................... X X The unified output format starts with a two-line header, which looks Xlike this: X X --- FROM-FILE FROM-FILE-MODIFICATION-TIME X +++ TO-FILE TO-FILE-MODIFICATION-TIME X XThe time stamp looks like `2002-02-21 23:30:39.942229878 -0800' to Xindicate the date, time with fractional seconds, and time zone. X X You can change the header's content with the `--label=LABEL' option; Xsee *Note Alternate Names::. X X Next come one or more hunks of differences; each hunk shows one area Xwhere the files differ. Unified format hunks look like this: X X @@ FROM-FILE-RANGE TO-FILE-RANGE @@ X LINE-FROM-EITHER-FILE X LINE-FROM-EITHER-FILE... X X The lines common to both files begin with a space character. The Xlines that actually differ between the two files have one of the Xfollowing indicator characters in the left print column: X X`+' X A line was added here to the first file. X X`-' X A line was removed here from the first file. X X XFile: diff.info, Node: Example Unified, Prev: Detailed Unified, Up: Unified Format X XAn Example of Unified Format X............................ X X Here is the output of the command `diff -u lao tzu' (*note Sample Xdiff Input::, for the complete contents of the two files): X X --- lao 2002-02-21 23:30:39.942229878 -0800 X +++ tzu 2002-02-21 23:30:50.442260588 -0800 X @@ -1,7 +1,6 @@ X -The Way that can be told of is not the eternal Way; X -The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X -The Named is the mother of all things. X +The named is the mother of all things. X + X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X @@ -9,3 +8,6 @@ X The two are the same, X But after they are produced, X they have different names. X +They both may be called deep and profound. X +Deeper and more profound, X +The door of all subtleties! X X XFile: diff.info, Node: Sections, Next: Alternate Names, Prev: Unified Format, Up: Context X XShowing Which Sections Differences Are in X----------------------------------------- X X Sometimes you might want to know which part of the files each change Xfalls in. If the files are source code, this could mean which function Xwas changed. If the files are documents, it could mean which chapter or Xappendix was changed. GNU `diff' can show this by displaying the Xnearest section heading line that precedes the differing lines. Which Xlines are "section headings" is determined by a regular expression. X X* Menu: X X* Specified Headings:: Showing headings that match regular expressions. X* C Function Headings:: Showing headings of C functions. X X XFile: diff.info, Node: Specified Headings, Next: C Function Headings, Up: Sections X XShowing Lines That Match Regular Expressions X............................................ X X To show in which sections differences occur for files that are not Xsource code for C or similar languages, use the `-F REGEXP' or X`--show-function-line=REGEXP' option. `diff' considers lines that Xmatch the `grep'-style regular expression REGEXP to be the beginning of Xa section of the file. Here are suggested regular expressions for some Xcommon languages: X X`^[[:alpha:]$_]' X C, C++, Prolog X X`^(' X Lisp X X`^@node' X Texinfo X X This option does not automatically select an output format; in order Xto use it, you must select the context format (*note Context Format::) Xor unified format (*note Unified Format::). In other output formats it Xhas no effect. X X The `-F' and `--show-function-line' options find the nearest Xunchanged line that precedes each hunk of differences and matches the Xgiven regular expression. Then they add that line to the end of the Xline of asterisks in the context format, or to the `@@' line in unified Xformat. If no matching line exists, they leave the output for that Xhunk unchanged. If that line is more than 40 characters long, they Xoutput only the first 40 characters. You can specify more than one Xregular expression for such lines; `diff' tries to match each line Xagainst each regular expression, starting with the last one given. This Xmeans that you can use `-p' and `-F' together, if you wish. X X XFile: diff.info, Node: C Function Headings, Prev: Specified Headings, Up: Sections X XShowing C Function Headings X........................... X X To show in which functions differences occur for C and similar Xlanguages, you can use the `-p' or `--show-c-function' option. This Xoption automatically defaults to the context output format (*note XContext Format::), with the default number of lines of context. You Xcan override that number with `-C LINES' elsewhere in the command line. XYou can override both the format and the number with `-U LINES' Xelsewhere in the command line. X X The `-p' and `--show-c-function' options are equivalent to `-F X'^[[:alpha:]$_]'' if the unified format is specified, otherwise `-c -F X'^[[:alpha:]$_]'' (*note Specified Headings::). GNU `diff' provides Xthem for the sake of convenience. X X XFile: diff.info, Node: Alternate Names, Prev: Sections, Up: Context X XShowing Alternate File Names X---------------------------- X X If you are comparing two files that have meaningless or uninformative Xnames, you might want `diff' to show alternate names in the header of Xthe context and unified output formats. To do this, use the X`--label=LABEL' option. The first time you give this option, its Xargument replaces the name and date of the first file in the header; Xthe second time, its argument replaces the name and date of the second Xfile. If you give this option more than twice, `diff' reports an Xerror. The `--label' option does not affect the file names in the `pr' Xheader when the `-l' or `--paginate' option is used (*note XPagination::). X X Here are the first two lines of the output from `diff -C 2 X--label=original --label=modified lao tzu': X X *** original X --- modified X X XFile: diff.info, Node: Side by Side, Next: Scripts, Prev: Context, Up: Output Formats X XShowing Differences Side by Side X================================ X X `diff' can produce a side by side difference listing of two files. XThe files are listed in two columns with a gutter between them. The Xgutter contains one of the following markers: X Xwhite space X The corresponding lines are in common. That is, either the lines X are identical, or the difference is ignored because of one of the X `--ignore' options (*note White Space::). X X`|' X The corresponding lines differ, and they are either both complete X or both incomplete. X X`<' X The files differ and only the first file contains the line. X X`>' X The files differ and only the second file contains the line. X X`(' X Only the first file contains the line, but the difference is X ignored. X X`)' X Only the second file contains the line, but the difference is X ignored. X X`\' X The corresponding lines differ, and only the first line is X incomplete. X X`/' X The corresponding lines differ, and only the second line is X incomplete. X X Normally, an output line is incomplete if and only if the lines that Xit contains are incomplete; *Note Incomplete Lines::. However, when an Xoutput line represents two differing lines, one might be incomplete Xwhile the other is not. In this case, the output line is complete, but Xits the gutter is marked `\' if the first line is incomplete, `/' if Xthe second line is. X X Side by side format is sometimes easiest to read, but it has Xlimitations. It generates much wider output than usual, and truncates Xlines that are too long to fit. Also, it relies on lining up output Xmore heavily than usual, so its output looks particularly bad if you Xuse varying width fonts, nonstandard tab stops, or nonprinting Xcharacters. X X You can use the `sdiff' command to interactively merge side by side Xdifferences. *Note Interactive Merging::, for more information on Xmerging files. X X* Menu: X X* Side by Side Format:: Controlling side by side output format. X* Example Side by Side:: Sample side by side output. X X XFile: diff.info, Node: Side by Side Format, Next: Example Side by Side, Up: Side by Side X XControlling Side by Side Format X------------------------------- X X The `-y' or `--side-by-side' option selects side by side format. XBecause side by side output lines contain two input lines, the output Xis wider than usual: normally 130 print columns, which can fit onto a Xtraditional printer line. You can set the width of the output with the X`-W COLUMNS' or `--width=COLUMNS' option. The output is split into two Xhalves of equal width, separated by a small gutter to mark differences; Xthe right half is aligned to a tab stop so that tabs line up. Input Xlines that are too long to fit in half of an output line are truncated Xfor output. X X The `--left-column' option prints only the left column of two common Xlines. The `--suppress-common-lines' option suppresses common lines Xentirely. X X XFile: diff.info, Node: Example Side by Side, Prev: Side by Side Format, Up: Side by Side X XAn Example of Side by Side Format X--------------------------------- X X Here is the output of the command `diff -y -W 72 lao tzu' (*note XSample diff Input::, for the complete contents of the two files). X X The Way that can be told of is n < X The name that can be named is no < X The Nameless is the origin of He The Nameless is the origin of He X The Named is the mother of all t | The named is the mother of all t X > X Therefore let there always be no Therefore let there always be no X so we may see their subtlety, so we may see their subtlety, X And let there always be being, And let there always be being, X so we may see their outcome. so we may see their outcome. X The two are the same, The two are the same, X But after they are produced, But after they are produced, X they have different names. they have different names. X > They both may be called deep and X > Deeper and more profound, X > The door of all subtleties! X X XFile: diff.info, Node: Scripts, Next: If-then-else, Prev: Side by Side, Up: Output Formats X XMaking Edit Scripts X=================== X X Several output modes produce command scripts for editing FROM-FILE Xto produce TO-FILE. X X* Menu: X X* ed Scripts:: Using `diff' to produce commands for `ed'. X* Forward ed:: Making forward `ed' scripts. X* RCS:: A special `diff' output format used by RCS. X X XFile: diff.info, Node: ed Scripts, Next: Forward ed, Up: Scripts X X`ed' Scripts X------------ X X `diff' can produce commands that direct the `ed' text editor to Xchange the first file into the second file. Long ago, this was the Xonly output mode that was suitable for editing one file into another Xautomatically; today, with `patch', it is almost obsolete. Use the X`-e' or `--ed' option to select this output format. X X Like the normal format (*note Normal::), this output format does not Xshow any context; unlike the normal format, it does not include the Xinformation necessary to apply the diff in reverse (to produce the first Xfile if all you have is the second file and the diff). X X If the file `d' contains the output of `diff -e old new', then the Xcommand `(cat d && echo w) | ed - old' edits `old' to make it a copy of X`new'. More generally, if `d1', `d2', ..., `dN' contain the outputs of X`diff -e old new1', `diff -e new1 new2', ..., `diff -e newN-1 newN', Xrespectively, then the command `(cat d1 d2 ... dN && echo w) | ed - Xold' edits `old' to make it a copy of `newN'. X X* Menu: X X* Detailed ed:: A detailed description of `ed' format. X* Example ed:: A sample `ed' script. X X XFile: diff.info, Node: Detailed ed, Next: Example ed, Up: ed Scripts X XDetailed Description of `ed' Format X................................... X X The `ed' output format consists of one or more hunks of differences. XThe changes closest to the ends of the files come first so that Xcommands that change the number of lines do not affect how `ed' Xinterprets line numbers in succeeding commands. `ed' format hunks look Xlike this: X X CHANGE-COMMAND X TO-FILE-LINE X TO-FILE-LINE... X . X X Because `ed' uses a single period on a line to indicate the end of Xinput, GNU `diff' protects lines of changes that contain a single Xperiod on a line by writing two periods instead, then writing a Xsubsequent `ed' command to change the two periods into one. The `ed' Xformat cannot represent an incomplete line, so if the second file ends Xin a changed incomplete line, `diff' reports an error and then pretends Xthat a newline was appended. X X There are three types of change commands. Each consists of a line Xnumber or comma-separated range of lines in the first file and a single Xcharacter indicating the kind of change to make. All line numbers are Xthe original line numbers in the file. The types of change commands Xare: X X`La' X Add text from the second file after line L in the first file. For X example, `8a' means to add the following lines after line 8 of file X 1. X X`Rc' X Replace the lines in range R in the first file with the following X lines. Like a combined add and delete, but more compact. For X example, `5,7c' means change lines 5-7 of file 1 to read as the X text file 2. X X`Rd' X Delete the lines in range R from the first file. For example, X `5,7d' means delete lines 5-7 of file 1. X X XFile: diff.info, Node: Example ed, Prev: Detailed ed, Up: ed Scripts X XExample `ed' Script X................... X X Here is the output of `diff -e lao tzu' (*note Sample diff Input::, Xfor the complete contents of the two files): X X 11a X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X . X 4c X The named is the mother of all things. X X . X 1,2d X X XFile: diff.info, Node: Forward ed, Next: RCS, Prev: ed Scripts, Up: Scripts X XForward `ed' Scripts X-------------------- X X `diff' can produce output that is like an `ed' script, but with Xhunks in forward (front to back) order. The format of the commands is Xalso changed slightly: command characters precede the lines they Xmodify, spaces separate line numbers in ranges, and no attempt is made Xto disambiguate hunk lines consisting of a single period. Like `ed' Xformat, forward `ed' format cannot represent incomplete lines. X X Forward `ed' format is not very useful, because neither `ed' nor X`patch' can apply diffs in this format. It exists mainly for Xcompatibility with older versions of `diff'. Use the `-f' or X`--forward-ed' option to select it. X X XFile: diff.info, Node: RCS, Prev: Forward ed, Up: Scripts X XRCS Scripts X----------- X X The RCS output format is designed specifically for use by the XRevision Control System, which is a set of free programs used for Xorganizing different versions and systems of files. Use the `-n' or X`--rcs' option to select this output format. It is like the forward X`ed' format (*note Forward ed::), but it can represent arbitrary Xchanges to the contents of a file because it avoids the forward `ed' Xformat's problems with lines consisting of a single period and with Xincomplete lines. Instead of ending text sections with a line Xconsisting of a single period, each command specifies the number of Xlines it affects; a combination of the `a' and `d' commands are used Xinstead of `c'. Also, if the second file ends in a changed incomplete Xline, then the output also ends in an incomplete line. X X Here is the output of `diff -n lao tzu' (*note Sample diff Input::, Xfor the complete contents of the two files): X X d1 2 X d4 1 X a4 2 X The named is the mother of all things. X X a11 3 X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X X XFile: diff.info, Node: If-then-else, Prev: Scripts, Up: Output Formats X XMerging Files with If-then-else X=============================== X X You can use `diff' to merge two files of C source code. The output Xof `diff' in this format contains all the lines of both files. Lines Xcommon to both files are output just once; the differing parts are Xseparated by the C preprocessor directives `#ifdef NAME' or `#ifndef XNAME', `#else', and `#endif'. When compiling the output, you select Xwhich version to use by either defining or leaving undefined the macro XNAME. X X To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME' Xoption. The argument NAME is the C preprocessor identifier to use in Xthe `#ifdef' and `#ifndef' directives. X X For example, if you change an instance of `wait (&s)' to `waitpid X(-1, &s, 0)' and then merge the old and new files with the X`--ifdef=HAVE_WAITPID' option, then the affected part of your code Xmight look like this: X X do { X #ifndef HAVE_WAITPID X if ((w = wait (&s)) < 0 && errno != EINTR) X #else /* HAVE_WAITPID */ X if ((w = waitpid (-1, &s, 0)) < 0 && errno != EINTR) X #endif /* HAVE_WAITPID */ X return w; X } while (w != child); X X You can specify formats for languages other than C by using line Xgroup formats and line formats, as described in the next sections. X X* Menu: X X* Line Group Formats:: Formats for general if-then-else line groups. X* Line Formats:: Formats for each line in a line group. X* Detailed If-then-else:: A detailed description of if-then-else format. X* Example If-then-else:: Sample if-then-else format output. X X XFile: diff.info, Node: Line Group Formats, Next: Line Formats, Up: If-then-else X XLine Group Formats X------------------ X X Line group formats let you specify formats suitable for many Xapplications that allow if-then-else input, including programming Xlanguages and text formatting languages. A line group format specifies Xthe output format for a contiguous group of similar lines. X X For example, the following command compares the TeX files `old' and X`new', and outputs a merged file in which old regions are surrounded by X`\begin{em}'-`\end{em}' lines, and new regions are surrounded by X`\begin{bf}'-`\end{bf}' lines. X X diff \ X --old-group-format='\begin{em} X %<\end{em} X ' \ X --new-group-format='\begin{bf} X %>\end{bf} X ' \ X old new X X The following command is equivalent to the above example, but it is a Xlittle more verbose, because it spells out the default line group Xformats. X X diff \ X --old-group-format='\begin{em} X %<\end{em} X ' \ X --new-group-format='\begin{bf} X %>\end{bf} X ' \ X --unchanged-group-format='%=' \ X --changed-group-format='\begin{em} X %<\end{em} X \begin{bf} X %>\end{bf} X ' \ X old new X X Here is a more advanced example, which outputs a diff listing with Xheaders containing line numbers in a "plain English" style. X X diff \ X --unchanged-group-format='' \ X --old-group-format='-------- %dn line%(n=1?:s) deleted at %df: X %<' \ X --new-group-format='-------- %dN line%(N=1?:s) added after %de: X %>' \ X --changed-group-format='-------- %dn line%(n=1?:s) changed at %df: X %<-------- to: X %>' \ X old new X X To specify a line group format, use `diff' with one of the options Xlisted below. You can specify up to four line group formats, one for Xeach kind of line group. You should quote FORMAT, because it typically Xcontains shell metacharacters. X X`--old-group-format=FORMAT' X These line groups are hunks containing only lines from the first X file. The default old group format is the same as the changed X group format if it is specified; otherwise it is a format that X outputs the line group as-is. X X`--new-group-format=FORMAT' X These line groups are hunks containing only lines from the second X file. The default new group format is same as the changed group X format if it is specified; otherwise it is a format that outputs X the line group as-is. X X`--changed-group-format=FORMAT' X These line groups are hunks containing lines from both files. The X default changed group format is the concatenation of the old and X new group formats. X X`--unchanged-group-format=FORMAT' X These line groups contain lines common to both files. The default X unchanged group format is a format that outputs the line group X as-is. X X In a line group format, ordinary characters represent themselves; Xconversion specifications start with `%' and have one of the following Xforms. X X`%<' X stands for the lines from the first file, including the trailing X newline. Each line is formatted according to the old line format X (*note Line Formats::). X X`%>' X stands for the lines from the second file, including the trailing X newline. Each line is formatted according to the new line format. X X`%=' X stands for the lines common to both files, including the trailing X newline. Each line is formatted according to the unchanged line X format. X X`%%' X stands for `%'. X X`%c'C'' X where C is a single character, stands for C. C may not be a X backslash or an apostrophe. For example, `%c':'' stands for a X colon, even inside the then-part of an if-then-else format, which X a colon would normally terminate. X X`%c'\O'' X where O is a string of 1, 2, or 3 octal digits, stands for the X character with octal code O. For example, `%c'\0'' stands for a X null character. X X`FN' X where F is a `printf' conversion specification and N is one of the X following letters, stands for N's value formatted with F. X X `e' X The line number of the line just before the group in the old X file. X X `f' X The line number of the first line in the group in the old X file; equals E + 1. X X `l' X The line number of the last line in the group in the old file. X X `m' X The line number of the line just after the group in the old X file; equals L + 1. X X `n' X The number of lines in the group in the old file; equals L - X F + 1. X X `E, F, L, M, N' X Likewise, for lines in the new file. X X The `printf' conversion specification can be `%d', `%o', `%x', or X `%X', specifying decimal, octal, lower case hexadecimal, or upper X case hexadecimal output respectively. After the `%' the following X options can appear in sequence: a series of zero or more flags; an X integer specifying the minimum field width; and a period followed X by an optional integer specifying the minimum number of digits. X The flags are `-' for left-justification, `'' for separating the X digit into groups as specified by the `LC_NUMERIC' locale category, X and `0' for padding with zeros instead of spaces. For example, X `%5dN' prints the number of new lines in the group in a field of X width 5 characters, using the `printf' format `"%5d"'. X X`(A=B?T:E)' X If A equals B then T else E. A and B are each either a decimal X constant or a single letter interpreted as above. This format X spec is equivalent to T if A's value equals B's; otherwise it is X equivalent to E. X X For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no X lines' if N (the number of lines in the group in the the new file) X is 0, to `1 line' if N is 1, and to `%dN lines' otherwise. X X XFile: diff.info, Node: Line Formats, Next: Detailed If-then-else, Prev: Line Group Formats, Up: If-then-else X XLine Formats X------------ X X Line formats control how each line taken from an input file is Xoutput as part of a line group in if-then-else format. X X For example, the following command outputs text with a one-character Xchange indicator to the left of the text. The first character of output Xis `-' for deleted lines, `|' for added lines, and a space for Xunchanged lines. The formats contain newline characters where newlines Xare desired on output. X X diff \ X --old-line-format='-%l X ' \ X --new-line-format='|%l X ' \ X --unchanged-line-format=' %l X ' \ X old new X X To specify a line format, use one of the following options. You Xshould quote FORMAT, since it often contains shell metacharacters. X X`--old-line-format=FORMAT' X formats lines just from the first file. X X`--new-line-format=FORMAT' X formats lines just from the second file. X X`--unchanged-line-format=FORMAT' X formats lines common to both files. X X`--line-format=FORMAT' X formats all lines; in effect, it sets all three above options X simultaneously. X X In a line format, ordinary characters represent themselves; Xconversion specifications start with `%' and have one of the following Xforms. X X`%l' X stands for the contents of the line, not counting its trailing X newline (if any). This format ignores whether the line is X incomplete; *Note Incomplete Lines::. X X`%L' X stands for the contents of the line, including its trailing newline X (if any). If a line is incomplete, this format preserves its X incompleteness. X X`%%' X stands for `%'. X X`%c'C'' X where C is a single character, stands for C. C may not be a X backslash or an apostrophe. For example, `%c':'' stands for a X colon. X X`%c'\O'' X where O is a string of 1, 2, or 3 octal digits, stands for the X character with octal code O. For example, `%c'\0'' stands for a X null character. X X`Fn' X where F is a `printf' conversion specification, stands for the X line number formatted with F. For example, `%.5dn' prints the X line number using the `printf' format `"%.5d"'. *Note Line Group X Formats::, for more about printf conversion specifications. X X The default line format is `%l' followed by a newline character. X X If the input contains tab characters and it is important that they Xline up on output, you should ensure that `%l' or `%L' in a line format Xis just after a tab stop (e.g. by preceding `%l' or `%L' with a tab Xcharacter), or you should use the `-t' or `--expand-tabs' option. X X Taken together, the line and line group formats let you specify many Xdifferent formats. For example, the following command uses a format Xsimilar to normal `diff' format. You can tailor this command to get Xfine control over `diff' output. X X diff \ X --old-line-format='< %l X ' \ X --new-line-format='> %l X ' \ X --old-group-format='%df%(f=l?:,%dl)d%dE X %<' \ X --new-group-format='%dea%dF%(F=L?:,%dL) X %>' \ X --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL) X %<--- X %>' \ X --unchanged-group-format='' \ X old new X X XFile: diff.info, Node: Detailed If-then-else, Next: Example If-then-else, Prev: Line Formats, Up: If-then-else X XDetailed Description of If-then-else Format X------------------------------------------- X X For lines common to both files, `diff' uses the unchanged line group Xformat. For each hunk of differences in the merged output format, if Xthe hunk contains only lines from the first file, `diff' uses the old Xline group format; if the hunk contains only lines from the second Xfile, `diff' uses the new group format; otherwise, `diff' uses the Xchanged group format. X X The old, new, and unchanged line formats specify the output format of Xlines from the first file, lines from the second file, and lines common Xto both files, respectively. X X The option `--ifdef=NAME' is equivalent to the following sequence of Xoptions using shell syntax: X X --old-group-format='#ifndef NAME X %<#endif /* ! NAME */ X ' \ X --new-group-format='#ifdef NAME X %>#endif /* NAME */ X ' \ X --unchanged-group-format='%=' \ X --changed-group-format='#ifndef NAME X %<#else /* NAME */ X %>#endif /* NAME */ X ' X X You should carefully check the `diff' output for proper nesting. XFor example, when using the `-D NAME' or `--ifdef=NAME' option, you Xshould check that if the differing lines contain any of the C Xpreprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or X`#endif', they are nested properly and match. If they don't, you must Xmake corrections manually. It is a good idea to carefully check the Xresulting code anyway to make sure that it really does what you want it Xto; depending on how the input files were produced, the output might Xcontain duplicate or otherwise incorrect code. X X The `patch' `-D NAME' option behaves like the `diff' `-D NAME' Xoption, except it operates on a file and a diff to produce a merged Xfile; *Note patch Options::. X X XFile: diff.info, Node: Example If-then-else, Prev: Detailed If-then-else, Up: If-then-else X XAn Example of If-then-else Format X--------------------------------- X X Here is the output of `diff -DTWO lao tzu' (*note Sample diff XInput::, for the complete contents of the two files): X X #ifndef TWO X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X #endif /* ! TWO */ X The Nameless is the origin of Heaven and Earth; X #ifndef TWO X The Named is the mother of all things. X #else /* TWO */ X The named is the mother of all things. X X #endif /* TWO */ X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X so we may see their outcome. X The two are the same, X But after they are produced, X they have different names. X #ifdef TWO X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X #endif /* TWO */ X X XFile: diff.info, Node: Incomplete Lines, Next: Comparing Directories, Prev: Output Formats, Up: Top X XIncomplete Lines X**************** X X When an input file ends in a non-newline character, its last line is Xcalled an "incomplete line" because its last character is not a Xnewline. All other lines are called "full lines" and end in a newline Xcharacter. Incomplete lines do not match full lines unless differences Xin white space are ignored (*note White Space::). X X An incomplete line is normally distinguished on output from a full Xline by a following line that starts with `\'. However, the RCS format X(*note RCS::) outputs the incomplete line as-is, without any trailing Xnewline or following line. The side by side format normally represents Xincomplete lines as-is, but in some cases uses a `\' or `/' gutter Xmarker; *Note Side by Side::. The if-then-else line format preserves a Xline's incompleteness with `%L', and discards the newline with `%l'; X*Note Line Formats::. Finally, with the `ed' and forward `ed' output Xformats (*note Output Formats::) `diff' cannot represent an incomplete Xline, so it pretends there was a newline and reports an error. X X For example, suppose `F' and `G' are one-byte files that contain Xjust `f' and `g', respectively. Then `diff F G' outputs X X 1c1 X < f X \ No newline at end of file X --- X > g X \ No newline at end of file X X(The exact message may differ in non-English locales.) `diff -n F G' Xoutputs the following without a trailing newline: X X d1 1 X a1 1 X g X X`diff -e F G' reports two errors and outputs the following: X X 1c X g X . X X XFile: diff.info, Node: Comparing Directories, Next: Adjusting Output, Prev: Incomplete Lines, Up: Top X XComparing Directories X********************* X X You can use `diff' to compare some or all of the files in two Xdirectory trees. When both file name arguments to `diff' are Xdirectories, it compares each file that is contained in both Xdirectories, examining file names in alphabetical order as specified by Xthe `LC_COLLATE' locale category. Normally `diff' is silent about Xpairs of files that contain no differences, but if you use the `-s' or X`--report-identical-files' option, it reports pairs of identical files. XNormally `diff' reports subdirectories common to both directories Xwithout comparing subdirectories' files, but if you use the `-r' or X`--recursive' option, it compares every corresponding pair of files in Xthe directory trees, as many levels deep as they go. X X For file names that are in only one of the directories, `diff' Xnormally does not show the contents of the file that exists; it reports Xonly that the file exists in that directory and not in the other. You Xcan make `diff' act as though the file existed but was empty in the Xother directory, so that it outputs the entire contents of the file that Xactually exists. (It is output as either an insertion or a deletion, Xdepending on whether it is in the first or the second directory given.) XTo do this, use the `-N' or `--new-file' option. X X If the older directory contains one or more large files that are not Xin the newer directory, you can make the patch smaller by using the X`--unidirectional-new-file' option instead of `-N'. This option is Xlike `-N' except that it only inserts the contents of files that appear Xin the second directory but not the first (that is, files that were Xadded). At the top of the patch, write instructions for the user Xapplying the patch to remove the files that were deleted before Xapplying the patch. *Note Making Patches::, for more discussion of Xmaking patches for distribution. X X To ignore some files while comparing directories, use the `-x XPATTERN' or `--exclude=PATTERN' option. This option ignores any files Xor subdirectories whose base names match the shell pattern PATTERN. XUnlike in the shell, a period at the start of the base of a file name Xmatches a wildcard at the start of a pattern. You should enclose XPATTERN in quotes so that the shell does not expand it. For example, Xthe option `-x '*.[ao]'' ignores any file whose name ends with `.a' or X`.o'. X X This option accumulates if you specify it more than once. For Xexample, using the options `-x 'RCS' -x '*,v'' ignores any file or Xsubdirectory whose base name is `RCS' or ends with `,v'. X X If you need to give this option many times, you can instead put the Xpatterns in a file, one pattern per line, and use the `-X FILE' or X`--exclude-from=FILE' option. X X If you have been comparing two directories and stopped partway Xthrough, later you might want to continue where you left off. You can Xdo this by using the `-S FILE' or `--starting-file=FILE' option. This Xcompares only the file FILE and all alphabetically later files in the Xtopmost directory level. X X If two directories differ only in that file names are lower case in Xone directory and upper case in the upper, `diff' normally reports many Xdifferences because it compares file names in a case sensitive way. XWith the `--ignore-file-name-case' option, `diff' ignores case Xdifferences in file names, so that for example the contents of the file X`Tao' in one directory are compared to the contents of the file `TAO' Xin the other. The `--no-ignore-file-name-case' option cancels the Xeffect of the `--ignore-file-name-case' option, reverting to the default Xbehavior. X X If an `-x PATTERN', `--exclude=PATTERN', `-X FILE', or X`--exclude-from=FILE' option is specified while the X`--ignore-file-name-case' option is in effect, case is ignored when Xexcluding file names matching the specified patterns. X X XFile: diff.info, Node: Adjusting Output, Next: diff Performance, Prev: Comparing Directories, Up: Top X XMaking `diff' Output Prettier X***************************** X X `diff' provides several ways to adjust the appearance of its output. XThese adjustments can be applied to any output format. X X* Menu: X X* Tabs:: Preserving the alignment of tab stops. X* Pagination:: Page numbering and time-stamping `diff' output. X X XFile: diff.info, Node: Tabs, Next: Pagination, Up: Adjusting Output X XPreserving Tab Stop Alignment X============================= X X The lines of text in some of the `diff' output formats are preceded Xby one or two characters that indicate whether the text is inserted, Xdeleted, or changed. The addition of those characters can cause tabs to Xmove to the next tab stop, throwing off the alignment of columns in the Xline. GNU `diff' provides two ways to make tab-aligned columns line up Xcorrectly. X X The first way is to have `diff' convert all tabs into the correct Xnumber of spaces before outputting them; select this method with the X`-t' or `--expand-tabs' option. `diff' assumes that tab stops are set Xevery 8 print columns. To use this form of output with `patch', you Xmust give `patch' the `-l' or `--ignore-white-space' option (*note XChanged White Space::, for more information). X X The other method for making tabs line up correctly is to add a tab Xcharacter instead of a space after the indicator character at the Xbeginning of the line. This ensures that all following tab characters Xare in the same position relative to tab stops that they were in the Xoriginal files, so that the output is aligned correctly. Its Xdisadvantage is that it can make long lines too long to fit on one line Xof the screen or the paper. It also does not work with the unified Xoutput format, which does not have a space character after the change Xtype indicator character. Select this method with the `-T' or X`--initial-tab' option. X X XFile: diff.info, Node: Pagination, Prev: Tabs, Up: Adjusting Output X XPaginating `diff' Output X======================== X X It can be convenient to have long output page-numbered and Xtime-stamped. The `-l' and `--paginate' options do this by sending the X`diff' output through the `pr' program. Here is what the page header Xmight look like for `diff -lc lao tzu': X X 2002-02-22 14:20 diff -lc lao tzu Page 1 X X XFile: diff.info, Node: diff Performance, Next: Comparing Three Files, Prev: Adjusting Output, Up: Top X X`diff' Performance Tradeoffs X**************************** X X GNU `diff' runs quite efficiently; however, in some circumstances Xyou can cause it to run faster or produce a more compact set of changes. X X One way to improve `diff' performance is to use hard or symbolic Xlinks to files instead of copies. This improves performance because X`diff' normally does not need to read two hard or symbolic links to the Xsame file, since their contents must be identical. For example, Xsuppose you copy a large directory hierarchy, make a few changes to the Xcopy, and then often use `diff -r' to compare the original to the copy. XIf the original files are read-only, you can greatly improve Xperformance by creating the copy using hard or symbolic links (e.g., Xwith GNU `cp -lR' or `cp -sR'). Before editing a file in the copy for Xthe first time, you should break the link and replace it with a regular Xcopy. X X You can also affect the performance of GNU `diff' by giving it Xoptions that change the way it compares files. Performance has more Xthan one dimension. These options improve one aspect of performance at Xthe cost of another, or they improve performance in some cases while Xhurting it in others. X X The way that GNU `diff' determines which lines have changed always Xcomes up with a near-minimal set of differences. Usually it is good Xenough for practical purposes. If the `diff' output is large, you Xmight want `diff' to use a modified algorithm that sometimes produces a Xsmaller set of differences. The `-d' or `--minimal' option does this; Xhowever, it can also cause `diff' to run more slowly than usual, so it Xis not the default behavior. X X When the files you are comparing are large and have small groups of Xchanges scattered throughout them, you can use the X`--speed-large-files' option to make a different modification to the Xalgorithm that `diff' uses. If the input files have a constant small Xdensity of changes, this option speeds up the comparisons without Xchanging the output. If not, `diff' might produce a larger set of Xdifferences; however, the output will still be correct. X X Normally `diff' discards the prefix and suffix that is common to Xboth files before it attempts to find a minimal set of differences. XThis makes `diff' run faster, but occasionally it may produce Xnon-minimal output. The `--horizon-lines=LINES' option prevents `diff' Xfrom discarding the last LINES lines of the prefix and the first LINES Xlines of the suffix. This gives `diff' further opportunities to find a Xminimal output. X X Suppose a run of changed lines includes a sequence of lines at one Xend and there is an identical sequence of lines just outside the other Xend. The `diff' command is free to choose which identical sequence is Xincluded in the hunk. In this case, `diff' normally shifts the hunk's Xboundaries when this merges adjacent hunks, or shifts a hunk's lines Xtowards the end of the file. Merging hunks can make the output look Xnicer in some cases. X X XFile: diff.info, Node: Comparing Three Files, Next: diff3 Merging, Prev: diff Performance, Up: Top X XComparing Three Files X********************* X X Use the program `diff3' to compare three files and show any Xdifferences among them. (`diff3' can also merge files; see *Note diff3 XMerging::). X X The "normal" `diff3' output format shows each hunk of differences Xwithout surrounding context. Hunks are labeled depending on whether Xthey are two-way or three-way, and lines are annotated by their Xlocation in the input files. X X *Note Invoking diff3::, for more information on how to run `diff3'. X X* Menu: X X* Sample diff3 Input:: Sample `diff3' input for examples. X* Detailed diff3 Normal:: A detailed description of normal output format. X* diff3 Hunks:: The format of normal output format. X* Example diff3 Normal:: Sample output in the normal format. X X XFile: diff.info, Node: Sample diff3 Input, Next: Detailed diff3 Normal, Up: Comparing Three Files X XA Third Sample Input File X========================= X X Here is a third sample file that will be used in examples to Xillustrate the output of `diff3' and how various options can change it. XThe first two files are the same that we used for `diff' (*note Sample Xdiff Input::). This is the third sample file, called `tao': X X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X The Nameless is the origin of Heaven and Earth; X The named is the mother of all things. X X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X so we may see their result. X The two are the same, X But after they are produced, X they have different names. X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X X XFile: diff.info, Node: Detailed diff3 Normal, Next: diff3 Hunks, Prev: Sample diff3 Input, Up: Comparing Three Files X XDetailed Description of `diff3' Normal Format X============================================= X X Each hunk begins with a line marked `===='. Three-way hunks have Xplain `====' lines, and two-way hunks have `1', `2', or `3' appended to Xspecify which of the three input files differ in that hunk. The hunks Xcontain copies of two or three sets of input lines each preceded by one Xor two commands identifying where the lines came from. X X Normally, two spaces precede each copy of an input line to Xdistinguish it from the commands. But with the `-T' or `--initial-tab' Xoption, `diff3' uses a tab instead of two spaces; this lines up tabs Xcorrectly. *Note Tabs::, for more information. X X Commands take the following forms: X X`FILE:La' X This hunk appears after line L of file FILE, and contains no lines X in that file. To edit this file to yield the other files, one X must append hunk lines taken from the other files. For example, X `1:11a' means that the hunk follows line 11 in the first file and X contains no lines from that file. X X`FILE:Rc' X This hunk contains the lines in the range R of file FILE. The X range R is a comma-separated pair of line numbers, or just one X number if the range is a singleton. To edit this file to yield the X other files, one must change the specified lines to be the lines X taken from the other files. For example, `2:11,13c' means that X the hunk contains lines 11 through 13 from the second file. X X If the last line in a set of input lines is incomplete (*note XIncomplete Lines::), it is distinguished on output from a full line by Xa following line that starts with `\'. X X XFile: diff.info, Node: diff3 Hunks, Next: Example diff3 Normal, Prev: Detailed diff3 Normal, Up: Comparing Three Files X X`diff3' Hunks X============= X X Groups of lines that differ in two or three of the input files are Xcalled "diff3 hunks", by analogy with `diff' hunks (*note Hunks::). If Xall three input files differ in a `diff3' hunk, the hunk is called a X"three-way hunk"; if just two input files differ, it is a "two-way Xhunk". X X As with `diff', several solutions are possible. When comparing the Xfiles `A', `B', and `C', `diff3' normally finds `diff3' hunks by Xmerging the two-way hunks output by the two commands `diff A B' and X`diff A C'. This does not necessarily minimize the size of the output, Xbut exceptions should be rare. X X For example, suppose `F' contains the three lines `a', `b', `f', `G' Xcontains the lines `g', `b', `g', and `H' contains the lines `a', `b', X`h'. `diff3 F G H' might output the following: X X ====2 X 1:1c X 3:1c X a X 2:1c X g X ==== X 1:3c X f X 2:3c X g X 3:3c X h X Xbecause it found a two-way hunk containing `a' in the first and third Xfiles and `g' in the second file, then the single line `b' common to Xall three files, then a three-way hunk containing the last line of each Xfile. X X XFile: diff.info, Node: Example diff3 Normal, Prev: diff3 Hunks, Up: Comparing Three Files X XAn Example of `diff3' Normal Format X=================================== X X Here is the output of the command `diff3 lao tzu tao' (*note Sample Xdiff3 Input::, for the complete contents of the files). Notice that it Xshows only the lines that are different among the three files. X X ====2 X 1:1,2c X 3:1,2c X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X 2:0a X ====1 X 1:4c X The Named is the mother of all things. X 2:2,3c X 3:4,5c X The named is the mother of all things. X X ====3 X 1:8c X 2:7c X so we may see their outcome. X 3:9c X so we may see their result. X ==== X 1:11a X 2:11,13c X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X 3:13,14c X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X X XFile: diff.info, Node: diff3 Merging, Next: Interactive Merging, Prev: Comparing Three Files, Up: Top X XMerging From a Common Ancestor X****************************** X X When two people have made changes to copies of the same file, X`diff3' can produce a merged output that contains both sets of changes Xtogether with warnings about conflicts. X X One might imagine programs with names like `diff4' and `diff5' to Xcompare more than three files simultaneously, but in practice the need Xrarely arises. You can use `diff3' to merge three or more sets of Xchanges to a file by merging two change sets at a time. X X `diff3' can incorporate changes from two modified versions into a Xcommon preceding version. This lets you merge the sets of changes Xrepresented by the two newer files. Specify the common ancestor version Xas the second argument and the two newer versions as the first and third Xarguments, like this: X X diff3 MINE OLDER YOURS X XYou can remember the order of the arguments by noting that they are in Xalphabetical order. X X You can think of this as subtracting OLDER from YOURS and adding the Xresult to MINE, or as merging into MINE the changes that would turn XOLDER into YOURS. This merging is well-defined as long as MINE and XOLDER match in the neighborhood of each such change. This fails to be Xtrue when all three input files differ or when only OLDER differs; we Xcall this a "conflict". When all three input files differ, we call the Xconflict an "overlap". X X `diff3' gives you several ways to handle overlaps and conflicts. XYou can omit overlaps or conflicts, or select only overlaps, or mark Xconflicts with special `<<<<<<<' and `>>>>>>>' lines. X X `diff3' can output the merge results as an `ed' script that that can Xbe applied to the first file to yield the merged output. However, it Xis usually better to have `diff3' generate the merged output directly; Xthis bypasses some problems with `ed'. X X* Menu: X X* Which Changes:: Selecting changes to incorporate. X* Marking Conflicts:: Marking conflicts. X* Bypassing ed:: Generating merged output directly. X* Merging Incomplete Lines:: How `diff3' merges incomplete lines. X* Saving the Changed File:: Emulating System V behavior. X X XFile: diff.info, Node: Which Changes, Next: Marking Conflicts, Up: diff3 Merging X XSelecting Which Changes to Incorporate X====================================== X X You can select all unmerged changes from OLDER to YOURS for merging Xinto MINE with the `-e' or `--ed' option. You can select only the Xnonoverlapping unmerged changes with `-3' or `--easy-only', and you can Xselect only the overlapping changes with `-x' or `--overlap-only'. X X The `-e', `-3' and `-x' options select only "unmerged changes", i.e. Xchanges where MINE and YOURS differ; they ignore changes from OLDER to XYOURS where MINE and YOURS are identical, because they assume that such Xchanges have already been merged. If this assumption is not a safe Xone, you can use the `-A' or `--show-all' option (*note Marking XConflicts::). X X Here is the output of the command `diff3' with each of these three Xoptions (*note Sample diff3 Input::, for the complete contents of the Xfiles). Notice that `-e' outputs the union of the disjoint sets of Xchanges output by `-3' and `-x'. X X Output of `diff3 -e lao tzu tao': X 11a X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X . X 8c X so we may see their result. X . X X Output of `diff3 -3 lao tzu tao': X 8c X so we may see their result. X . X X Output of `diff3 -x lao tzu tao': X 11a X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X . X X XFile: diff.info, Node: Marking Conflicts, Next: Bypassing ed, Prev: Which Changes, Up: diff3 Merging X XMarking Conflicts X================= X X `diff3' can mark conflicts in the merged output by bracketing them Xwith special marker lines. A conflict that comes from two files A and XB is marked as follows: X X <<<<<<< A X lines from A X ======= X lines from B X >>>>>>> B X X A conflict that comes from three files A, B and C is marked as Xfollows: X X <<<<<<< A X lines from A X ||||||| B X lines from B X ======= X lines from C X >>>>>>> C X X The `-A' or `--show-all' option acts like the `-e' option, except Xthat it brackets conflicts, and it outputs all changes from OLDER to XYOURS, not just the unmerged changes. Thus, given the sample input Xfiles (*note Sample diff3 Input::), `diff3 -A lao tzu tao' puts Xbrackets around the conflict where only `tzu' differs: X X <<<<<<< tzu X ======= X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X >>>>>>> tao X X And it outputs the three-way conflict as follows: X X <<<<<<< lao X ||||||| tzu X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X ======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X >>>>>>> tao X X The `-E' or `--show-overlap' option outputs less information than Xthe `-A' or `--show-all' option, because it outputs only unmerged Xchanges, and it never outputs the contents of the second file. Thus Xthe `-E' option acts like the `-e' option, except that it brackets the Xfirst and third files from three-way overlapping changes. Similarly, X`-X' acts like `-x', except it brackets all its (necessarily Xoverlapping) changes. For example, for the three-way overlapping Xchange above, the `-E' and `-X' options output the following: X X <<<<<<< lao X ======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X >>>>>>> tao X X If you are comparing files that have meaningless or uninformative Xnames, you can use the `-L LABEL' or `--label=LABEL' option to show Xalternate names in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets. XThis option can be given up to three times, once for each input file. XThus `diff3 -A -L X -L Y -L Z A B C' acts like `diff3 -A A B C', except Xthat the output looks like it came from files named `X', `Y' and `Z' Xrather than from files named `A', `B' and `C'. X X XFile: diff.info, Node: Bypassing ed, Next: Merging Incomplete Lines, Prev: Marking Conflicts, Up: diff3 Merging X XGenerating the Merged Output Directly X===================================== X X With the `-m' or `--merge' option, `diff3' outputs the merged file Xdirectly. This is more efficient than using `ed' to generate it, and Xworks even with non-text files that `ed' would reject. If you specify X`-m' without an `ed' script option, `-A' (`--show-all') is assumed. X X For example, the command `diff3 -m lao tzu tao' (*note Sample diff3 XInput:: for a copy of the input files) would output the following: X X <<<<<<< tzu X ======= X The Way that can be told of is not the eternal Way; X The name that can be named is not the eternal name. X >>>>>>> tao X The Nameless is the origin of Heaven and Earth; X The Named is the mother of all things. X Therefore let there always be non-being, X so we may see their subtlety, X And let there always be being, X so we may see their result. X The two are the same, X But after they are produced, X they have different names. X <<<<<<< lao X ||||||| tzu X They both may be called deep and profound. X Deeper and more profound, X The door of all subtleties! X ======= X X -- The Way of Lao-Tzu, tr. Wing-tsit Chan X >>>>>>> tao X X XFile: diff.info, Node: Merging Incomplete Lines, Next: Saving the Changed File, Prev: Bypassing ed, Up: diff3 Merging X XHow `diff3' Merges Incomplete Lines X=================================== X X With `-m', incomplete lines (*note Incomplete Lines::) are simply Xcopied to the output as they are found; if the merged output ends in an Xconflict and one of the input files ends in an incomplete line, Xsucceeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere Xother than the start of a line because they are appended to the Xincomplete line. X X Without `-m', if an `ed' script option is specified and an Xincomplete line is found, `diff3' generates a warning and acts as if a Xnewline had been present. X X XFile: diff.info, Node: Saving the Changed File, Prev: Merging Incomplete Lines, Up: diff3 Merging X XSaving the Changed File X======================= X X Traditional Unix `diff3' generates an `ed' script without the Xtrailing `w' and `q' commands that save the changes. System V `diff3' Xgenerates these extra commands. GNU `diff3' normally behaves like Xtraditional Unix `diff3', but with the `-i' option it behaves like XSystem V `diff3' and appends the `w' and `q' commands. X X The `-i' option requires one of the `ed' script options `-AeExX3', Xand is incompatible with the merged output option `-m'. X X XFile: diff.info, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: Top X XInteractive Merging with `sdiff' X******************************** X X With `sdiff', you can merge two files interactively based on a Xside-by-side `-y' format comparison (*note Side by Side::). Use `-o XFILE' or `--output=FILE' to specify where to put the merged text. X*Note Invoking sdiff::, for more details on the options to `sdiff'. X X Another way to merge files interactively is to use the Emacs Lisp Xpackage `emerge'. *Note emerge: (emacs)emerge, for more information. X X* Menu: X X* sdiff Option Summary:: Summary of `sdiff' options. X* Merge Commands:: Merging two files interactively. X X XFile: diff.info, Node: sdiff Option Summary, Next: Merge Commands, Up: Interactive Merging X XSpecifying `diff' Options to `sdiff' X==================================== X X The following `sdiff' options have the same meaning as for `diff'. X*Note diff Options::, for the use of these options. X X -a -b -d -i -t -v X -B -E -I REGEXP X X --ignore-blank-lines --ignore-case X --ignore-matching-lines=REGEXP --ignore-space-change X --ignore-tab-expansion X --left-column --minimal --speed-large-files X --strip-trailing-cr --suppress-common-lines --expand-tabs X --text --version --width=COLUMNS X X For historical reasons, `sdiff' has alternate names for some Xoptions. The `-l' option is equivalent to the `--left-column' option, Xand similarly `-s' is equivalent to `--suppress-common-lines'. The Xmeaning of the `sdiff' `-w' and `-W' options is interchanged from that Xof `diff': with `sdiff', `-w COLUMNS' is equivalent to X`--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'. X`sdiff' without the `-o' option is equivalent to `diff' with the `-y' Xor `--side-by-side' option (*note Side by Side::). X X XFile: diff.info, Node: Merge Commands, Prev: sdiff Option Summary, Up: Interactive Merging X XMerge Commands X============== X X Groups of common lines, with a blank gutter, are copied from the Xfirst file to the output. After each group of differing lines, `sdiff' Xprompts with `%' and pauses, waiting for one of the following commands. XFollow each command with . X X`e' X Discard both versions. Invoke a text editor on an empty temporary X file, then copy the resulting file to the output. X X`eb' X Concatenate the two versions, edit the result in a temporary file, X then copy the edited result to the output. X X`ed' X Like `eb', except precede each version with a header that shows X what file and lines the version came from. X X`el' X Edit a copy of the left version, then copy the result to the X output. X X`er' X Edit a copy of the right version, then copy the result to the X output. X X`l' X Copy the left version to the output. X X`q' X Quit. X X`r' X Copy the right version to the output. X X`s' X Silently copy common lines. X X`v' X Verbosely copy common lines. This is the default. X X The text editor invoked is specified by the `EDITOR' environment Xvariable if it is set. The default is system-dependent. X X XFile: diff.info, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up: Top X XMerging with `patch' X******************** X X `patch' takes comparison output produced by `diff' and applies the Xdifferences to a copy of the original file, producing a patched Xversion. With `patch', you can distribute just the changes to a set of Xfiles instead of distributing the entire file set; your correspondents Xcan apply `patch' to update their copy of the files with your changes. X`patch' automatically determines the diff format, skips any leading or Xtrailing headers, and uses the headers to determine which file to Xpatch. This lets your correspondents feed a mail message containing a Xdifference listing directly to `patch'. X X `patch' detects and warns about common problems like forward Xpatches. It saves any patches that it could not apply. It can also Xmaintain a `patchlevel.h' file to ensure that your correspondents apply Xdiffs in the proper order. X X `patch' accepts a series of diffs in its standard input, usually Xseparated by headers that specify which file to patch. It applies X`diff' hunks (*note Hunks::) one by one. If a hunk does not exactly Xmatch the original file, `patch' uses heuristics to try to patch the Xfile as well as it can. If no approximate match can be found, `patch' Xrejects the hunk and skips to the next hunk. `patch' normally replaces Xeach file F with its new version, putting reject hunks (if any) into X`F.rej'. X X *Note Invoking patch::, for detailed information on the options to X`patch'. X X* Menu: X X* patch Input:: Selecting the type of `patch' input. X* Revision Control:: Getting files from RCS, SCCS, etc. X* Imperfect:: Dealing with imperfect patches. X* Creating and Removing:: Creating and removing files with a patch. X* Patching Time Stamps:: Updating time stamps on patched files. X* Multiple Patches:: Handling multiple patches in a file. X* patch Directories:: Changing directory and stripping directories. X* Backups:: Whether backup files are made. X* Backup Names:: Backup file names. X* Reject Names:: Reject file names. X* patch Messages:: Messages and questions `patch' can produce. X* patch and POSIX:: Conformance to the POSIX standard. X* patch and Tradition:: GNU versus traditional `patch'. X X XFile: diff.info, Node: patch Input, Next: Revision Control, Up: Merging with patch X XSelecting the `patch' Input Format X================================== X X `patch' normally determines which `diff' format the patch file uses Xby examining its contents. For patch files that contain particularly Xconfusing leading text, you might need to use one of the following Xoptions to force `patch' to interpret the patch file as a certain Xformat of diff. The output formats listed here are the only ones that X`patch' can understand. X X`-c' X`--context' X context diff. X X`-e' X`--ed' X `ed' script. X X`-n' X`--normal' X normal diff. X X`-u' X`--unified' X unified diff. X X XFile: diff.info, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch X XRevision Control X================ X X If a nonexistent input file is under a revision control system Xsupported by `patch', `patch' normally asks the user whether to get (or Xcheck out) the file from the revision control system. Patch currently Xsupports RCS, ClearCase and SCCS. Under RCS and SCCS, `patch' also Xasks when the input file is read-only and matches the default version Xin the revision control system. X X The `-g NUM' or `--get=NUM' affects access to files under supported Xrevision control systems. If NUM is positive, `patch' gets the file Xwithout asking the user; if zero, `patch' neither asks the user nor Xgets the file; and if negative, `patch' asks the user before getting Xthe file. The default value of NUM is given by the value of the X`PATCH_GET' environment variable if it is set; if not, the default Xvalue is zero if `patch' is conforming to POSIX, negative otherwise. X*Note patch and POSIX::. X X The choice of revision control system is unaffected by the X`VERSION_CONTROL' environment variable (*note Backup Names::). X X XFile: diff.info, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch X XApplying Imperfect Patches X========================== X X `patch' tries to skip any leading text in the patch file, apply the Xdiff, and then skip any trailing text. Thus you can feed a mail Xmessage directly to `patch', and it should work. If the entire diff is Xindented by a constant amount of white space, `patch' automatically Xignores the indentation. If a context diff contains trailing carriage Xreturn on each line, `patch' automatically ignores the carriage return. XIf a context diff has been encapsulated by prepending `- ' to lines Xbeginning with `-' as per Internet RFC 934 X(ftp://ftp.isi.edu/in-notes/rfc934.txt), `patch' automatically Xunencapsulates the input. X X However, certain other types of imperfect input require user Xintervention or testing. X X* Menu: X X* Changed White Space:: When tabs and spaces don't match exactly. X* Reversed Patches:: Applying reversed patches correctly. X* Inexact:: Helping `patch' find close matches. X* Dry Runs:: Predicting what `patch' will do. X X XFile: diff.info, Node: Changed White Space, Next: Reversed Patches, Up: Imperfect X XApplying Patches with Changed White Space X----------------------------------------- X X Sometimes mailers, editors, or other programs change spaces into Xtabs, or vice versa. If this happens to a patch file or an input file, Xthe files might look the same, but `patch' will not be able to match Xthem properly. If this problem occurs, use the `-l' or X`--ignore-white-space' option, which makes `patch' compare blank Xcharacters (i.e. spaces and tabs) loosely so that any nonempty sequence Xof blanks in the patch file matches any nonempty sequence of blanks in Xthe input files. Non-blank characters must still match exactly. Each Xline of the context must still match a line in the input file. X X XFile: diff.info, Node: Reversed Patches, Next: Inexact, Prev: Changed White Space, Up: Imperfect X XApplying Reversed Patches X------------------------- X X Sometimes people run `diff' with the new file first instead of Xsecond. This creates a diff that is "reversed". To apply such Xpatches, give `patch' the `-R' or `--reverse' option. `patch' then Xattempts to swap each hunk around before applying it. Rejects come out Xin the swapped format. X X Often `patch' can guess that the patch is reversed. If the first Xhunk of a patch fails, `patch' reverses the hunk to see if it can apply Xit that way. If it can, `patch' asks you if you want to have the `-R' Xoption set; if it can't, `patch' continues to apply the patch normally. XThis method cannot detect a reversed patch if it is a normal diff and Xthe first command is an append (which should have been a delete) since Xappends always succeed, because a null context matches anywhere. But Xmost patches add or change lines rather than delete them, so most Xreversed normal diffs begin with a delete, which fails, and `patch' Xnotices. X X If you apply a patch that you have already applied, `patch' thinks Xit is a reversed patch and offers to un-apply the patch. This could be Xconstrued as a feature. If you did this inadvertently and you don't Xwant to un-apply the patch, just answer `n' to this offer and to the Xsubsequent "apply anyway" question--or type `C-c' to kill the `patch' Xprocess. X X XFile: diff.info, Node: Inexact, Next: Dry Runs, Prev: Reversed Patches, Up: Imperfect X XHelping `patch' Find Inexact Matches X------------------------------------ X X For context diffs, and to a lesser extent normal diffs, `patch' can Xdetect when the line numbers mentioned in the patch are incorrect, and Xit attempts to find the correct place to apply each hunk of the patch. XAs a first guess, it takes the line number mentioned in the hunk, plus Xor minus any offset used in applying the previous hunk. If that is not Xthe correct place, `patch' scans both forward and backward for a set of Xlines matching the context given in the hunk. X X First `patch' looks for a place where all lines of the context Xmatch. If it cannot find such a place, and it is reading a context or Xunified diff, and the maximum fuzz factor is set to 1 or more, then X`patch' makes another scan, ignoring the first and last line of Xcontext. If that fails, and the maximum fuzz factor is set to 2 or Xmore, it makes another scan, ignoring the first two and last two lines Xof context are ignored. It continues similarly if the maximum fuzz Xfactor is larger. X X The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor Xto LINES. This option only applies to context and unified diffs; it Xignores up to LINES lines while looking for the place to install a Xhunk. Note that a larger fuzz factor increases the odds of making a Xfaulty patch. The default fuzz factor is 2; there is no point to Xsetting it to more than the number of lines of context in the diff, Xordinarily 3. X X If `patch' cannot find a place to install a hunk of the patch, it Xwrites the hunk out to a reject file (*note Reject Names::, for Xinformation on how reject files are named). It writes out rejected Xhunks in context format no matter what form the input patch is in. If Xthe input is a normal or `ed' diff, many of the contexts are simply Xnull. The line numbers on the hunks in the reject file may be Xdifferent from those in the patch file: they show the approximate Xlocation where `patch' thinks the failed hunks belong in the new file Xrather than in the old one. X X If the `--verbose' option is given, then as it completes each hunk X`patch' tells you whether the hunk succeeded or failed, and if it Xfailed, on which line (in the new file) `patch' thinks the hunk should Xgo. If this is different from the line number specified in the diff, Xit tells you the offset. A single large offset _may_ indicate that X`patch' installed a hunk in the wrong place. `patch' also tells you if Xit used a fuzz factor to make the match, in which case you should also Xbe slightly suspicious. X X `patch' cannot tell if the line numbers are off in an `ed' script, Xand can only detect wrong line numbers in a normal diff when it finds a Xchange or delete command. It may have the same problem with a context Xdiff using a fuzz factor equal to or greater than the number of lines Xof context shown in the diff (typically 3). In these cases, you should Xprobably look at a context diff between your original and patched input Xfiles to see if the changes make sense. Compiling without errors is a Xpretty good indication that the patch worked, but not a guarantee. X X A patch against an empty file applies to a nonexistent file, and vice Xversa. *Note Creating and Removing::. X X `patch' usually produces the correct results, even when it must make Xmany guesses. However, the results are guaranteed only when the patch Xis applied to an exact copy of the file that the patch was generated Xfrom. X X XFile: diff.info, Node: Dry Runs, Prev: Inexact, Up: Imperfect X XPredicting what `patch' will do X------------------------------- X X It may not be obvious in advance what `patch' will do with a Xcomplicated or poorly formatted patch. If you are concerned that the Xinput might cause `patch' to modify the wrong files, you can use the X`--dry-run' option, which causes `patch' to print the results of Xapplying patches without actually changing any files. You can then Xinspect the diagnostics generated by the dry run to see whether `patch' Xwill modify the files that you expect. If the patch does not do what Xyou want, you can modify the patch (or the other options to `patch') Xand try another dry run. Once you are satisfied with the proposed Xpatch you can apply it by invoking `patch' as before, but this time Xwithout the `--dry-run' option. X X XFile: diff.info, Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch X XCreating and Removing Files X=========================== X X Sometimes when comparing two directories, a file may exist in one Xdirectory but not the other. If you give `diff' the `-N' or X`--new-file' option, or if you supply an old or new file that is named X`/dev/null' or is empty and is dated the Epoch (1970-01-01 00:00:00 XUTC), `diff' outputs a patch that adds or deletes the contents of this Xfile. When given such a patch, `patch' normally creates a new file or Xremoves the old file. However, when conforming to POSIX (*note patch Xand POSIX::), `patch' does not remove the old file, but leaves it empty. XThe `-E' or `--remove-empty-files' option causes `patch' to remove Xoutput files that are empty after applying a patch, even if the patch Xdoes not appear to be one that removed the file. X X If the patch appears to create a file that already exists, `patch' Xasks for confirmation before applying the patch. X X XFile: diff.info, Node: Patching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch X XUpdating Time Stamps on Patched Files X===================================== X X When `patch' updates a file, it normally sets the file's Xlast-modified time stamp to the current time of day. If you are using X`patch' to track a software distribution, this can cause `make' to Xincorrectly conclude that a patched file is out of date. For example, Xif `syntax.c' depends on `syntax.y', and `patch' updates `syntax.c' and Xthen `syntax.y', then `syntax.c' will normally appear to be out of date Xwith respect to `syntax.y' even though its contents are actually up to Xdate. X X The `-Z' or `--set-utc' option causes `patch' to set a patched Xfile's modification and access times to the time stamps given in Xcontext diff headers. If the context diff headers do not specify a Xtime zone, they are assumed to use Coordinated Universal Time (UTC, Xoften known as GMT). X X The `-T' or `--set-time' option acts like `-Z' or `--set-utc', Xexcept that it assumes that the context diff headers' time stamps use Xlocal time instead of UTC. This option is not recommended, because Xpatches using local time cannot easily be used by people in other time Xzones, and because local time stamps are ambiguous when local clocks Xmove backwards during daylight-saving time adjustments. If the context Xdiff headers specify a time zone, this option is equivalent to `-Z' or X`--set-utc'. X X `patch' normally refrains from setting a file's time stamps if the Xfile's original last-modified time stamp does not match the time given Xin the diff header, of if the file's contents do not exactly match the Xpatch. However, if the `-f' or `--force' option is given, the file's Xtime stamps are set regardless. X X Due to the limitations of the current `diff' format, `patch' cannot Xupdate the times of files whose contents have not changed. Also, if Xyou set file time stamps to values other than the current time of day, Xyou should also remove (e.g., with `make clean') all files that depend Xon the patched files, so that later invocations of `make' do not get Xconfused by the patched files' times. X X XFile: diff.info, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merging with patch X XMultiple Patches in a File X========================== X X If the patch file contains more than one patch, and if you do not Xspecify an input file on the command line, `patch' tries to apply each Xpatch as if they came from separate patch files. This means that it Xdetermines the name of the file to patch for each patch, and that it Xexamines the leading text before each patch for file names and Xprerequisite revision level (*note Making Patches::, for more on that Xtopic). X X `patch' uses the following rules to intuit a file name from the Xleading text before a patch. First, `patch' takes an ordered list of Xcandidate file names as follows: X X * If the header is that of a context diff, `patch' takes the old and X new file names in the header. A name is ignored if it does not X have enough slashes to satisfy the `-pNUM' or `--strip=NUM' X option. The name `/dev/null' is also ignored. X X * If there is an `Index:' line in the leading garbage and if either X the old and new names are both absent or if `patch' is conforming X to POSIX, `patch' takes the name in the `Index:' line. X X * For the purpose of the following rules, the candidate file names X are considered to be in the order (old, new, index), regardless of X the order that they appear in the header. X XThen `patch' selects a file name from the candidate list as follows: X X * If some of the named files exist, `patch' selects the first name X if conforming to POSIX, and the best name otherwise. X X * If `patch' is not ignoring RCS, ClearCase, and SCCS (*note X Revision Control::), and no named files exist but an RCS, X ClearCase, or SCCS master is found, `patch' selects the first X named file with an RCS, ClearCase, or SCCS master. X X * If no named files exist, no RCS, ClearCase, or SCCS master was X found, some names are given, `patch' is not conforming to POSIX, X and the patch appears to create a file, `patch' selects the best X name requiring the creation of the fewest directories. X X * If no file name results from the above heuristics, you are asked X for the name of the file to patch, and `patch' selects that name. X X To determine the "best" of a nonempty list of file names, `patch' Xfirst takes all the names with the fewest path name components; of Xthose, it then takes all the names with the shortest basename; of Xthose, it then takes all the shortest names; finally, it takes the Xfirst remaining name. X X *Note patch and POSIX::, to see whether `patch' is conforming to XPOSIX. X X XFile: diff.info, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging with patch X XApplying Patches in Other Directories X===================================== X X The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch' Xmakes directory DIRECTORY the current directory for interpreting both Xfile names in the patch file, and file names given as arguments to Xother options (such as `-B' and `-o'). For example, while in a mail Xreading program, you can patch a file in the `/usr/src/emacs' directory Xdirectly from a message containing the patch like this: X X | patch -d /usr/src/emacs X X Sometimes the file names given in a patch contain leading Xdirectories, but you keep your files in a directory different from the Xone given in the patch. In those cases, you can use the `-pNUMBER' or X`--strip=NUMBER' option to set the file name strip count to NUMBER. XThe strip count tells `patch' how many slashes, along with the directory Xnames between them, to strip from the front of file names. A sequence Xof one or more adjacent slashes is counted as a single slash. By Xdefault, `patch' strips off all leading directories, leaving just the Xbase file names. X X For example, suppose the file name in the patch file is X`/gnu/src/emacs/etc/NEWS'. Using `-p0' gives the entire file name Xunmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading slash), X`-p4' gives `etc/NEWS', and not specifying `-p' at all gives `NEWS'. X X `patch' looks for each file (after any slashes have been stripped) Xin the current directory, or if you used the `-d DIRECTORY' option, in Xthat directory. X X XFile: diff.info, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch X XBackup Files X============ X X Normally, `patch' creates a backup file if the patch does not Xexactly match the original input file, because in that case the Xoriginal data might not be recovered if you undo the patch with `patch X-R' (*note Reversed Patches::). However, when conforming to POSIX, X`patch' does not create backup files by default. *Note patch and XPOSIX::. X X The `-b' or `--backup' option causes `patch' to make a backup file Xregardless of whether the patch matches the original input. The X`--backup-if-mismatch' option causes `patch' to create backup files for Xmismatches files; this is the default when not conforming to POSIX. The X`--no-backup-if-mismatch' option causes `patch' to not create backup Xfiles, even for mismatched patches; this is the default when conforming Xto POSIX. X X When backing up a file that does not exist, an empty, unreadable Xbackup file is created as a placeholder to represent the nonexistent Xfile. X X XFile: diff.info, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch X XBackup File Names X================= X X Normally, `patch' renames an original input file into a backup file Xby appending to its name the extension `.orig', or `~' if using `.orig' Xwould make the backup file name too long.(1) The `-z BACKUP-SUFFIX' or X`--suffix=BACKUP-SUFFIX' option causes `patch' to use BACKUP-SUFFIX as Xthe backup extension instead. X X Alternately, you can specify the extension for backup files with the X`SIMPLE_BACKUP_SUFFIX' environment variable, which the options override. X X `patch' can also create numbered backup files the way GNU Emacs Xdoes. With this method, instead of having a single backup of each file, X`patch' makes a new backup file name each time it patches a file. For Xexample, the backups of a file named `sink' would be called, Xsuccessively, `sink.~1~', `sink.~2~', `sink.~3~', etc. X X The `-V BACKUP-STYLE' or `--version-control=BACKUP-STYLE' option Xtakes as an argument a method for creating backup file names. You can Xalternately control the type of backups that `patch' makes with the X`PATCH_VERSION_CONTROL' environment variable, which the `-V' option Xoverrides. If `PATCH_VERSION_CONTROL' is not set, the X`VERSION_CONTROL' environment variable is used instead. Please note Xthat these options and variables control backup file names; they do not Xaffect the choice of revision control system (*note Revision Control::). X X The values of these environment variables and the argument to the X`-V' option are like the GNU Emacs `version-control' variable (*note XBackup Names: (emacs)Backup Names., for more information on backup Xversions in Emacs). They also recognize synonyms that are more Xdescriptive. The valid values are listed below; unique abbreviations Xare acceptable. X X`t' X`numbered' X Always make numbered backups. X X`nil' X`existing' X Make numbered backups of files that already have them, simple X backups of the others. This is the default. X X`never' X`simple' X Always make simple backups. X X You can also tell `patch' to prepend a prefix, such as a directory Xname, to produce backup file names. The `-B PREFIX' or X`--prefix=PREFIX' option makes backup files by prepending PREFIX to Xthem. The `-Y PREFIX' or `--basename-prefix=PREFIX' prepends PREFIX to Xthe last file name component of backup file names instead; for example, X`-Y ~' causes the backup name for `dir/file.c' to be `dir/~file.c'. If Xyou use either of these prefix options, the suffix-based options are Xignored. X X If you specify the output file with the `-o' option, that file is Xthe one that is backed up, not the input file. X X Options that affect the names of backup files do not affect whether Xbackups are made. For example, if you specify the X`--no-backup-if-mismatch' option, none of the options described in this Xsection have any affect, because no backups are made. X X ---------- Footnotes ---------- X X (1) A coding error in GNU `patch' version 2.5.4 causes it to always Xuse `~', but this should be fixed in the next release. X X XFile: diff.info, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with patch X XReject File Names X================= X X The names for reject files (files containing patches that `patch' Xcould not find a place to apply) are normally the name of the output Xfile with `.rej' appended (or `#' if if using `.rej' would make the Xbackup file name too long). X X Alternatively, you can tell `patch' to place all of the rejected Xpatches in a single file. The `-r REJECT-FILE' or X`--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file Xname. X X XFile: diff.info, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging with patch X XMessages and Questions from `patch' X=================================== X X `patch' can produce a variety of messages, especially if it has Xtrouble decoding its input. In a few situations where it's not sure Xhow to proceed, `patch' normally prompts you for more information from Xthe keyboard. There are options to produce more or fewer messages, to Xhave it not ask for keyboard input, and to affect the way that file Xnames are quoted in messages. X X* Menu: X X* More or Fewer Messages:: Controlling the verbosity of `patch'. X* patch and Keyboard Input:: Inhibiting keyboard input. X* patch Quoting Style:: Quoting file names in diagnostics. X X `patch' exits with status 0 if all hunks are applied successfully, 1 Xif some hunks cannot be applied, and 2 if there is more serious trouble. XWhen applying a set of patches in a loop, you should check the exit Xstatus, so you don't apply a later patch to a partially patched file. X X XFile: diff.info, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages X XControlling the Verbosity of `patch' X------------------------------------ X X You can cause `patch' to produce more messages by using the X`--verbose' option. For example, when you give this option, the Xmessage `Hmm...' indicates that `patch' is reading text in the patch Xfile, attempting to determine whether there is a patch in that text, Xand if so, what kind of patch it is. X X You can inhibit all terminal output from `patch', unless an error Xoccurs, by using the `-s', `--quiet', or `--silent' option. X X XFile: diff.info, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer Messages, Up: patch Messages X XInhibiting Keyboard Input X------------------------- X X There are two ways you can prevent `patch' from asking you any Xquestions. The `-f' or `--force' option assumes that you know what you Xare doing. It causes `patch' to do the following: X X * Skip patches that do not contain file names in their headers. X X * Patch files even though they have the wrong version for the X `Prereq:' line in the patch; X X * Assume that patches are not reversed even if they look like they X are. X XThe `-t' or `--batch' option is similar to `-f', in that it suppresses Xquestions, but it makes somewhat different assumptions: X X * Skip patches that do not contain file names in their headers (the X same as `-f'). X X * Skip patches for which the file has the wrong version for the X `Prereq:' line in the patch; X X * Assume that patches are reversed if they look like they are. X X XFile: diff.info, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages X X`patch' Quoting Style X--------------------- X X When `patch' outputs a file name in a diagnostic message, it can Xformat the name in any of several ways. This can be useful to output Xfile names unambiguously, even if they contain punctuation or special Xcharacters like newlines. The `--quoting-style=WORD' option controls Xhow names are output. The WORD should be one of the following: X X`literal' X Output names as-is. X X`shell' X Quote names for the shell if they contain shell metacharacters or X would cause ambiguous output. X X`shell-always' X Quote names for the shell, even if they would normally not require X quoting. X X`c' X Quote names as for a C language string. X X`escape' X Quote as with `c' except omit the surrounding double-quote X characters. X X You can specify the default value of the `--quoting-style' option Xwith the environment variable `QUOTING_STYLE'. If that environment Xvariable is not set, the default value is `shell', but this default may Xchange in a future version of `patch'. X X XFile: diff.info, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Merging with patch X X`patch' and the POSIX Standard X============================== X X If you specify the `--posix' option, or set the `POSIXLY_CORRECT' Xenvironment variable, `patch' conforms more strictly to the POSIX Xstandard, as follows: X X * Take the first existing file from the list (old, new, index) when X intuiting file names from diff headers. *Note Multiple Patches::. X X * Do not remove files that are removed by a diff. *Note Creating X and Removing::. X X * Do not ask whether to get files from RCS, ClearCase, or SCCS. X *Note Revision Control::. X X * Require that all options precede the files in the command line. X X * Do not backup files, even when there is a mismatch. *Note X