TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"W. Wesley Groleau x4923" <[log in to unmask]>
Tue, 1 Jun 1999 13:07:57 -0500
text/plain (40 lines)
> 2. Use context diff to collect detailed change counts:
>       diff -cbw file.old > file.diff
>       added = `grep "^+ " file.diff | wc -l`
>       removed = `grep "^- " file.diff | wc -l`
>       modified = `grep "^! " file.diff | wc -l`
> ....
> 4. Finally, you may want to strip comments from your code before
>    generating change metrics.

For stripping comments, you have the irritating task of stripping them
from a copy of the before file.  :-)

-bw  will not catch changes in spacing _within_ literals

GNU diff also offers -B to ignore added or removed blank lines.

But no diff tool that is not "Ada-aware" will know that the following is not a

    type Color_Code is (Black, Brown, Red, Orange, Yellow, Green, Blue,
    Violet, Gray, White, Gold, Silver, None);

    Description : constant String := Comp_Type'Image (Composition) & " "
                                     Value_Image (Color_Array);
    type Color_Code is
         (Black,   Brown,   Red,
          Orange,  Yellow,  Green,
          Blue,    Violet,  Gray,   White,
          Gold,    Silver,  None);

    Description : constant String :=
       Comp_Type'Image (Composition) & " " Value_Image (Color_Array);

You can run before & after through the same "pretty-printer" but that runs
the risk of having neither file having the same line breaks.

If you take the diffs in "statements" instead of "lines," then you could
run a converter that puts each statement on one and only one line.