select.2: timeout is restrict too.
[dragonfly.git] / contrib / diffutils / src / normal.c
blobea9de57bc4ef1808954d60d49f178fcb1754f4f7
1 /* Normal-format output routines for GNU DIFF.
3 Copyright (C) 1988-1989, 1993, 1995, 1998, 2001, 2006, 2009-2013 Free
4 Software Foundation, Inc.
6 This file is part of GNU DIFF.
8 This program 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 3 of the License, or
11 (at your option) any later version.
13 This program 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. If not, see <http://www.gnu.org/licenses/>. */
21 #include "diff.h"
23 static void print_normal_hunk (struct change *);
25 /* Print the edit-script SCRIPT as a normal diff.
26 INF points to an array of descriptions of the two files. */
28 void
29 print_normal_script (struct change *script)
31 print_script (script, find_change, print_normal_hunk);
34 /* Print a hunk of a normal diff.
35 This is a contiguous portion of a complete edit script,
36 describing changes in consecutive lines. */
38 static void
39 print_normal_hunk (struct change *hunk)
41 lin first0, last0, first1, last1;
42 register lin i;
44 /* Determine range of line numbers involved in each file. */
45 enum changes changes = analyze_hunk (hunk, &first0, &last0, &first1, &last1);
46 if (!changes)
47 return;
49 begin_output ();
51 /* Print out the line number header for this hunk */
52 print_number_range (',', &files[0], first0, last0);
53 fputc (change_letter[changes], outfile);
54 print_number_range (',', &files[1], first1, last1);
55 fputc ('\n', outfile);
57 /* Print the lines that the first file has. */
58 if (changes & OLD)
59 for (i = first0; i <= last0; i++)
60 print_1_line ("<", &files[0].linbuf[i]);
62 if (changes == CHANGED)
63 fputs ("---\n", outfile);
65 /* Print the lines that the second file has. */
66 if (changes & NEW)
67 for (i = first1; i <= last1; i++)
68 print_1_line (">", &files[1].linbuf[i]);