home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / tools / compmod / cmpmod.doc next >
Text File  |  1989-04-13  |  8KB  |  122 lines

  1. COMPARE/MODIFY documentation                             Version 1.0 - 4/14/89
  2. ------------------------------------------------------------------------------
  3. What ?         COMPARE is a utility for comparing files. Files can be of any
  4.                type and any size. COMPARE writes a scriptfile as it runs over
  5.                the two input files. The scriptfile documents the differences
  6.                between the two files in a format, which allows MODIFY to build
  7.                the modified from the original. COMPARE will recognize both
  8.                insertions, deletions and replaces as differences between the
  9.                original and the modified.
  10.  
  11. Why ?          Originally I started to write this utility as a means to cut
  12.                down on my phone bill. I have a number of utilities in the
  13.                CompuServe DLs, and uploading a scriptfile with a modification
  14.                is much cheaper than uploading the entire modified version,
  15.                especially with a moderate number of changes. Building a
  16.                traditional patch file is a tedious and time consuming process
  17.                and it's not very user friendly. With this utility I can make
  18.                any modifications without having to worry about the code
  19.                getting bigger or smaller, as COMPARE will automatically
  20.                determine this. All I have to do is to keep the original
  21.                version intact.
  22.  
  23.                Whereas the reasons just mentioned were the initial motivation
  24.                for writing these two programs, it occured to me during the
  25.                testing process, that there are other and much more creative
  26.                ways of using them:
  27.  
  28.                One of the most annoying restrictions in pascal is the missing
  29.                support for dynamic array, i.e. the ability to specify array
  30.                bounds at runtime. I've got a stock management system, which
  31.                exists in two version, one with an item code length of 10, and
  32.                one with an item code length of 13. The actual size depends on
  33.                a constant, which is referenced in the type definitions and
  34.                throughout the source code. I compiled each version and ran
  35.                COMPARE on both the EXE and OVR files. The EXE files were
  36.                169,312 bytes long for both version, and the OVR files were
  37.                368,052 and 368,069 respectively. The resulting EXE script
  38.                was 2,596 bytes and the OVR script was 17,677 bytes. Instead
  39.                of distributing both versions, I now distribute only one and
  40.                include the script files and MODIFY.EXE. My installation
  41.                procedure calls MODIFY as a child, if the longer code is
  42.                requested.
  43.                This is just an example. In another test I tried to include
  44.                an entire unit in the second version, which was not in the
  45.                first, this time keeping the same item code length. The unit
  46.                code size was 7K. The script for the EXE was only 257 bytes
  47.                and the script for the OVR was 10K (including of course the
  48.                entire code for the inserted unit).
  49.  
  50.                The only limit is your imagination and the maximum look ahead
  51.                of 16,384 bytes, more on that in the next paragraph.
  52.  
  53. How ?          COMPARE is invoked like this:
  54.  
  55.                   COMPARE Original Modified Script
  56.  
  57.                MODIFY like this:
  58.  
  59.                   MODIFY Original Script Modified
  60.  
  61.                In this context Modified simple means the file, which should
  62.                be rebuilt from Original. There is no restriction that the
  63.                Modified be newer than Original. In fact you can just as well
  64.                use COMPARE to enable tracing back through version by doing
  65.                COMPARE Newest Oldest Script.
  66.                COMPARE assumes no default extensions and all files must be
  67.                in the current directory. No check on existing scriptfiles
  68.                is made.
  69.  
  70.                COMPARE stores date, time and size of both the Original and
  71.                the Modified in the Script. MODIFY checks that Original matches
  72.                the date, time and size and aborts with an error message and
  73.                returns an error code of 1, if this is not the case. When
  74.                MODIFY completes, it checks that the Modified has the expected
  75.                length, i.e. the length of Modified in the ScriptFile. If this
  76.                is not the case, an error message is printed and an error code
  77.                of 2 is returned. If MODIFY succeeds, it changes the date and
  78.                time of Modified to the one in the ScriptFile. This prevents
  79.                MODIFY to be run again on the same file, and also supports
  80.                the popular scheme of having the version # in the time field.
  81.  
  82.                COMPARE can sometimes be quite slow. The execution times depend
  83.                heavily on the amount of redundancy between Original and
  84.                Modified. If there are lots of changes, COMPARE must use a lot
  85.                of effort trying to get back in sync after an insert, delete or
  86.                replace. This requires a lot of scanning back and forth in the
  87.                buffers. This process involves a certain amount of guesswork
  88.                because an identical sequence of bytes in the two files is not
  89.                necessarily a resync spot. COMPARE does not always produce the
  90.                smallest possible script, as this would require trying all
  91.                possible solutions, and that would of course make it too slow.
  92.                As scanning times are a function of the buffer lengths, these
  93.                are kept at 16384 bytes. This obviously restricts the size of
  94.                inserted and deleted sequences of bytes that can be handled
  95.                with a subsequent resync to this length. Actually the figure is
  96.                somewhat smaller as there must be a recognizable sequence of
  97.                bytes after the inserted/deleted image. On the other hand
  98.                there is nothing to keep you from inserting multiple blocks
  99.                as long as a resync can take place between them. If COMPARE can
  100.                not resync, it will include bytes from Modified in the script
  101.                until it can or until Modified exhausted. This means that
  102.                Modified can be expanded with any amount of bytes.
  103.  
  104.                Whereas COMPARE can be quite slow, MODIFY is very fast and
  105.                it requires less than 32K (around 26) to operate. This makes
  106.                it suitable for EXECing.
  107.  
  108.                Script files produced by COMPARE can usually be compressed
  109.                with standard archiving utilities to 40-60% of their original
  110.                size.
  111.  
  112. Who ?          COMPARE.EXE & MODIFY.EXE were written by Per Larsen. MODIFY was
  113.                written entirely in Turbo Pascal Version 5, COMPARE was written
  114.                partly in TP5, partly in assembler.
  115.  
  116.                Both utilities are hereby released to the public domain. Use
  117.                for whatever purpose you like. If you encounter any problems
  118.                or come up with an interesting use of these utilities, please
  119.                let me know. I can be reached at CompuServe as 75470,1320 or
  120.                by writing me at this address: Per Larsen, Vesterled 24,
  121.                DK-8600 Silkeborg, Denmark.
  122.