Dec 072017
 
These two programs (C source included) form the basis of a version control system. Program 1 'compare' generates deltas. Program 2 'update' applies deltas.
File VERCTL.ZIP from The Programmer’s Corner in
Category C Source Code
These two programs (C source included) form the basis of a version control system. Program 1 ‘compare’ generates deltas. Program 2 ‘update’ applies deltas.
File Name File Size Zip Size Zip Type
COMPARE.C 22241 6680 deflated
COMPARE.H 1579 520 deflated
MAKEFILE 133 64 deflated
READ.ME 10495 3732 deflated
READ.MEP 329 207 deflated
UPDATE.C 29207 7666 deflated

Download File VERCTL.ZIP Here

Contents of the READ.ME file


COMPARE.C
UPDATE.C

Copyright (C) Seven Valleys Software 1985,1987,1988
Written for Seven Valleys Software by Cheyenne Wills &
Released For Public Distribution
All Rights Reserved

Permission is granted to freely distribute this code, but not for
profit, provided that this notice and the following disclaimer are
included in their entirety and without modifications of any sort. This
work may not be sold, or modified and sold, or included in any other
work to be sold, (except for a nominal media charge), without the
written permission of the author.

Permission is granted to modify the source code and distribute it in
modified form PROVIDED that the authors of any modifications identify
themselves with name and address following this header and that all such
modifications are clearly indicated as to location and purpose, with
descriptive comments that clearly indicate modified lines.

The author would appreciate hearing of any modifications that may be
made, but makes no guarantees that such modifications will be
distributed with future releases of this program.

Author's address:

Cheyenne C. Wills
12 West Locust St.
Mechanicsburg, Pa. 17055
(717) 697-5198

Written for
Seven Valley's Software
P.O. Box 99
Glen Rock, Pa 17327

Disclaimer:

No guarantees or warranties of any kind: This code is distributed
"AS IS" without any warranty of any kind, either expressed or implied,
including, but not limited to the implied warranties of merchantability
and fitness for a particular purpose. You are soley responsible for the
selection of the program to achieve your intended results and for the
results actually obtained. Should the program prove defective, you (and
not the author) assume the entire cost of all necessary servicing,
repair, or correction.

Neither the author nor anyone else who has been involved in the
creation, production or delivery of this program shall be liable for any
direct, indirect, consequential or incidental damages arising out of the
use or inability to use this program.
-------------------------------------------------------------------------------

Manifest:

compupdt.arc
read.me - this file
compare.exe- text file compare utility
update.exe- merges a base file and "update" files
compare.c- source code for compare utility
update.c- source code for update utility
makefile- makefile used for creating compare.exe and
update.exe

Notes:

Both the .EXE files will run in OS/2 and MSDOS (ie they have been bound
with the family API library).

The makefile may not work with Microsoft's MAKE utility. I have another
MAKE utility that works more like AT&T's UNIX MAKE.

-------------------------------------------------------------------------------
Overview

The compare and update utilities were designed to provide a facility to
help maintain source code files. They were patterned off the UPDATE
factility provided by IBM's VM system. Given two "levels" of a file,
the compare utility can generate an "update" file that describes the
changes that have to be made to the first level to bring it up to the
same level as the second file.The update utility takes a base level
of a file, and either a single update file or a list of update files and
applies all the requested changes. The smallest "unit" that compare and
update work with is a line. This means that if you change a word then
the entire line will be marked as changed.

Instead of creating an update file, the compare utility can generate a
report of the differences between the two files. This facility is very
handy (in fact it is the default operation of compare) and will be the
mode you will probably use the most. Again the smallest "unit" of
change is a line.

UPDATE Facility

The update facility is based around a concept of a base file that once
it is created will not be changed, and update files that describe (to
the update utility) the changes required to go from one level of changes
to another.

An important concept that the update facility uses are "sequence
numbers". When you create the base file, each line will be assigned a
number. When you apply an update to the base,the update file contains
control statements that match these sequence numbers. An example might
best explain the concept.

Example:
Seq Nums ---- BASE ----
+--------------------------------------------+
[0010000] |#include |
[0020000] |main(argc,argv)|
[0030000] |int argc; char **argv;|
[0040000] |{|
[0050000] |printf("%d\n",argc); |
[0060000] |}|
+--------------------------------------------+
--- Update for creating level1 ---
+--------------------------------------------+
|./ R 30000 50000 $ 36000 6000|
|int argc;|
|char **argv;|
|{|
|printf("The number of args = %d\n",argc); |
+--------------------------------------------+
Seq Nums --- LEVEL1 ---
+--------------------------------------------+
[0010000] |#include |
[0020000] |main(argc,argv)|
[0036000] |int argc;|
[0042000] |char **argv;|
[0048000] |{|
[0054000] |printf("The number of args = %d\n",argc); |
[0060000] |}|
+--------------------------------------------+

There are several things to notice in the above example. First the
sequence numbers are not really added to the file. Instead they are
assigned by compare and update at execution time. The starting value
and increment are command line parms. Second the sequence numbers for
lines that have been changed are replaced with a new sequence number.
The new number will not have the same value has the original. This is
to prevent applying updates that hit the same line(s) out of order. The
third thing is that the assigning of the sequence numbers must be
consistant between one invocation of compare/update and the next.
Otherwise the updates might get placed on the wrong lines.

UPDATE control statements

The following is a list of the UPDATE control statements.


./ D seqno1 [seqno2]
Deletes lines from seqno1 upto and including seqno2. Seqno1 is
required, seqno2 defaults to seqno1 (thus deleting only that line)
The next line in the update file must be a valid update control record.


./ I seqno [$ [seqstrt [seqincr]]]
Inserts lines following seqno.The dollar sign is an indicator that
there could be two more options. The seqstrt (default is seqno+100) is
the sequence number value of the first inserted line. Seqincr (default
is 100) is the increment to be added to get the next sequence number.

./ R seqno1 [seqno2] [$ [seqstrt [seqincr]]]
Replaces lines starting at seqno1 upto and including seqno2. The
default for seqno2 is seqno1. Seqstrt and seqincr have the same meaning
as in the insert statement.

./ S seqstrt seqincr
Resequences the file.If specified - it must be the first control
statement in the file.Seqstrt is the starting sequence number, seqincr
is the value added to the current sequence number to produce the next
one. Default for seqstrt is 10000 and the default for seqincr is
seqstrt.

./ * [comment]
Comment cards..


-------------------------------------------------------------------------------
Command formats

COMPARE [options]

Where:

and are the two files to be compared

[options] are:

-l []Generate output to file
defaults to COMPARE.LST
-wIgnore white space between 'words'
-tIgnore case
-pGenerate output to the printer
-mnResync on n lines (default is 2)
-cx,yOnly compare cols x thru y

------------ following for update deck generation only ------------
-u [] Generate update deck to make file1 into file2
defaults to the ."UPT"
-sx,yGenerate internal sequence numbers starting with x
and increment by y. Default if -s is omitted is 1,1
if -s is specified with out x and y then x=10000
y defaults to x
-xFile1 already contains sequence numbers
------------ following for aide with editor shells only -----------
-iUse a sequence file (generated from UPDATE command)
name is ."SEQ"
will be deleted

UPDATE [] [options]
Where:
is the name of the file to be updated
is the name of the delta deck
is the name of the output file (defaults to $)

[options]

-p Print a brief update log to PRN
-pf Print a Full log (each update is listed) to PRN

-l [] List a brief update log to (default is UPDATE.LOG)
-lf [] List a Full update log to (default is UPDATE.LOG)

-s[S,I] Generates sequences numbers starting with S and incremented
by I. S defaults to 10000 and I defaults to S.

---- The following options control if the sequence numbers already
---- exist in the input file.
-xi Input file contains sequence numbers as the first "word"
of each line. (ex: 10000 10 rem fist line).
-xio[S,I] Input file contains sequence numbers as the first "word"
output file will also contain sequence numbers as the
first word. If S is specified, then the output will
be resequenced starting with S.I (the increment)
defaults to S.
-xo[S,I] Resequence the output file.

-c Control file. is the name of a control file
is the name of the output file.
is unused.
Each line of the control file contains as its
first "word" the extension of an input file.
the first line must be the extension of base file.
ex:
>> DIR SAMP.* ->
SAMP.CTL
SAMP.V00
SAMP.V01
+---------------COMPARE.CTL-------------------+
| V00 Base of SAMP.C |
| V01 Add -i option and online doc |
+---------------------------------------------+
To generate SAMP.C
UPDATE SAMP.C SAMP.CTL -c

------------ following for aid with editor shells only -----------
-i Generate a sequence file to be used by COMPARE
on the last pass generate a external sequence file.




 December 7, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)