home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
MERGE10P.ZIP
/
MERGE.DOC
next >
Wrap
Text File
|
1991-05-01
|
14KB
|
355 lines
MERGE 1.00
Purpose
-------
MERGE compares two versions of a program source file and
generates a third file that is a "merger" of the two. The merge
file contains all source from both versions; differences between
the two versions are bracketed by conditional compilation
directives. Thus, either version can be compiled/assembled by
setting appropriate compiler switches or declaring constants in
the source.
MERGE directly supports C, Pascal, and assembler. It can be
used with languages that support conditional compilation, but
you may have to change the conditional compilation directives in
the merge file.
MERGE is available in both DOS and OS/2 versions (distributed in
separate libraries). Usage is identical for both versions. The
OS/2 version is not a PM application, but it can be run in a
window.
Running MERGE
-------------
The general syntax for MERGE is:
hdiff [/options] old-file new-file [merge-file]
The simplest use of MERGE is exemplified by:
merge oldver.c newver.c
This compares OLDVER.C and NEWVER.C and generates a merged
version of the two, which is displayed. You can record the
merged version in a disk file either by redirecting the output
or by specifying a third filename:
merge oldver.c newver.c > merger.c
merge oldver.c newver.c merger.c
In either case, MERGER.C will contain the merged version.
Option switches
-----------------
Option switches must precede the filenames. They may be
introduced by either '/' or '-' and are not case sensitive. The
options are:
/C Case insensitive comparison: MERGE ignores differences
in alphabetic case in the source. Thus, the two lines:
This is text
THIS IS TEXT
are not reported as changed.
/Dname Declares the name of the conditional compilation
constant. For example, "/D_OS2" declares the constant
to be "_OS2", and MERGE will use conditional compilation
directives in the form "#ifdef _OS2" (for C). If no
constant name is specified, MERGE creates a name based
on the current date and time; this allows you to use a
merged file as one of the bases for a later merge
without duplicating the constant name. In general,
however, we recommend that you specify a name.
/I# Specifies an indentation value. All lines between
conditional compilation directives will be indented the
number of spaces specified. For example, if you use /I2
and the original lines were flush-left (not indented),
the merge file might look like this:
#ifdef foo
statement2
#else
statement1
#endif
Without the /I, it would look like this:
#ifdef foo
statement
#else
statement
#endif
/I simply makes the merge file easier to read. Valid
value for /I are from 1 to 20.
/Lx Specifies the language. The option can be any of:
/La Assembler
/Lc C
/Lp Pascal
In assembler mode, MERGE uses the following directives:
IFDEF name
IFNDEF name
ELSE
ENDIF
In C mode, MERGE uses:
#ifdef name
#ifndef name
#else
#endif
In Pascal mode, MERGE uses (these are the directives
used by Turbo Pascal; others may vary):
{$IFDEF name}
{$IFNDEF name}
{$ELSE}
{$ENDIF}
The default language is based on the extension of the
first file specified:
.ASM Assembler
.PAS Pascal
other C
Thus, you will need the /L option only if MERGE won't
default to the correct language for your current source.
/S Space insensitive: MERGE ignores differences in spacing.
Thus, the two lines:
This is text
This is text
are not considered to have been changed.
Examples
--------
Examples of MERGE use:
merge one.c two.c
Compares ONE.C with TWO.C and displays a merged version.
merge one.c two.c three.c
Compares ONE.C with TWO.C and creates a merged version
in the new file THREE.C
merge one.c two.c > three.c
Identical to previous example.
merge /DP386 one.c two.c three.c
As above, but the conditional compilation directives
will reference the constant 'P386'.
merge /C /DDOS /I4 one.pas two.pas three.pas
Merges Pascal files ONE.PAS and TWO.PAS into THREE.PAS.
The file comparison is case-insensitive, and the
constant will be named "DOS". Conditionally compiled
statements will be indented four spaces.
The merge file
--------------
As an example of what a merge file looks like, suppose we have
a DOS version and an OS/2 version of this do-nothing assembler
program:
DOS VERSION OS/2 VERSION
------------ ------------
.MODEL SMALL .MODEL SMALL
DOSSEG DOSSEG
.STACK 256 .STACK 4096
EXTRN DosExit:far
.CODE
start: .CODE
mov ax,@data start:
mov ds,ax mov ax,@data
mov ax,4C00h mov ds,ax
int 21h push 0
END start push 0
call DosExit
END start
If we then run the command
merge /D_OS2 /I2 dosprg.asm os2prg.asm prg.asm
the new file PRG.ASM will contain the following:
.MODEL SMALL
DOSSEG
IFDEF _OS2
.STACK 4096
EXTRN DosExit:far
ELSE
.STACK 256
ENDIF
.CODE
start:
mov ax,@data
mov ds,ax
IFDEF _OS2
push 0
push 0
call DosExit
ELSE
mov ax,4C00h
int 21h
ENDIF
END start
Thus, we could create the DOS version via:
masm prg;
or the OS/2 version via
masm /D_OS2 prg;
Alternatively, of course, we could add:
_OS2 equ 1
to the source to force the OS/2 version to be assembled.
Note the sense of the conditional compilation constant as MERGE
uses it: if the constant is defined, the second version is
created. If the constant is not define, the first version is
created. Keep this in mind when you're deciding on constant
names.
Restrictions
------------
The following act, in one way or another, as restrictions on
MERGE:
- File format: MERGE is intended for use with ASCII text files
only. Do not try to use it on binary data files, including word
processor files.
- Available memory: MERGE works entirely in memory, and it
needs quite a lot. The starting memory requirement is about
220K; then, for each UNIQUE line in either file, MERGE needs
about 12 bytes plus the length of the line. Identical lines are
stored only once, no matter how many times they occur. Thus,
the two files:
File 1:
Line 1
/* Comment */
Line 2
File 2:
Line 1
/* Comment */
/* Comment */
Line 2
Line 3
have four unique lines ("Line 1", "/* Comment */", "Line 2", and
"Line 3"). These will use about 79 bytes of storage (in
addition to the 220K starting memory!):
4 lines @ 12 bytes: 48
Total text length: 31
- Number of lines: neither file can exceed 5000 lines of text.
- Line size: limited to a maximum of 1000 characters per line.
- File contents: while not a restriction in the traditional
sense, we note here that the files should be reasonably similar!
If the two files are quite different, the resulting merge file
will be difficult to understand. MERGE is intended for use
against two files without relatively minor differences.
HDIFF
-----
MERGE is derived from HDIFF, a file difference finder also
released by Cove Software. HDIFF differs from MERGE in what it
does with the differences between the two files. MERGE combines
the two files to create a third (merged) version; HDIFF creates
a file of differences. This file is in the form of an editor
script that can be used to create the second version from the
first.
HDIFF is thus useful for tasks such as software version control:
you can retain multiple versions of a source file compactly and
conveniently by retaining an original (base) version and one or
more difference files. These difference files can be applied to
the base version to create the currect version or any previous
version.
Copyright/License/Warranty
--------------------------
This document and the program file MERGE.EXE ("the software")
are copyrighted by the author. If you are an individual, the
copyright owner hereby licenses you to: use the software; make
as many copies of the program and documentation as you wish;
give such copies to anyone; and distribute the software and
documentation via electronic means. There is no charge for any
of the above.
However, you are specifically prohibited from charging, or
requesting donations, for any such copies, however made; and
from distributing the software and/or documentation with
commercial products without prior permission. An exception is
granted to not-for-profit user's groups, which are authorized to
charge a small fee (not to exceed $7) for materials, handling,
postage, and general overhead. NO FOR-PROFIT ORGANIZATION IS
AUTHORIZED TO CHARGE ANY AMOUNT FOR DISTRIBUTION OF COPIES OF
THE SOFTWARE OR DOCUMENTATION, OR TO INCLUDE COPIES OF THE
SOFTWARE OR DOCUMENTATION WITH SALES OF THEIR OWN PRODUCTS.
THIS INCLUDES A SPECIFIC PROHIBITION AGAINST FOR-PROFIT
ORGANIZATIONS DISTRIBUTING THE SOFTWARE, EITHER ALONE OR WITH
OTHER SOFTWARE, AND CHARGING A "HANDLING" OR "MATERIALS" FEE OR
ANY OTHER SUCH FEE FOR THE DISTRIBUTION. NO FOR-PROFIT
ORGANIZATION IS AUTHORIZED TO INCLUDE THE SOFTWARE ON ANY MEDIA
FOR WHICH MONEY IS CHARGED.
Businesses, governmental entities, and institutions are
prohibited from installing or using the software on their
systems without specific permission. Licenses are available
from The Cove Software Group at the address shown below.
No copy of the software may be distributed or given away without
this document; and this notice must not be removed.
There is no warranty of any kind, and the copyright owner is not
liable for damages of any kind. By using this free software,
you agree to this.
The software and documentation are:
Copyright (C) 1991 by
Christopher J. Dunford
The Cove Software Group
P.O. Box 1072
Columbia, Maryland 21044
(301) 992-9371
CompuServe 76703,2002 [IBMNET]
Internet/Bitnet, etc.: 76703.2002@compuserve.com
Software and documentation author: Chris Dunford