mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 10:23:46 +00:00
Estimated hours taken: 30 Modified files -------------- samples/diff/README: Info about this new version. Put the existing READMEs in reverse order, so that they'll be in the most sensible order for someone reading top-down. samples/diff/Mmakefile: Supply more detail about which bit of this program GCC 2.7.2 under Digital Unix 3.2 doesn't compile properly. samples/diff/diff.m: Slight reorganisation. Accept options, remove some high coupling betweem diff__do_diff and lcss.m. samples/diff/file.m: Add support for attaching a filename to a file. samples/diff/lcss.m: Add more documentation, one slight performance improvement. lcss__to_diff now works on the reversed LCSS, to avoid going to the trouble of reversing it. New files --------- samples/diff/TODO: Meaning should be obvious. samples/diff/diff_out.m: Replacement for diffs.m (which was never a very good name). Now contains code to display a diff in lots more output styles than previously supported. samples/diff/difftype.m: Replacement for lcsstype.m. Contains the type of a diff (but not of an lcss, which is now local to lcss.m, hence the renaming). samples/diff/filter.m: Contains code to filter a diff before being displayed. This is only required if the user specified that they didn't want to see part of the diff (e.g. with --ignore-blank-lines). samples/diff/globals.m: samples/diff/options.m: Support for option handling. Removed files ------------- samples/diff/diffs.m: Functionality moved to diff_out.m. samples/diff/lcsstype.m: Functionality moved to difftype.m.
50 lines
1.7 KiB
Mathematica
50 lines
1.7 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 1995-1998 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% Main author: bromage
|
|
% Based on lcsstype.m, written by bromage and simplified by
|
|
% Marnix Klooster <marnix@worldonline.nl>
|
|
|
|
% This module contains the type of a diff.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module difftype.
|
|
|
|
:- interface.
|
|
:- import_module std_util, list.
|
|
|
|
% A pos is a non-negative number representing a position in a
|
|
% list. The position before all elements is 0, the one
|
|
% between the first and second elements is 1, etc.
|
|
:- type pos == int.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% A segment is a pair of positions. Numbering items from 0,
|
|
% segment P-Q stands for items P up to, but not including, Q.
|
|
% (Rationale: see the interpretation of type pos above.)
|
|
%
|
|
% Invariant: In any segment X - Y, it should always be true
|
|
% that X =< Y. If X=Y, the segment is empty.
|
|
:- type segment == pair(pos,pos).
|
|
|
|
% An edit operation is an addition, a deletion or a change.
|
|
:- type edit --->
|
|
add(pos,segment)
|
|
; delete(segment,pos)
|
|
; change(segment,segment).
|
|
|
|
% The complete diff of two file is a list of edit
|
|
% operations.
|
|
%
|
|
% Invariant: The edits must be in order, and must
|
|
% not overlap or touch.
|
|
:- type diff == list(edit).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|