/* Normal-format output routines for GNU DIFF.12Copyright (C) 1988, 1989, 1993, 1995, 1998, 2001 Free Software3Foundation, Inc.45This file is part of GNU DIFF.67GNU DIFF is free software; you can redistribute it and/or modify8it under the terms of the GNU General Public License as published by9the Free Software Foundation; either version 2, or (at your option)10any later version.1112GNU DIFF is distributed in the hope that it will be useful,13but WITHOUT ANY WARRANTY; without even the implied warranty of14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15GNU General Public License for more details.1617You should have received a copy of the GNU General Public License18along with this program; see the file COPYING.19If not, write to the Free Software Foundation,2059 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */2122#include "diff.h"2324static void print_normal_hunk (struct change *);2526/* Print the edit-script SCRIPT as a normal diff.27INF points to an array of descriptions of the two files. */2829void30print_normal_script (struct change *script)31{32print_script (script, find_change, print_normal_hunk);33}3435/* Print a hunk of a normal diff.36This is a contiguous portion of a complete edit script,37describing changes in consecutive lines. */3839static void40print_normal_hunk (struct change *hunk)41{42lin first0, last0, first1, last1;43register lin i;4445/* Determine range of line numbers involved in each file. */46enum changes changes = analyze_hunk (hunk, &first0, &last0, &first1, &last1);47if (!changes)48return;4950begin_output ();5152/* Print out the line number header for this hunk */53print_number_range (',', &files[0], first0, last0);54fprintf (outfile, "%c", change_letter[changes]);55print_number_range (',', &files[1], first1, last1);56fprintf (outfile, "\n");5758/* Print the lines that the first file has. */59if (changes & OLD)60for (i = first0; i <= last0; i++)61print_1_line ("<", &files[0].linbuf[i]);6263if (changes == CHANGED)64fprintf (outfile, "---\n");6566/* Print the lines that the second file has. */67if (changes & NEW)68for (i = first1; i <= last1; i++)69print_1_line (">", &files[1].linbuf[i]);70}717273