User:PerfektesChaos/WikidiffLX/coding

Implementation suggestions for WikidiffLX in C++ code.

Migration from Wikidiff2
The development was based on wikidiff2 (rev 84056).


 * wikidiff2.cpp
 * WikidiffLX.cpp – Re-written and extended.


 * wikidiff2.h
 * Split into WikidiffLX.h class and WDLX_config.h configuration.


 * Word.h
 * Moved into Word.cpp – extension changed, small amendments
 * Word.h – class declaration only


 * DiffEngine.cpp
 * Not changed.


 * DiffEngine.h
 * Name of include WikidiffLX.h adapted.

New files:


 * Line.cpp and Line.h
 * WDLX_config.h general configuration separated for integration, testing and debugging purposes.

Envision presentation without line number headers
Make any use of line number headers dependent on new macro NOLINENUMBERS if one day decided to skip these numbers.

Reserve buffer for line number headers once
Reserve space for line number headers once only.

Avoid trouble with possible long characters
wchar_t was replaced by explicitly unsigned long in order to prevent C90 fuzz from compilers. 32bit long characters are required for CJK. There is no need to adapt on 16bit characters silently.

For the same reason the type of nextUtf8Char is unsigned int now.

Number of context lines
The number of context lines became class member now rather than passing through many argument lists. Actually it is a kind of fixed global parameter but may be subject to change without new compilation.

op codes
The result of the diff engine is an amalgamated sequence of parts, containing the original from and to as well as a code op as follows. For lines this is displayed by yellow and green colour: Entire part absolutely unchanged. Number of parts between two neighbouring copy chunks unchanged and content differs. Count of parts between neighbouring copy chunks differs and another content; from has the greater number and this is attached to from while to</tt> is null. Count of parts between neighbouring copy</tt> chunks differs and another content; to</tt> has the greater number and this is attached to to</tt> while from</tt> is null.
 * copy</tt>
 * change</tt>
 * del</tt>
 * add</tt>

Note that from</tt> and to</tt> lines with the same op</tt> code are merged into arrays of pointers to line by diff engine.