This script manages display of code differences between two versions of a source file.
fflush ()
Function fflush
sets STDOUT in autoflush mode.
Note:
The reason for using this function is not clear. It has been commented out without adverse effect.
Being very short, it could be inlined (only one usage!) if it needs to be reenabled.
htmljust ($s, $w)
Function htmljust
returns an HTML string justified to exactly a fixed number of screen positions.
$s
a string containing an HTML sequence
$w
an integer defining the justification width
The string argument is truncated or expanded to show exactly $w
"characters" on screen.
Atomic units must not be split, otherwise HTML integrity is broken. HTML tags and entity references are copied without truncation.
When checking overflow, HTML tags are considered as zero-width "characters" and HTML entity references as one screen position glyphs (which is not always the case: combining diacritic marks, zero-width spacers, ...).
When the desired width is met, opening tags may not have been matched by their closing tags. To return a synctactically correct HTML sequence, HTML tags are still copied but without their content. This results in a sequence longer than necessary, but it is safe.
printdiff (@dargs)
Procedure printdiff
is the main driver for difference display (two passes).
@dargs
an array containing the 'variables'
values for the reference version
When entered for the first time, query arguments only offer current 'variables'
values. This is detected by the absence of any ~
var_name=
... argument. Current values are then transfered into these so-called remembered values and user is requested to choose another version.
On second entry, both current values (var_name=
...) and remembered values (~
var_name=
...) are present in the query arguments. The latter values designate the reference version (in the right pane); the former values the "new" version (in the left pane). With these two file descriptions, processing can be done.
The file name in $pathname
has been nominally transformed by the 'maps'
rules. But to get the other name, we must first reverse the effects of these rules (in the remembered environment) et re-apply them (in the current environment). Once this is done, both file names correctly point to the desired versions.
Next, physical (real) files are obtained so that rcs diff can build the patch directives..
Both files are highlighted by markupfile
. The resulting HTML streams are kept in memory. This could cause a serious strain on memory and degrade performance (because of swapping for instance).
Then it is relatively simple to merge both streams line by line under control of the patch directives.
Builds the header and footer and launches printdiff
for the real job.