TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
Date:
Tue, 12 Oct 1999 10:07:19 -0700
Reply-To:
Greg Bek <[log in to unmask]>
Subject:
From:
Greg Bek <[log in to unmask]>
Content-Transfer-Encoding:
7bit
In-Reply-To:
Content-Type:
text/plain; charset="iso-8859-1"
MIME-Version:
1.0
Parts/Attachments:
text/plain (72 lines)
My favourite is this awk script, typically driven from the C-shell
script that follows it:

#!/bin/awk  -f

BEGIN           { cmnt = 0; nblnk = 0; blnk = 0; semi = 0; }

/^[ \t]*--/     { cmnt++; next; }
/^[ \t]*$/      { blnk++; next; }
/;$/            { semi++; next; }
                { nblnk++; next; }

END             {
                  printf("Comment lines:   %5d\n", cmnt);
                  printf("Blank lines:     %5d\n", blnk);
                  printf("Semicolon lines: %5d\n", semi);
                  printf("Other lines:     %5d\n", nblnk);
                  printf("-----------------------\n");
                  printf("Total lines:     %5d\n", cmnt+blnk+semi+nblnk);
                }


#! /bin/csh -f
#
# Command file to count lines in: ada units and or views
#
set sloc_counter = "~/bin/sc"
set usage = "Usage: $0 [-v] <file_list>"
#
# Check for verbosity
#
if ( $1 == -v ) then
  shift
  set verbose
endif
#
# Check number of arguments
#
if ( $#argv < 1 ) then
  echo "$usage"
  exit 1
endif

# Loop for each arg
foreach file ( $* )

  if ( -e $file ) then

#only get here if the 'object' exists

    if ( -f $file && $file =~ *.ada ) then
      echo $file
      $sloc_counter $file
    else
       if ( -d $file ) then
           echo "Totals for directory $file"
#
# Don't iterate over all files, instead give a total
#          find $file -name '*.ada' -print -exec $sloc_counter {} \;
#
           $sloc_counter $file/*.ada
       else
          echo "$file is not an Ada unit or a directory name"
       endif
    endif
  else
    echo "$file doesn't exist"
  endif


end

ATOM RSS1 RSS2