summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/diff
diff options
context:
space:
mode:
authortv <tv@NetBSD.org>1999-02-12 12:45:03 +0000
committertv <tv@NetBSD.org>1999-02-12 12:45:03 +0000
commit45e58bf16e075ebcfcc33e44c85af1b480949325 (patch)
treeda1e8a4ea8eb6861cd5c91162623ca785b7e196a /gnu/usr.bin/diff
parent9b9c3c160ebd9f3171b7f6fbf078a92e6e40d150 (diff)
Use dist layout for diffutils, and add Texinfo doc.
Diffstat (limited to 'gnu/usr.bin/diff')
-rw-r--r--gnu/usr.bin/diff/COPYING339
-rw-r--r--gnu/usr.bin/diff/Makefile21
-rw-r--r--gnu/usr.bin/diff/analyze.c1084
3 files changed, 14 insertions, 1430 deletions
diff --git a/gnu/usr.bin/diff/COPYING b/gnu/usr.bin/diff/COPYING
deleted file mode 100644
index a43ea2126fb..00000000000
--- a/gnu/usr.bin/diff/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/gnu/usr.bin/diff/Makefile b/gnu/usr.bin/diff/Makefile
index 7b10534882e..01c7320b9cc 100644
--- a/gnu/usr.bin/diff/Makefile
+++ b/gnu/usr.bin/diff/Makefile
@@ -1,11 +1,18 @@
-# $NetBSD: Makefile,v 1.11 1997/10/25 10:10:30 lukem Exp $
+# $NetBSD: Makefile,v 1.12 1999/02/12 12:45:03 tv Exp $
-PROG= diff
-SRCS= diff.c analyze.c cmpbuf.c io.c context.c ed.c normal.c util.c dir.c \
- regex.c side.c ifdef.c version.c getopt.c getopt1.c
+PROG= diff
+SRCS= diff.c analyze.c cmpbuf.c io.c context.c ed.c normal.c util.c \
+ dir.c regex.c side.c ifdef.c version.c getopt.c getopt1.c
-CPPFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} -DPR_PROGRAM=\"/usr/bin/pr\"
-LDADD+= -lgnumalloc
-DPADD+= ${LIBGNUMALLOC}
+CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR} -I${DIST}/diffutils \
+ -DPR_PROGRAM=\"/usr/bin/pr\"
+LDADD+= -lgnumalloc
+DPADD+= ${LIBGNUMALLOC}
+TEXINFO= diff.texi
+
+DIST= ${.CURDIR}/../../dist
+.PATH: ${DIST}/diffutils
+
+.include <bsd.info.mk>
.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/diff/analyze.c b/gnu/usr.bin/diff/analyze.c
deleted file mode 100644
index 556d388c46a..00000000000
--- a/gnu/usr.bin/diff/analyze.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* Analyze file differences for GNU DIFF.
- Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GNU DIFF.
-
-GNU DIFF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU DIFF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU DIFF; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* The basic algorithm is described in:
- "An O(ND) Difference Algorithm and its Variations", Eugene Myers,
- Algorithmica Vol. 1 No. 2, 1986, pp. 251-266;
- see especially section 4.2, which describes the variation used below.
- Unless the --minimal option is specified, this code uses the TOO_EXPENSIVE
- heuristic, by Paul Eggert, to limit the cost to O(N**1.5 log N)
- at the price of producing suboptimal output for large inputs with
- many differences.
-
- The basic algorithm was independently discovered as described in:
- "Algorithms for Approximate String Matching", E. Ukkonen,
- Information and Control Vol. 64, 1985, pp. 100-118. */
-
-#include "diff.h"
-#include "cmpbuf.h"
-
-extern int no_discards;
-
-static int *xvec, *yvec; /* Vectors being compared. */
-static int *fdiag; /* Vector, indexed by diagonal, containing
- 1 + the X coordinate of the point furthest
- along the given diagonal in the forward
- search of the edit matrix. */
-static int *bdiag; /* Vector, indexed by diagonal, containing
- the X coordinate of the point furthest
- along the given diagonal in the backward
- search of the edit matrix. */
-static int too_expensive; /* Edit scripts longer than this are too
- expensive to compute. */
-
-#define SNAKE_LIMIT 20 /* Snakes bigger than this are considered `big'. */
-
-struct partition
-{
- int xmid, ymid; /* Midpoints of this partition. */
- int lo_minimal; /* Nonzero if low half will be analyzed minimally. */
- int hi_minimal; /* Likewise for high half. */
-};
-
-static int diag PARAMS((int, int, int, int, int, struct partition *));
-static struct change *add_change PARAMS((int, int, int, int, struct change *));
-static struct change *build_reverse_script PARAMS((struct file_data const[]));
-static struct change *build_script PARAMS((struct file_data const[]));
-static void briefly_report PARAMS((int, struct file_data const[]));
-static void compareseq PARAMS((int, int, int, int, int));
-static void discard_confusing_lines PARAMS((struct file_data[]));
-static void shift_boundaries PARAMS((struct file_data[]));
-
-/* Find the midpoint of the shortest edit script for a specified
- portion of the two files.
-
- Scan from the beginnings of the files, and simultaneously from the ends,
- doing a breadth-first search through the space of edit-sequence.
- When the two searches meet, we have found the midpoint of the shortest
- edit sequence.
-
- If MINIMAL is nonzero, find the minimal edit script regardless
- of expense. Otherwise, if the search is too expensive, use
- heuristics to stop the search and report a suboptimal answer.
-
- Set PART->(XMID,YMID) to the midpoint (XMID,YMID). The diagonal number
- XMID - YMID equals the number of inserted lines minus the number
- of deleted lines (counting only lines before the midpoint).
- Return the approximate edit cost; this is the total number of
- lines inserted or deleted (counting only lines before the midpoint),
- unless a heuristic is used to terminate the search prematurely.
-
- Set PART->LEFT_MINIMAL to nonzero iff the minimal edit script for the
- left half of the partition is known; similarly for PART->RIGHT_MINIMAL.
-
- This function assumes that the first lines of the specified portions
- of the two files do not match, and likewise that the last lines do not
- match. The caller must trim matching lines from the beginning and end
- of the portions it is going to specify.
-
- If we return the "wrong" partitions,
- the worst this can do is cause suboptimal diff output.
- It cannot cause incorrect diff output. */
-
-static int
-diag (xoff, xlim, yoff, ylim, minimal, part)
- int xoff, xlim, yoff, ylim, minimal;
- struct partition *part;
-{
- int *const fd = fdiag; /* Give the compiler a chance. */
- int *const bd = bdiag; /* Additional help for the compiler. */
- int const *const xv = xvec; /* Still more help for the compiler. */
- int const *const yv = yvec; /* And more and more . . . */
- int const dmin = xoff - ylim; /* Minimum valid diagonal. */
- int const dmax = xlim - yoff; /* Maximum valid diagonal. */
- int const fmid = xoff - yoff; /* Center diagonal of top-down search. */
- int const bmid = xlim - ylim; /* Center diagonal of bottom-up search. */
- int fmin = fmid, fmax = fmid; /* Limits of top-down search. */
- int bmin = bmid, bmax = bmid; /* Limits of bottom-up search. */
- int c; /* Cost. */
- int odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd
- diagonal with respect to the northwest. */
-
- fd[fmid] = xoff;
- bd[bmid] = xlim;
-
- for (c = 1;; ++c)
- {
- int d; /* Active diagonal. */
- int big_snake = 0;
-
- /* Extend the top-down search by an edit step in each diagonal. */
- fmin > dmin ? fd[--fmin - 1] = -1 : ++fmin;
- fmax < dmax ? fd[++fmax + 1] = -1 : --fmax;
- for (d = fmax; d >= fmin; d -= 2)
- {
- int x, y, oldx, tlo = fd[d - 1], thi = fd[d + 1];
-
- if (tlo >= thi)
- x = tlo + 1;
- else
- x = thi;
- oldx = x;
- y = x - d;
- while (x < xlim && y < ylim && xv[x] == yv[y])
- ++x, ++y;
- if (x - oldx > SNAKE_LIMIT)
- big_snake = 1;
- fd[d] = x;
- if (odd && bmin <= d && d <= bmax && bd[d] <= x)
- {
- part->xmid = x;
- part->ymid = y;
- part->lo_minimal = part->hi_minimal = 1;
- return 2 * c - 1;
- }
- }
-
- /* Similarly extend the bottom-up search. */
- bmin > dmin ? bd[--bmin - 1] = INT_MAX : ++bmin;
- bmax < dmax ? bd[++bmax + 1] = INT_MAX : --bmax;
- for (d = bmax; d >= bmin; d -= 2)
- {
- int x, y, oldx, tlo = bd[d - 1], thi = bd[d + 1];
-
- if (tlo < thi)
- x = tlo;
- else
- x = thi - 1;
- oldx = x;
- y = x - d;
- while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1])
- --x, --y;
- if (oldx - x > SNAKE_LIMIT)
- big_snake = 1;
- bd[d] = x;
- if (!odd && fmin <= d && d <= fmax && x <= fd[d])
- {
- part->xmid = x;
- part->ymid = y;
- part->lo_minimal = part->hi_minimal = 1;
- return 2 * c;
- }
- }
-
- if (minimal)
- continue;
-
- /* Heuristic: check occasionally for a diagonal that has made
- lots of progress compared with the edit distance.
- If we have any such, find the one that has made the most
- progress and return it as if it had succeeded.
-
- With this heuristic, for files with a constant small density
- of changes, the algorithm is linear in the file size. */
-
- if (c > 200 && big_snake && heuristic)
- {
- int best;
-
- best = 0;
- for (d = fmax; d >= fmin; d -= 2)
- {
- int dd = d - fmid;
- int x = fd[d];
- int y = x - d;
- int v = (x - xoff) * 2 - dd;
- if (v > 12 * (c + (dd < 0 ? -dd : dd)))
- {
- if (v > best
- && xoff + SNAKE_LIMIT <= x && x < xlim
- && yoff + SNAKE_LIMIT <= y && y < ylim)
- {
- /* We have a good enough best diagonal;
- now insist that it end with a significant snake. */
- int k;
-
- for (k = 1; xv[x - k] == yv[y - k]; k++)
- if (k == SNAKE_LIMIT)
- {
- best = v;
- part->xmid = x;
- part->ymid = y;
- break;
- }
- }
- }
- }
- if (best > 0)
- {
- part->lo_minimal = 1;
- part->hi_minimal = 0;
- return 2 * c - 1;
- }
-
- best = 0;
- for (d = bmax; d >= bmin; d -= 2)
- {
- int dd = d - bmid;
- int x = bd[d];
- int y = x - d;
- int v = (xlim - x) * 2 + dd;
- if (v > 12 * (c + (dd < 0 ? -dd : dd)))
- {
- if (v > best
- && xoff < x && x <= xlim - SNAKE_LIMIT
- && yoff < y && y <= ylim - SNAKE_LIMIT)
- {
- /* We have a good enough best diagonal;
- now insist that it end with a significant snake. */
- int k;
-
- for (k = 0; xv[x + k] == yv[y + k]; k++)
- if (k == SNAKE_LIMIT - 1)
- {
- best = v;
- part->xmid = x;
- part->ymid = y;
- break;
- }
- }
- }
- }
- if (best > 0)
- {
- part->lo_minimal = 0;
- part->hi_minimal = 1;
- return 2 * c - 1;
- }
- }
-
- /* Heuristic: if we've gone well beyond the call of duty,
- give up and report halfway between our best results so far. */
- if (c >= too_expensive)
- {
- int fxybest, fxbest;
- int bxybest, bxbest;
-
- fxbest = bxbest = 0; /* Pacify `gcc -Wall'. */
-
- /* Find forward diagonal that maximizes X + Y. */
- fxybest = -1;
- for (d = fmax; d >= fmin; d -= 2)
- {
- int x = min (fd[d], xlim);
- int y = x - d;
- if (ylim < y)
- x = ylim + d, y = ylim;
- if (fxybest < x + y)
- {
- fxybest = x + y;
- fxbest = x;
- }
- }
-
- /* Find backward diagonal that minimizes X + Y. */
- bxybest = INT_MAX;
- for (d = bmax; d >= bmin; d -= 2)
- {
- int x = max (xoff, bd[d]);
- int y = x - d;
- if (y < yoff)
- x = yoff + d, y = yoff;
- if (x + y < bxybest)
- {
- bxybest = x + y;
- bxbest = x;
- }
- }
-
- /* Use the better of the two diagonals. */
- if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
- {
- part->xmid = fxbest;
- part->ymid = fxybest - fxbest;
- part->lo_minimal = 1;
- part->hi_minimal = 0;
- }
- else
- {
- part->xmid = bxbest;
- part->ymid = bxybest - bxbest;
- part->lo_minimal = 0;
- part->hi_minimal = 1;
- }
- return 2 * c - 1;
- }
- }
-}
-
-/* Compare in detail contiguous subsequences of the two files
- which are known, as a whole, to match each other.
-
- The results are recorded in the vectors files[N].changed_flag, by
- storing a 1 in the element for each line that is an insertion or deletion.
-
- The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1.
-
- Note that XLIM, YLIM are exclusive bounds.
- All line numbers are origin-0 and discarded lines are not counted.
-
- If MINIMAL is nonzero, find a minimal difference no matter how
- expensive it is. */
-
-static void
-compareseq (xoff, xlim, yoff, ylim, minimal)
- int xoff, xlim, yoff, ylim, minimal;
-{
- int * const xv = xvec; /* Help the compiler. */
- int * const yv = yvec;
-
- /* Slide down the bottom initial diagonal. */
- while (xoff < xlim && yoff < ylim && xv[xoff] == yv[yoff])
- ++xoff, ++yoff;
- /* Slide up the top initial diagonal. */
- while (xlim > xoff && ylim > yoff && xv[xlim - 1] == yv[ylim - 1])
- --xlim, --ylim;
-
- /* Handle simple cases. */
- if (xoff == xlim)
- while (yoff < ylim)
- files[1].changed_flag[files[1].realindexes[yoff++]] = 1;
- else if (yoff == ylim)
- while (xoff < xlim)
- files[0].changed_flag[files[0].realindexes[xoff++]] = 1;
- else
- {
- int c;
- struct partition part;
-
- /* Find a point of correspondence in the middle of the files. */
-
- c = diag (xoff, xlim, yoff, ylim, minimal, &part);
-
- if (c == 1)
- {
- /* This should be impossible, because it implies that
- one of the two subsequences is empty,
- and that case was handled above without calling `diag'.
- Let's verify that this is true. */
- abort ();
-#if 0
- /* The two subsequences differ by a single insert or delete;
- record it and we are done. */
- if (part.xmid - part.ymid < xoff - yoff)
- files[1].changed_flag[files[1].realindexes[part.ymid - 1]] = 1;
- else
- files[0].changed_flag[files[0].realindexes[part.xmid]] = 1;
-#endif
- }
- else
- {
- /* Use the partitions to split this problem into subproblems. */
- compareseq (xoff, part.xmid, yoff, part.ymid, part.lo_minimal);
- compareseq (part.xmid, xlim, part.ymid, ylim, part.hi_minimal);
- }
- }
-}
-
-/* Discard lines from one file that have no matches in the other file.
-
- A line which is discarded will not be considered by the actual
- comparison algorithm; it will be as if that line were not in the file.
- The file's `realindexes' table maps virtual line numbers
- (which don't count the discarded lines) into real line numbers;
- this is how the actual comparison algorithm produces results
- that are comprehensible when the discarded lines are counted.
-
- When we discard a line, we also mark it as a deletion or insertion
- so that it will be printed in the output. */
-
-static void
-discard_confusing_lines (filevec)
- struct file_data filevec[];
-{
- unsigned int f, i;
- char *discarded[2];
- int *equiv_count[2];
- int *p;
-
- /* Allocate our results. */
- p = (int *) xmalloc ((filevec[0].buffered_lines + filevec[1].buffered_lines)
- * (2 * sizeof (int)));
- for (f = 0; f < 2; f++)
- {
- filevec[f].undiscarded = p; p += filevec[f].buffered_lines;
- filevec[f].realindexes = p; p += filevec[f].buffered_lines;
- }
-
- /* Set up equiv_count[F][I] as the number of lines in file F
- that fall in equivalence class I. */
-
- p = (int *) xmalloc (filevec[0].equiv_max * (2 * sizeof (int)));
- equiv_count[0] = p;
- equiv_count[1] = p + filevec[0].equiv_max;
- bzero (p, filevec[0].equiv_max * (2 * sizeof (int)));
-
- for (i = 0; i < filevec[0].buffered_lines; ++i)
- ++equiv_count[0][filevec[0].equivs[i]];
- for (i = 0; i < filevec[1].buffered_lines; ++i)
- ++equiv_count[1][filevec[1].equivs[i]];
-
- /* Set up tables of which lines are going to be discarded. */
-
- discarded[0] = xmalloc (sizeof (char)
- * (filevec[0].buffered_lines
- + filevec[1].buffered_lines));
- discarded[1] = discarded[0] + filevec[0].buffered_lines;
- bzero (discarded[0], sizeof (char) * (filevec[0].buffered_lines
- + filevec[1].buffered_lines));
-
- /* Mark to be discarded each line that matches no line of the other file.
- If a line matches many lines, mark it as provisionally discardable. */
-
- for (f = 0; f < 2; f++)
- {
- unsigned int end = filevec[f].buffered_lines;
- char *discards = discarded[f];
- int *counts = equiv_count[1 - f];
- int *equivs = filevec[f].equivs;
- unsigned int many = 5;
- unsigned int tem = end / 64;
-
- /* Multiply MANY by approximate square root of number of lines.
- That is the threshold for provisionally discardable lines. */
- while ((tem = tem >> 2) > 0)
- many *= 2;
-
- for (i = 0; i < end; i++)
- {
- int nmatch;
- if (equivs[i] == 0)
- continue;
- nmatch = counts[equivs[i]];
- if (nmatch == 0)
- discards[i] = 1;
- else if (nmatch > many)
- discards[i] = 2;
- }
- }
-
- /* Don't really discard the provisional lines except when they occur
- in a run of discardables, with nonprovisionals at the beginning
- and end. */
-
- for (f = 0; f < 2; f++)
- {
- unsigned int end = filevec[f].buffered_lines;
- register char *discards = discarded[f];
-
- for (i = 0; i < end; i++)
- {
- /* Cancel provisional discards not in middle of run of discards. */
- if (discards[i] == 2)
- discards[i] = 0;
- else if (discards[i] != 0)
- {
- /* We have found a nonprovisional discard. */
- register int j;
- unsigned int length;
- unsigned int provisional = 0;
-
- /* Find end of this run of discardable lines.
- Count how many are provisionally discardable. */
- for (j = i; j < end; j++)
- {
- if (discards[j] == 0)
- break;
- if (discards[j] == 2)
- ++provisional;
- }
-
- /* Cancel provisional discards at end, and shrink the run. */
- while (j > i && discards[j - 1] == 2)
- discards[--j] = 0, --provisional;
-
- /* Now we have the length of a run of discardable lines
- whose first and last are not provisional. */
- length = j - i;
-
- /* If 1/4 of the lines in the run are provisional,
- cancel discarding of all provisional lines in the run. */
- if (provisional * 4 > length)
- {
- while (j > i)
- if (discards[--j] == 2)
- discards[j] = 0;
- }
- else
- {
- register unsigned int consec;
- unsigned int minimum = 1;
- unsigned int tem = length / 4;
-
- /* MINIMUM is approximate square root of LENGTH/4.
- A subrun of two or more provisionals can stand
- when LENGTH is at least 16.
- A subrun of 4 or more can stand when LENGTH >= 64. */
- while ((tem = tem >> 2) > 0)
- minimum *= 2;
- minimum++;
-
- /* Cancel any subrun of MINIMUM or more provisionals
- within the larger run. */
- for (j = 0, consec = 0; j < length; j++)
- if (discards[i + j] != 2)
- consec = 0;
- else if (minimum == ++consec)
- /* Back up to start of subrun, to cancel it all. */
- j -= consec;
- else if (minimum < consec)
- discards[i + j] = 0;
-
- /* Scan from beginning of run
- until we find 3 or more nonprovisionals in a row
- or until the first nonprovisional at least 8 lines in.
- Until that point, cancel any provisionals. */
- for (j = 0, consec = 0; j < length; j++)
- {
- if (j >= 8 && discards[i + j] == 1)
- break;
- if (discards[i + j] == 2)
- consec = 0, discards[i + j] = 0;
- else if (discards[i + j] == 0)
- consec = 0;
- else
- consec++;
- if (consec == 3)
- break;
- }
-
- /* I advances to the last line of the run. */
- i += length - 1;
-
- /* Same thing, from end. */
- for (j = 0, consec = 0; j < length; j++)
- {
- if (j >= 8 && discards[i - j] == 1)
- break;
- if (discards[i - j] == 2)
- consec = 0, discards[i - j] = 0;
- else if (discards[i - j] == 0)
- consec = 0;
- else
- consec++;
- if (consec == 3)
- break;
- }
- }
- }
- }
- }
-
- /* Actually discard the lines. */
- for (f = 0; f < 2; f++)
- {
- char *discards = discarded[f];
- unsigned int end = filevec[f].buffered_lines;
- unsigned int j = 0;
- for (i = 0; i < end; ++i)
- if (no_discards || discards[i] == 0)
- {
- filevec[f].undiscarded[j] = filevec[f].equivs[i];
- filevec[f].realindexes[j++] = i;
- }
- else
- filevec[f].changed_flag[i] = 1;
- filevec[f].nondiscarded_lines = j;
- }
-
- free (discarded[0]);
- free (equiv_count[0]);
-}
-
-/* Adjust inserts/deletes of identical lines to join changes
- as much as possible.
-
- We do something when a run of changed lines include a
- line at one end and have an excluded, identical line at the other.
- We are free to choose which identical line is included.
- `compareseq' usually chooses the one at the beginning,
- but usually it is cleaner to consider the following identical line
- to be the "change". */
-
-int inhibit;
-
-static void
-shift_boundaries (filevec)
- struct file_data filevec[];
-{
- int f;
-
- if (inhibit)
- return;
-
- for (f = 0; f < 2; f++)
- {
- char *changed = filevec[f].changed_flag;
- char const *other_changed = filevec[1-f].changed_flag;
- int const *equivs = filevec[f].equivs;
- int i = 0;
- int j = 0;
- int i_end = filevec[f].buffered_lines;
-
- while (1)
- {
- int runlength, start, corresponding;
-
- /* Scan forwards to find beginning of another run of changes.
- Also keep track of the corresponding point in the other file. */
-
- while (i < i_end && changed[i] == 0)
- {
- while (other_changed[j++])
- continue;
- i++;
- }
-
- if (i == i_end)
- break;
-
- start = i;
-
- /* Find the end of this run of changes. */
-
- while (changed[++i])
- continue;
- while (other_changed[j])
- j++;
-
- do
- {
- /* Record the length of this run of changes, so that
- we can later determine whether the run has grown. */
- runlength = i - start;
-
- /* Move the changed region back, so long as the
- previous unchanged line matches the last changed one.
- This merges with previous changed regions. */
-
- while (start && equivs[start - 1] == equivs[i - 1])
- {
- changed[--start] = 1;
- changed[--i] = 0;
- while (changed[start - 1])
- start--;
- while (other_changed[--j])
- continue;
- }
-
- /* Set CORRESPONDING to the end of the changed run, at the last
- point where it corresponds to a changed run in the other file.
- CORRESPONDING == I_END means no such point has been found. */
- corresponding = other_changed[j - 1] ? i : i_end;
-
- /* Move the changed region forward, so long as the
- first changed line matches the following unchanged one.
- This merges with following changed regions.
- Do this second, so that if there are no merges,
- the changed region is moved forward as far as possible. */
-
- while (i != i_end && equivs[start] == equivs[i])
- {
- changed[start++] = 0;
- changed[i++] = 1;
- while (changed[i])
- i++;
- while (other_changed[++j])
- corresponding = i;
- }
- }
- while (runlength != i - start);
-
- /* If possible, move the fully-merged run of changes
- back to a corresponding run in the other file. */
-
- while (corresponding < i)
- {
- changed[--start] = 1;
- changed[--i] = 0;
- while (other_changed[--j])
- continue;
- }
- }
- }
-}
-
-/* Cons an additional entry onto the front of an edit script OLD.
- LINE0 and LINE1 are the first affected lines in the two files (origin 0).
- DELETED is the number of lines deleted here from file 0.
- INSERTED is the number of lines inserted here in file 1.
-
- If DELETED is 0 then LINE0 is the number of the line before
- which the insertion was done; vice versa for INSERTED and LINE1. */
-
-static struct change *
-add_change (line0, line1, deleted, inserted, old)
- int line0, line1, deleted, inserted;
- struct change *old;
-{
- struct change *new = (struct change *) xmalloc (sizeof (struct change));
-
- new->line0 = line0;
- new->line1 = line1;
- new->inserted = inserted;
- new->deleted = deleted;
- new->link = old;
- return new;
-}
-
-/* Scan the tables of which lines are inserted and deleted,
- producing an edit script in reverse order. */
-
-static struct change *
-build_reverse_script (filevec)
- struct file_data const filevec[];
-{
- struct change *script = 0;
- char *changed0 = filevec[0].changed_flag;
- char *changed1 = filevec[1].changed_flag;
- int len0 = filevec[0].buffered_lines;
- int len1 = filevec[1].buffered_lines;
-
- /* Note that changedN[len0] does exist, and contains 0. */
-
- int i0 = 0, i1 = 0;
-
- while (i0 < len0 || i1 < len1)
- {
- if (changed0[i0] || changed1[i1])
- {
- int line0 = i0, line1 = i1;
-
- /* Find # lines changed here in each file. */
- while (changed0[i0]) ++i0;
- while (changed1[i1]) ++i1;
-
- /* Record this change. */
- script = add_change (line0, line1, i0 - line0, i1 - line1, script);
- }
-
- /* We have reached lines in the two files that match each other. */
- i0++, i1++;
- }
-
- return script;
-}
-
-/* Scan the tables of which lines are inserted and deleted,
- producing an edit script in forward order. */
-
-static struct change *
-build_script (filevec)
- struct file_data const filevec[];
-{
- struct change *script = 0;
- char *changed0 = filevec[0].changed_flag;
- char *changed1 = filevec[1].changed_flag;
- int i0 = filevec[0].buffered_lines, i1 = filevec[1].buffered_lines;
-
- /* Note that changedN[-1] does exist, and contains 0. */
-
- while (i0 >= 0 || i1 >= 0)
- {
- if (changed0[i0 - 1] || changed1[i1 - 1])
- {
- int line0 = i0, line1 = i1;
-
- /* Find # lines changed here in each file. */
- while (changed0[i0 - 1]) --i0;
- while (changed1[i1 - 1]) --i1;
-
- /* Record this change. */
- script = add_change (i0, i1, line0 - i0, line1 - i1, script);
- }
-
- /* We have reached lines in the two files that match each other. */
- i0--, i1--;
- }
-
- return script;
-}
-
-/* If CHANGES, briefly report that two files differed. */
-static void
-briefly_report (changes, filevec)
- int changes;
- struct file_data const filevec[];
-{
- if (changes)
- message (no_details_flag ? "Files %s and %s differ\n"
- : "Binary files %s and %s differ\n",
- filevec[0].name, filevec[1].name);
-}
-
-/* Report the differences of two files. DEPTH is the current directory
- depth. */
-int
-diff_2_files (filevec, depth)
- struct file_data filevec[];
- int depth;
-{
- int diags;
- int i;
- struct change *e, *p;
- struct change *script;
- int changes;
-
-
- /* If we have detected that either file is binary,
- compare the two files as binary. This can happen
- only when the first chunk is read.
- Also, --brief without any --ignore-* options means
- we can speed things up by treating the files as binary. */
-
- if (read_files (filevec, no_details_flag & ~ignore_some_changes))
- {
- /* Files with different lengths must be different. */
- if (filevec[0].stat.st_size != filevec[1].stat.st_size
- && (filevec[0].desc < 0 || S_ISREG (filevec[0].stat.st_mode))
- && (filevec[1].desc < 0 || S_ISREG (filevec[1].stat.st_mode)))
- changes = 1;
-
- /* Standard input equals itself. */
- else if (filevec[0].desc == filevec[1].desc)
- changes = 0;
-
- else
- /* Scan both files, a buffer at a time, looking for a difference. */
- {
- /* Allocate same-sized buffers for both files. */
- size_t buffer_size = buffer_lcm (STAT_BLOCKSIZE (filevec[0].stat),
- STAT_BLOCKSIZE (filevec[1].stat));
- for (i = 0; i < 2; i++)
- filevec[i].buffer = xrealloc (filevec[i].buffer, buffer_size);
-
- for (;; filevec[0].buffered_chars = filevec[1].buffered_chars = 0)
- {
- /* Read a buffer's worth from both files. */
- for (i = 0; i < 2; i++)
- if (0 <= filevec[i].desc)
- while (filevec[i].buffered_chars != buffer_size)
- {
- int r = read (filevec[i].desc,
- filevec[i].buffer
- + filevec[i].buffered_chars,
- buffer_size - filevec[i].buffered_chars);
- if (r == 0)
- break;
- if (r < 0)
- pfatal_with_name (filevec[i].name);
- filevec[i].buffered_chars += r;
- }
-
- /* If the buffers differ, the files differ. */
- if (filevec[0].buffered_chars != filevec[1].buffered_chars
- || (filevec[0].buffered_chars != 0
- && memcmp (filevec[0].buffer,
- filevec[1].buffer,
- filevec[0].buffered_chars) != 0))
- {
- changes = 1;
- break;
- }
-
- /* If we reach end of file, the files are the same. */
- if (filevec[0].buffered_chars != buffer_size)
- {
- changes = 0;
- break;
- }
- }
- }
-
- briefly_report (changes, filevec);
- }
- else
- {
- /* Allocate vectors for the results of comparison:
- a flag for each line of each file, saying whether that line
- is an insertion or deletion.
- Allocate an extra element, always zero, at each end of each vector. */
-
- size_t s = filevec[0].buffered_lines + filevec[1].buffered_lines + 4;
- filevec[0].changed_flag = xmalloc (s);
- bzero (filevec[0].changed_flag, s);
- filevec[0].changed_flag++;
- filevec[1].changed_flag = filevec[0].changed_flag
- + filevec[0].buffered_lines + 2;
-
- /* Some lines are obviously insertions or deletions
- because they don't match anything. Detect them now, and
- avoid even thinking about them in the main comparison algorithm. */
-
- discard_confusing_lines (filevec);
-
- /* Now do the main comparison algorithm, considering just the
- undiscarded lines. */
-
- xvec = filevec[0].undiscarded;
- yvec = filevec[1].undiscarded;
- diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
- fdiag = (int *) xmalloc (diags * (2 * sizeof (int)));
- bdiag = fdiag + diags;
- fdiag += filevec[1].nondiscarded_lines + 1;
- bdiag += filevec[1].nondiscarded_lines + 1;
-
- /* Set TOO_EXPENSIVE to be approximate square root of input size,
- bounded below by 256. */
- too_expensive = 1;
- for (i = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines;
- i != 0; i >>= 2)
- too_expensive <<= 1;
- too_expensive = max (256, too_expensive);
-
- files[0] = filevec[0];
- files[1] = filevec[1];
-
- compareseq (0, filevec[0].nondiscarded_lines,
- 0, filevec[1].nondiscarded_lines, no_discards);
-
- free (fdiag - (filevec[1].nondiscarded_lines + 1));
-
- /* Modify the results slightly to make them prettier
- in cases where that can validly be done. */
-
- shift_boundaries (filevec);
-
- /* Get the results of comparison in the form of a chain
- of `struct change's -- an edit script. */
-
- if (output_style == OUTPUT_ED)
- script = build_reverse_script (filevec);
- else
- script = build_script (filevec);
-
- /* Set CHANGES if we had any diffs.
- If some changes are ignored, we must scan the script to decide. */
- if (ignore_blank_lines_flag || ignore_regexp_list)
- {
- struct change *next = script;
- changes = 0;
-
- while (next && changes == 0)
- {
- struct change *this, *end;
- int first0, last0, first1, last1, deletes, inserts;
-
- /* Find a set of changes that belong together. */
- this = next;
- end = find_change (next);
-
- /* Disconnect them from the rest of the changes, making them
- a hunk, and remember the rest for next iteration. */
- next = end->link;
- end->link = 0;
-
- /* Determine whether this hunk is really a difference. */
- analyze_hunk (this, &first0, &last0, &first1, &last1,
- &deletes, &inserts);
-
- /* Reconnect the script so it will all be freed properly. */
- end->link = next;
-
- if (deletes || inserts)
- changes = 1;
- }
- }
- else
- changes = (script != 0);
-
- if (no_details_flag)
- briefly_report (changes, filevec);
- else
- {
- if (changes || ! no_diff_means_no_output)
- {
- /* Record info for starting up output,
- to be used if and when we have some output to print. */
- setup_output (files[0].name, files[1].name, depth);
-
- switch (output_style)
- {
- case OUTPUT_CONTEXT:
- print_context_script (script, 0);
- break;
-
- case OUTPUT_UNIFIED:
- print_context_script (script, 1);
- break;
-
- case OUTPUT_ED:
- print_ed_script (script);
- break;
-
- case OUTPUT_FORWARD_ED:
- pr_forward_ed_script (script);
- break;
-
- case OUTPUT_RCS:
- print_rcs_script (script);
- break;
-
- case OUTPUT_NORMAL:
- print_normal_script (script);
- break;
-
- case OUTPUT_IFDEF:
- print_ifdef_script (script);
- break;
-
- case OUTPUT_SDIFF:
- print_sdiff_script (script);
- }
-
- finish_output ();
- }
- }
-
- free (filevec[0].undiscarded);
-
- free (filevec[0].changed_flag - 1);
-
- for (i = 1; i >= 0; --i)
- free (filevec[i].equivs);
-
- for (i = 0; i < 2; ++i)
- free (filevec[i].linbuf + filevec[i].linbuf_base);
-
- for (e = script; e; e = p)
- {
- p = e->link;
- free (e);
- }
-
- if (! ROBUST_OUTPUT_STYLE (output_style))
- for (i = 0; i < 2; ++i)
- if (filevec[i].missing_newline)
- {
- error ("No newline at end of file %s", filevec[i].name, "");
- changes = 2;
- }
- }
-
- if (filevec[0].buffer != filevec[1].buffer)
- free (filevec[0].buffer);
- free (filevec[1].buffer);
-
- return changes;
-}