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