TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

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

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

Print Reply
Subject:
From:
"W. Wesley Groleau x4923" <[log in to unmask]>
Reply To:
W. Wesley Groleau x4923
Date:
Tue, 1 Jun 1999 13:07:57 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
> 2. Use context diff to collect detailed change counts:
>       diff -cbw file.old file.new > 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
"change":

    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);
vs.
    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.

ATOM RSS1 RSS2