home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
tools
/
compmod
/
cmpmod.doc
next >
Wrap
Text File
|
1989-04-13
|
8KB
|
122 lines
COMPARE/MODIFY documentation Version 1.0 - 4/14/89
------------------------------------------------------------------------------
What ? COMPARE is a utility for comparing files. Files can be of any
type and any size. COMPARE writes a scriptfile as it runs over
the two input files. The scriptfile documents the differences
between the two files in a format, which allows MODIFY to build
the modified from the original. COMPARE will recognize both
insertions, deletions and replaces as differences between the
original and the modified.
Why ? Originally I started to write this utility as a means to cut
down on my phone bill. I have a number of utilities in the
CompuServe DLs, and uploading a scriptfile with a modification
is much cheaper than uploading the entire modified version,
especially with a moderate number of changes. Building a
traditional patch file is a tedious and time consuming process
and it's not very user friendly. With this utility I can make
any modifications without having to worry about the code
getting bigger or smaller, as COMPARE will automatically
determine this. All I have to do is to keep the original
version intact.
Whereas the reasons just mentioned were the initial motivation
for writing these two programs, it occured to me during the
testing process, that there are other and much more creative
ways of using them:
One of the most annoying restrictions in pascal is the missing
support for dynamic array, i.e. the ability to specify array
bounds at runtime. I've got a stock management system, which
exists in two version, one with an item code length of 10, and
one with an item code length of 13. The actual size depends on
a constant, which is referenced in the type definitions and
throughout the source code. I compiled each version and ran
COMPARE on both the EXE and OVR files. The EXE files were
169,312 bytes long for both version, and the OVR files were
368,052 and 368,069 respectively. The resulting EXE script
was 2,596 bytes and the OVR script was 17,677 bytes. Instead
of distributing both versions, I now distribute only one and
include the script files and MODIFY.EXE. My installation
procedure calls MODIFY as a child, if the longer code is
requested.
This is just an example. In another test I tried to include
an entire unit in the second version, which was not in the
first, this time keeping the same item code length. The unit
code size was 7K. The script for the EXE was only 257 bytes
and the script for the OVR was 10K (including of course the
entire code for the inserted unit).
The only limit is your imagination and the maximum look ahead
of 16,384 bytes, more on that in the next paragraph.
How ? COMPARE is invoked like this:
COMPARE Original Modified Script
MODIFY like this:
MODIFY Original Script Modified
In this context Modified simple means the file, which should
be rebuilt from Original. There is no restriction that the
Modified be newer than Original. In fact you can just as well
use COMPARE to enable tracing back through version by doing
COMPARE Newest Oldest Script.
COMPARE assumes no default extensions and all files must be
in the current directory. No check on existing scriptfiles
is made.
COMPARE stores date, time and size of both the Original and
the Modified in the Script. MODIFY checks that Original matches
the date, time and size and aborts with an error message and
returns an error code of 1, if this is not the case. When
MODIFY completes, it checks that the Modified has the expected
length, i.e. the length of Modified in the ScriptFile. If this
is not the case, an error message is printed and an error code
of 2 is returned. If MODIFY succeeds, it changes the date and
time of Modified to the one in the ScriptFile. This prevents
MODIFY to be run again on the same file, and also supports
the popular scheme of having the version # in the time field.
COMPARE can sometimes be quite slow. The execution times depend
heavily on the amount of redundancy between Original and
Modified. If there are lots of changes, COMPARE must use a lot
of effort trying to get back in sync after an insert, delete or
replace. This requires a lot of scanning back and forth in the
buffers. This process involves a certain amount of guesswork
because an identical sequence of bytes in the two files is not
necessarily a resync spot. COMPARE does not always produce the
smallest possible script, as this would require trying all
possible solutions, and that would of course make it too slow.
As scanning times are a function of the buffer lengths, these
are kept at 16384 bytes. This obviously restricts the size of
inserted and deleted sequences of bytes that can be handled
with a subsequent resync to this length. Actually the figure is
somewhat smaller as there must be a recognizable sequence of
bytes after the inserted/deleted image. On the other hand
there is nothing to keep you from inserting multiple blocks
as long as a resync can take place between them. If COMPARE can
not resync, it will include bytes from Modified in the script
until it can or until Modified exhausted. This means that
Modified can be expanded with any amount of bytes.
Whereas COMPARE can be quite slow, MODIFY is very fast and
it requires less than 32K (around 26) to operate. This makes
it suitable for EXECing.
Script files produced by COMPARE can usually be compressed
with standard archiving utilities to 40-60% of their original
size.
Who ? COMPARE.EXE & MODIFY.EXE were written by Per Larsen. MODIFY was
written entirely in Turbo Pascal Version 5, COMPARE was written
partly in TP5, partly in assembler.
Both utilities are hereby released to the public domain. Use
for whatever purpose you like. If you encounter any problems
or come up with an interesting use of these utilities, please
let me know. I can be reached at CompuServe as 75470,1320 or
by writing me at this address: Per Larsen, Vesterled 24,
DK-8600 Silkeborg, Denmark.