Files
mercury/samples/diff
Zoltan Somogyi a653024ab7 Update many aspects of style in sample programs.
If we want to encourage people to read the sample programs
and learn Mercury programming from them, they should not be written
in an obsolete style.

samples/beer.m:
samples/calculator.m:
samples/calculator2.m:
samples/concurrency/midimon/midimon.m:
samples/diff/diff_out.m:
samples/e.m:
samples/eliza.m:
samples/muz/dict.m:
samples/muz/higher_order.m:
samples/muz/muz.m:
samples/muz/typecheck.m:
samples/muz/word.m:
samples/muz/zabstract.m:
samples/muz/zlogic.m:
samples/muz/zparser.m:
samples/muz/ztoken.m:
samples/muz/ztoken_io.m:
samples/muz/ztype.m:
samples/muz/ztype_op.m:
samples/rot13/rot13_concise.m:
samples/rot13/rot13_gustavo.m:
samples/rot13/rot13_juergen.m:
samples/rot13/rot13_ralph.m:
samples/rot13/rot13_verbose.m:
samples/solutions/all_solutions.m:
samples/solutions/n_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
samples/solver_types/eqneq.m:
samples/solver_types/sudoku.m:
samples/solver_types/test_eqneq.m:
    Replace uses of __ as module qualifier with dot.

    Replace (C->T;E) with (if C then T else E).

    Use our usual indentation for if-then-elses and for switches.

    Import one module per line. Put those imports into alphabetical order.

    Replace many uses of DCGs with state variables, leaving DCGs
    mostly just for parsing code.

    Use predmode declarations where this helps.

    Put predicates in top-down order where relevant.

    Use io.format where this helps.

    Do not put more than one predicate call on one line.

    Put each function symbol in a du type on a separate line.

    Put spaces after commas, around the bar in list syntax,
    around arithmetic operators, and around minus signs used for pairs.

    Replace tab indentation with four-space indentation.

    Delete spaces at the ends of lines.
    Replace two or more consecutive blank lines with one blank line.
    Delete blank lines that do not help structure the code.

    There are probably still some examples of old practices remaining;
    I do not claim to have fixed them all.
2021-07-07 05:32:09 +10:00
..

This is now looking a LOT more like the standard "diff" utility.  There
are a few features missing (e.g. we can't do directory diffs), but apart
from that, it seems to work.

The major changes in this version are:

	- We now accept command-line options.  In particular, we
	  recognise all options that are accepted by GNU diff,
	  though some of them result in error reports and a few
	  which have do nothing to do with the output format or
	  semantics, but are merely for efficiency, are accepted
	  and ignored.

	- We support different output formats, in particular all
	  of the output formats supported by GNU diff. There are
	  a number of modifiers to the output formats (for example,
	  --show-function-line) which we don't yet support.

	- We have a new diff algorithm, based on the one by Eugene
	  Myers.  See myers.m for details.

	- Just about everything has been modified to support the
	  above changes.

	- Lots of cleanups, lots more documentation.

Examine the file TODO to see what's still missing.

Andrew Bromage  13 September 1998

===========================================================================

The version which appears here is a re-hacked version of Marnix Klooster's
hacked version of my original.  Special thanks to him for making my code
a lot more maintainable than it originally was.  :-)

The changes from the previous version:

	- Bug fix for a problem which was causing it to bomb out if
	  the two files were identical.

	- Changed indenting so it more closely matches the Mercury
	  compiler coding standard.

	- Update to use unique arrays (now called array.m).

	- Various minor documentation tweaks.

Oh, and it still runs in nowhere near the speed of GNU diff.

Andrew Bromage  28 Jul 1997

===========================================================================

The Mercury modules in this directory have been derived from the
'diff' sample distributed with Mercury 0.6.  That sample carries the
following copyright information, description and to-do list (in
diff.m):


%-----------------------------------------------------------------------------%
% Copyright (C) 1995 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.
%-----------------------------------------------------------------------------%

% File: diff.m
% Main author: bromage

% Something very similar to the standard diff utility.  Sort of.  :-)

% On the still-to-do list:
%	- Add command-line options.  Probably:
%		--ignore-all-space
%		--ignore-blank-lines
%		--ignore-case
%		--rcs
%	  What others are easy and don't break up the code?


The major changes I made were

* Moved code for manipulating and displaying diffs to a separate
  module called diffs.m (and changed their calls in diff.m).  The type
  'lcss,' needed both by the rest of lcss.m and by diffs.m, was moved
  to a new module lcsstype.m.

* Made lcss.m independent of files, and allowed it to process any kind
  of list by adding polymorphism.  (The file processing calls have
  been moved to diff.m.)

* Added type synonyms 'pos' and 'segment' in diffs.m to clarify the
  types.  Renamed 'single_diff' to 'edit'.

* Added end-of-file match to the generated lcss, thereby allowing the
  to_diff predicate to be simplified considerably.

* Numbered lists from 0 internally in the lcss-algorithm.  This made
  to_diff simpler still, but also forced changes in the diff-printing
  part.

* Removed the swapping in find_lcss, because it doesn't seem to help.

* The array(string) representing a file in file.m was also renumbered
  to begin with 0.

* Added and corrected comments.

Have fun,

 <><

Marnix
--
Marnix Klooster
marnix@worldonline.nl