Next Previous Contents

2. How can I trust Beautifier programs??!!

For 100% assurance you need a SCIENTIFIC way to validate and trust a beautifier program. The method described in this section will enable the beautifier program to be accepted as "trust-worthy" and reliable.

In order to verify that beautifier programs like bcpp, indent or cb is not damaging or changing the input source-code after formatting, you can use the shell script verification program or use the following technique -

Generate the object code from the original input source code using the compiler -

  g++ -c myprogram.cpp

Here g++ is GNU C++ compiler. This will create object output myprogram.o

Save this file -

   mv myprogram.o myprogram_orig.o

Now run bcpp -

   bcpp myprogram.cpp

This will create the formatted output program file myprogram.cpp and move the original file to myprogram.cpp.orig. Compile the new file with -
   g++ -c myprogram.cpp

Now use the unix 'diff' command to compare the two object files -

   diff myprogram.o myprogram_orig.o

Both these files MUST BE IDENTICAL. This verifies that bcpp is working perfectly. On DOS or Windows 95 you may want to use the free Cygnus Cygwin 'diff' or 'MKS' utilities.

If for some reason you are not able to diff the object files then you MUST use the assembly output as described below.

You can use the assembler output instead of object output from the C++ compiler for doing the comparison. Like -

    g++ -S myprogram.cpp

This creates myprogram.s. Verify with -
    diff myprogram.s myprogram_orig.s

This step gives 100% guarantee that your valuable source code is intact and bcpp is JUST doing ONLY formatting and is NOT changing or damaging your code in any way. This method gives you 100% quality assurance and life term or long term WARRANTY on beautifier programs like 'bcpp', 'cb' or 'indent'.

It is strongly recommended that you do these two steps every time you run beautifier programs like bcpp, indent or cb.

Next Previous Contents