No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / diffutils / src / normal.c
blobc6a43a1e4d9473fdcef7240eadd62824d9525bb0
1 /* $NetBSD$ */
3 /* Normal-format output routines for GNU DIFF.
5 Copyright (C) 1988, 1989, 1993, 1995, 1998, 2001 Free Software
6 Foundation, Inc.
8 This file is part of GNU DIFF.
10 GNU DIFF is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
15 GNU DIFF is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; see the file COPYING.
22 If not, write to the Free Software Foundation,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "diff.h"
27 static void print_normal_hunk (struct change *);
29 /* Print the edit-script SCRIPT as a normal diff.
30 INF points to an array of descriptions of the two files. */
32 void
33 print_normal_script (struct change *script)
35 print_script (script, find_change, print_normal_hunk);
38 /* Print a hunk of a normal diff.
39 This is a contiguous portion of a complete edit script,
40 describing changes in consecutive lines. */
42 static void
43 print_normal_hunk (struct change *hunk)
45 lin first0, last0, first1, last1;
46 register lin i;
48 /* Determine range of line numbers involved in each file. */
49 enum changes changes = analyze_hunk (hunk, &first0, &last0, &first1, &last1);
50 if (!changes)
51 return;
53 begin_output ();
55 /* Print out the line number header for this hunk */
56 print_number_range (',', &files[0], first0, last0);
57 fprintf (outfile, "%c", change_letter[changes]);
58 print_number_range (',', &files[1], first1, last1);
59 fprintf (outfile, "\n");
61 /* Print the lines that the first file has. */
62 if (changes & OLD)
63 for (i = first0; i <= last0; i++)
64 print_1_line ("<", &files[0].linbuf[i]);
66 if (changes == CHANGED)
67 fprintf (outfile, "---\n");
69 /* Print the lines that the second file has. */
70 if (changes & NEW)
71 for (i = first1; i <= last1; i++)
72 print_1_line (">", &files[1].linbuf[i]);