Do you trust the "indent" program?

Ken Lerman lerman at stpstn.UUCP
Tue Jan 1 02:04:46 AEST 1991


In article <12184 at sybase.sybase.com> forrest at sybase.com writes:
>Let's say your company just decided on a coding standard and let's
>say you were able to come up with a specification file for the
>'indent' program that would allow 'indent' to change all your
>1000's of source files to meet the standard. Do you trust 'indent'
>enough to run it on all your source file without making any mistakes?
>By mistakes I mean changes that actually change your code so that it
>does something different than what it did before you ran it through
>'indent'.
>
>----
>Anything you read here is my opinion and in no way represents Sybase, Inc.
>
>Jon Forrest WB6EDM
>forrest at sybase.com
>{pacbell,sun,{uunet,ucbvax}!mtxinu}!sybase!forrest
>415-596-3422

NO, I would not trust indent.  

Alternative 1:
You could write a program (call it undent) which replaces each
contiguous string of white space with a single blank character.  You
could run it on my code before and after running indent and diff the
results.  If they are the same, you are probably OK.

The one area of concern I'd have left is what is done with comments.
In particular, some CPPs treat the zero length comment /**/ as a
concatenation operator.  Make sure that the undent program does NOT
treat this as white space.  (Or grep your input and output code
looking for this.)

Alternative 2:
The purpose of this standard is to make code easier to maintain.
Before doing any maintenance, the programmer should run regression
tests on the application he is working on.  Then run indent on the
module(s) he will be changing.  Then run the regression tests again.
Now you can start modifying code.  If some module is never worked on,
there is no need to "indent" it.

What, you don't have regression tests?  Then your problem is far worse
than the lack of a standard coding format.

Ken



More information about the Comp.lang.c mailing list