From: mcsun!ub4b!alcbel!btmpj6!devjwu@uunet.uu.net (Wuyts Jan)
Subject: Re: Seek LOC Count Software in Pub Domain
Date: 9 Jul 93 15:14:08 GMT [thread overview]
Message-ID: <2082@alcbel.be> (raw)
Here is a simple awk program that gives you some information about
LOCode and LOComments. It looks for -- in the input and everthing
not behind a -- is considered a LOCode
--------------next is first line--------------
BEGIN { comment_line=0; total_comment=0;
lines_with_comment=0; total_lines_with_comment=0;
blank_comment=0; total_blank_comment=0;
blank_line=0; total_blank=0; old_NR=1;
current_file=FILENAME;
print "File\t\t\t\tComment_lines\tBlank_lines\tCode_lines\tTot
al\n";
}
FILENAME != current_file {
printf("%-26.26s\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", current_fi
le, comment_line, blank_comment, blank_line, NR+1-old_NR-comment_line-blank_lin
e,lines_with_comment-comment_line,NR+1-old_NR);
current_file=FILENAME;
total_comment=total_comment+comment_line;
comment_line=0;
total_lines_with_comment=total_lines_with_comment+lines
_with_comment;
lines_with_comment=0;
total_blank=total_blank+blank_line;
blank_line=0;
total_blank_comment=total_blank_comment+blank_comment;
blank_comment=0;
old_NR=NR;
}
/^[ ]*--/ { comment_line++;
}
/[ ]*--/ { lines_with_comment++;
}
/^[ ]*--[ ]*$/ { blank_comment++;
}
/^[ ]*$/ { blank_line++;
}
END {
printf("%-26.26s\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", current_fi
le, comment_line, blank_comment, blank_line, NR+1-old_NR-comment_line-blank_lin
e,lines_with_comment-comment_line,NR+1-old_NR);
total_comment=total_comment+comment_line;
total_lines_with_comment=total_lines_with_comment+lines_with_
comment;
total_blank=total_blank+blank_line;
total_blank_comment=total_blank_comment+blank_comment;
printf("\nGrand total\t\t\t%d\t(%d)\t%d\t\t%d\t(%d)\t%d\n", t
otal_comment, total_blank_comment, total_blank, NR-total_comment-total_blank, t
otal_lines_with_comment-total_comment,NR);
}
--------------previous is last line--------------
Put this in a file, say count.awk
Count the lines with:
awk -f count.awk *.a
It gives per file a line indicating
filename, #comment_lines (#empty comments), #blank_lines, #code_lines (#comment
ed_code_lines). It also gives you a grand total.
Hope this is of any help
Jan Wuyts
next reply other threads:[~1993-07-09 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-07-09 15:14 Wuyts Jan [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-07-09 20:40 Seek LOC Count Software in Pub Domain cis.ohio-state.edu!math.ohio-state.edu!darwin.sura.net!source.asset.com!v
1993-07-09 17:16 Step he Leake
1993-07-07 22:56 Logicon RDA
1993-07-07 15:13 Michael Hann
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox