The Demon source showed all the signs of having been worked on by a large number of people, all of whom had different ways of doing things. The code indentation and layout style was rather strange, and made the code very difficult to read in places.
The first thing to do was to try and make the PCElm source easier to work on, while still retaining exact equivalence to the Demon version: this makes it fairly easy to fix bugs in "our" source, then apply those bug fixes to the (equivalent) Demon source, ready to be submitted to Richard Clayton for inclusion in the Demon version.
Another goal was to try, where possible and without changing the compilation results, to fix as many warnings as possible. The source was recompiled with all the Borland C warnings on: this produced 30 warnings. It was also run through Gimpel Software's PC-lint 7.50 (a splendid and viciously pedantic C/C++ syntax checker and more): this produced 800 warnings with sensible options! It should be pointed out that approximately 300 of these were caused by pcelm.h and proto.h, which are included by almost all the source files (sometimes more than once! 8-), and therefore some of these are multiple instances of the same warnings.
It was possible to eliminate all but 3 of the Borland warnings, and all but 116 of the PC-lint warnings, without changing the compiled result: those warnings which could not be eliminated have been individually suppressed in the source, with "ST-FIXME" comments to make sure that they get revisited.
The changes made are roughly as follows:
unsigned int func(int arg1, char *arg2) { char c = 16; unsigned int x, y; if (arg1 == 25 || arg1 > 55) { c = func1(arg2); x = func2(arg2, (int) c * arg1++); } else x = func2(arg2, arg1); y = x * (arg1 > 10) ? arg1 : 6; return y * (unsigned int) c; }
Written by Simon Turner (simon at twoplaces.co.uk)
Last updated 16 March 2000