| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
text.diff - Calculate difference of text streams This module calculates the difference of two text streams or strings,
using util.lcs (See section util.lcs - The longest common subsequence).
Generates an "edit list" from text sources src-a and src-b.
Each of text sources, src-a and src-b, can be either an input
port or a string. If it is a string, it is converted to a string input
port internally. Then, the text streams from both sources are converted
to sequences by calling reader repeatedly on them; the default
of reader is read-line, and those sequences are
passed to lcs-edit-list to calculate the edit list.
The equality function eq-fn is also passed to lcs-edit-list.
An edit list is a set of commands that turn the text sequence
from src-a to the one from src-b.
See the description of lcs-edit-list for
the detailed explanation of the edit list.
(diff "a\nb\nc\nd\n" "b\ne\nd\nf\n") ⇒ (((- 0 "a")) ((- 2 "c") (+ 1 "e")) ((+ 3 "f"))) |
A convenience procedure to take the diff of two text sources
and display the result nicely. This procedure calls lcs-fold
to calculate the difference of two text sources. The meanings of
src-a, src-b, reader and eq-fn are the
same as diff's.
Writer is a procedure that takes two arguments, the text element
and a type, which is either a symbol +,
a symbol -, or #f. If the text element is only
in src-a, writer is called with the element and
-. If the text element is only in src-b,
it is called with the element and +. If the text element
is in both sources, it is called with the element and
#f. The default procedure of writer prints
the passed text element to the current output port
in unified-diff-like format:
(diff-report "a\nb\nc\nd\n" "b\ne\nd\nf\n") |
displays:
- a b - c + e d + f |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.