home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol023 / sigmv023.ark / COMPARE.DOC < prev    next >
Text File  |  1984-04-29  |  9KB  |  277 lines

  1.  COMPARE - Compare Two Textfiles                  03 Jan 79
  2.  
  3.       Compare - Compare Two Textfiles and Report Their Differences
  4.  
  5.                 James F.  Miner
  6.            Social Science Research Facilities Center
  7.                   Andy Mickel
  8.                University Computer Center
  9.             University of Minnesota
  10.                Minneapolis, MN 55455 USA
  11.  
  12.                Copyright (c) 1977, 1978.
  13.  
  14.  What COMPARE Does
  15.  -----------------
  16.  
  17.       COMPARE is used to display the differences  between  two    similar
  18.  texts    (referred  to as "FILEA" and "FILEB").    Such textfiles could be
  19.  Pascal source programs, character data, documentation, etc.
  20.  
  21.       COMPARE is line-oriented, meaning the smallest unit of comparison
  22.  is  the  text    line  (ignoring  trailing blanks).  COMPARE generates a
  23.  report of differences (mismatches  or    extra  text)  between  the  two
  24.  textfiles.   The criterion for determining the locality of differences
  25.  is the number of consecutive lines on each file which must match after
  26.  a prior mismatch, and can be selected as a parameter.
  27.  
  28.       By selecting other parameters, you can direct COMPARE to restrict
  29.  the comparison to various linewidths, mark column-wise the differences
  30.  in  pairs  of    mismatched lines, generate text-editor directives to be
  31.  used to convert FILEA into FILEB, or generate    a  listing  which  will
  32.  flag  lines on FILEB indicating their addition or deletion as a result
  33.  of the application of the editor directives.
  34.  
  35.  How to Use COMPARE
  36.  ------------------
  37.  
  38.       COMPARE is available as an operating system control statement  on
  39.  CDC  6000/Cyber  70,170  computer  systems.   The  general form of the
  40.  control statement is:
  41.  
  42.       COMPARE(a,b,list,modfile/options)
  43.  
  44.       COMPARE.    means  COMPARE(FILEA,FILEB,MODS/C6,D,W120)
  45.  
  46.       "FILEA" and "FILEB" are the names  of  the  two  textfiles  being
  47.  compared, "OUTPUT" is the report file, and "MODS" is the file name for
  48.  the  generation  of  text-editor  directives  if  the    "M"  option  is
  49.  selected--see below.  The various options are:  C, D, F, M, P, and W.
  50.  
  51.  
  52.  
  53.                  - 1 -
  54.  
  55.  
  56.  COMPARE - Compare Two Textfiles                  03 Jan 79
  57.  
  58.   Cn   Match Criterion (1 <= n <= 100).
  59.       C  determines  the  number  of consecutive lines on each file
  60.       which  must  match  in  order  that  they  be  considered  as
  61.       terminating  a prior mismatch.  C therefore affects COMPARE's
  62.       "sensitivity" to the "locality" of differences.  Setting C to
  63.       a  large value tends to produce fewer (but longer) mismatches
  64.       than does a small value.  C6 appears to give good results  on
  65.       Pascal  source  files,  but  may  be    inappropriate for other
  66.       applications.
  67.       Default:  C6.
  68.  
  69.   D    Report Differences.
  70.       D directs  COMPARE  to  display  mismatches  and  extra  text
  71.       between  FILEA and FILEB in a clearly annotated report.  Only
  72.       one of D, F, or M can be explicitly selected at one time.
  73.       Default:  selected.
  74.  
  75.   F    Select Flag-form output.
  76.       F directs COMPARE to list FILEB annotated with lines prefixed
  77.       by  an  "A"  or  "D"    indicating  "additions"  or "deletions"
  78.       respectively.  Such modifications could have    been  generated
  79.       with    the M option.  Only one of D, F, or M can be explicitly
  80.       selected at one time.
  81.       Default:  not selected.
  82.  
  83.   M    Produce MODS file.
  84.       M directs COMPARE to produce a file of "INSERT"  or  "DELETE"
  85.       directives  ready  for  the CDC MODIFY or UPDATE text editors
  86.       (an "IDENT" directive must be  added).   The    insertions  and
  87.       deletions  will  convert  FILEA  into FILEB.    FILEA and FILEB
  88.       should be files with sequencing appearing in    columns  beyond
  89.       the  linewidth  specified  by  the W option.    This is true of
  90.       MODIFY and  UPDATE  "COMPILE"  files    (W72  is  recommended).
  91.       Sequence numbers are of the form:
  92.  
  93.            {Blanks} IdentName {Blanks} UnsignedInteger.
  94.  
  95.       Only    one  of  D,  F,  or M can be explicitly selected at one
  96.       time.
  97.       Default:  not selected.
  98.  
  99.   P    Mark Pairs of mismatched lines.
  100.       P alters the action of the D directive by  marking  differing
  101.       columns in pairs of lines which mismatch in sections of equal
  102.       length.  This is especially useful for comparing packed  data
  103.       files.
  104.       Default:  not selected.
  105.  
  106.   Wn   Specify significant line Width (length) (10 <= n <= 150).
  107.       W  determines  the fixed number of columns of each line which
  108.       will be compared.  W is ideal to use when  sequence  informa-
  109.       tion is present at the right edge of the text file.
  110.       Default:  W120.
  111.  
  112.  
  113.  
  114.                  - 2 -
  115.  
  116.  
  117.  COMPARE - Compare Two Textfiles                  03 Jan 79
  118.  
  119.  Example
  120.  -------
  121.  
  122.  Suppose FILEA is:
  123.  
  124.      PROGRAM L2U(INPUT, OUTPUT);
  125.       (* CONVERT CDC 6/12-ASCII LOWER-CASE
  126.          LETTERS TO UPPER CASE.  *)
  127.      BEGIN
  128.       WHILE NOT EOF(INPUT) DO
  129.        BEGIN
  130.         WHILE NOT EOLN(INPUT) DO
  131.          BEGIN
  132.           IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  133.           GET(INPUT)
  134.          END;
  135.         READLN;
  136.         WRITELN
  137.        END;
  138.       (*ALL DONE.*)
  139.      END.
  140.  
  141.  
  142.  
  143.  and FILEB is:
  144.  
  145.      PROGRAM U2L(INPUT, OUTPUT);
  146.       (* CONVERT CDC ASCII UPPER-CASE LETTERS
  147.          TO 6/12 LOWER CASE.  *)
  148.      BEGIN
  149.       WHILE NOT EOF(INPUT) DO
  150.        BEGIN
  151.         WHILE NOT EOLN(INPUT) DO
  152.          BEGIN
  153.           IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76));
  154.           WRITE(INPUT^);
  155.           GET(INPUT)
  156.          END;
  157.         READLN;
  158.         WRITELN
  159.        END;
  160.      END.
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.                  - 3 -
  169.  
  170.  
  171.  COMPARE - Compare Two Textfiles                  03 Jan 79
  172.  
  173.  then a report from COMPARE looks like this:
  174.  
  175.    COMPARE,L2U,U2L,LIST/C1,D,P.             78/12/31. 20.23.25.
  176.    COMPARE VERSION 3.0 CDC               (78/12/19)
  177.  
  178.    OUTPUT OPTION    = DIFFERENCES.
  179.    INPUT LINE WIDTH = 120 CHARACTERS.
  180.    MATCH CRITERION  = 1 LINES.
  181.  
  182.    FILEA: L2U
  183.    FILEB: U2L
  184.  
  185.      ***********************************
  186.    MISMATCH: L2U LINES 1 THRU 3 <NOT EQUAL TO> U2L LINES 1 THRU 3:
  187.  
  188.  A    1. PROGRAM L2U(INPUT, OUTPUT);
  189.  B    1. PROGRAM U2L(INPUT, OUTPUT);
  190.          ^ ^
  191.  
  192.  A    2.  (* CONVERT CDC 6/12-ASCII LOWER-CASE
  193.  B    2.  (* CONVERT CDC ASCII UPPER-CASE LETTERS
  194.              ^^^^^^^^^^^^^^^^^^^^^^^^
  195.  
  196.  A    3.     LETTERS TO UPPER CASE.  *)
  197.  B    3.     TO 6/12 LOWER CASE.  *)
  198.          ^^^^^^^ ^ ^^^^^^^^^^^^ ^^
  199.  
  200.      ***********************************
  201.    MISMATCH: L2U LINE 9 <NOT EQUAL TO> U2L LINES 9 THRU 10:
  202.  
  203.  A    9.      IF INPUT^ <> CHR(76) THEN WRITE(INPUT^);
  204.  
  205.  B    9.      IF INPUT^ IN ['A'..'Z'] THEN WRITE(CHR(76));
  206.  B   10.      WRITE(INPUT^);
  207.  
  208.      ***********************************
  209.    EXTRA TEXT ON L2U, BETWEEN LINES 15 AND 16 OF U2L
  210.  
  211.  A   15.  (*ALL DONE.*)
  212.  
  213.  How COMPARE Works
  214.  -----------------
  215.  
  216.       COMPARE employs a simple backtracking-search algorithm to isolate
  217.  mismatches  from  their  surrounding  matches.  Each mismatch requires
  218.  dynamic storage roughly  proportional    to  the  size  of  the    largest
  219.  mismatch,  and  time roughly proportional to the square of the size of
  220.  the mismatch.    Thus it may not be feasible to    use  COMPARE  on  files
  221.  with very long mismatches.
  222.  
  223.  
  224.  
  225.  
  226.                  - 4 -
  227.  
  228.  
  229.  COMPARE - Compare Two Textfiles                  03 Jan 79
  230.  
  231.  History
  232.  -------
  233.  
  234.       COMPARE was developed as a portable-Pascal software tool by James
  235.  Miner    of  the  Social  Science  Research  Facilities    Center    at  the
  236.  University  of  Minnesota,  in early 1977.  It was written in standard
  237.  Pascal and developed initially under CDC 6000    Pascal.   Although  the
  238.  original  version  simply  reported differences in a textfile, COMPARE
  239.  was designed to fit  naturally  into  a  larger  text-editing    system.
  240.  Plans    for  COMPARE's  accommodating  later  enhancements  to generate
  241.  text-editor directives were made from the  beginning.     In  summer  of
  242.  1977,    John  Strait  at  the  University  of Minnesota Computer Center
  243.  adapted COMPARE not only to generate such a  modifications  file,  but
  244.  also flag-form output and user-selectable options.
  245.  
  246.       COMPARE has been distributed to several Pascal enthusiasts in the
  247.  United States who have made it operational on other Pascal implementa-
  248.  tions.   See  Pascal  News #12, May, 1978, pages 20-23.  In late 1978,
  249.  Willett Kempton of the Anthropology Department at  the  University  of
  250.  California  Berkeley,    installed  COMPARE  (with  no  changes required
  251.  whatsoever) under Berkeley UNIX Pascal on a PDP 11/70 computer system.
  252.  He  later adapted the program to note column-wise differences in pairs
  253.  of different lines and made minor changes to the format of the report.
  254.  
  255.       Rick  Marcus  and  Andy  Mickel  at  the    University of Minnesota
  256.  Computer Center made minor enhancements to COMPARE and fully  documen-
  257.  ted it it for Release 3 of Pascal 6000 in December, 1978.
  258.  
  259.       COMPARE  is  a  model  program  in  many    respects.  It serves to
  260.  illustrate just how powerful and flexible such  a  comparison    program
  261.  can be.
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.                  - 5 -
  277.