package ocamldiff

  1. Overview
  2. Docs
OCamldiff is a small OCaml library providing functions to parse and display diff results

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ocamldiff-1.2.tar.bz2
md5=a7944e8628a72a6d3a22aa2e1e9abde3
sha512=edbc495be519b22c42e97140b756d831c71cb761efe38aabd599659954adee86404722c43d831c5ab72e65a43ce69d4973aa5072ce1f0b6abab90b87420c06cc

doc/ocamldiff/Odiff/index.html

Module OdiffSource

Computing differences.

Representation of differences

Sourcetype index = Odiff_types.index =
  1. | One of int
    (*

    one line

    *)
  2. | Many of int * int
    (*

    many lines, we have the first and the last

    *)

Index in a file or string.

Sourcetype diff = Odiff_types.diff =
  1. | Add of index * index * string
    (*

    for <index>a<index> and the added text

    *)
  2. | Delete of index * index * string
    (*

    for <index>d<index> and the deleted text

    *)
  3. | Change of index * string * index * string
    (*

    for <index>c<index> and the deleted and added texts

    *)

Representation of one difference.

Sourcetype diffs = diff list

Differences between two texts.

Printing differences

Sourceval string_of_diff : ?offset:int -> diff -> string

offset is added to line numbers. Default is 0.

Sourceval string_of_diffs : ?offset:int -> diffs -> string

offset is added to line numbers. Default is 0.

Sourceval print_diffs : out_channel -> ?offset:int -> diffs -> unit

Parsing differences

Sourceval from_string : string -> diffs

Return the list of differences from a string generated string.

Sourceval from_channel : in_channel -> diffs

Same as Odiff.from_string but read from the given in_channel.

Sourceval from_file : string -> diffs

Same as Odiff.from_string but read from the given file.

Computing differences

Sourceval files_diffs : string -> string -> diffs

files_diffs file1 file2 runs the diff command on the given files and returns its parsed output.

Sourceval strings_diffs : string -> string -> diffs

Same as Odiff.files_diffs but on strings. The two strings are put in two files to run the diff command. The files are removed before returning the result.