summaryrefslogtreecommitdiff
path: root/bin/count_lines
diff options
context:
space:
mode:
authorgthaker <gthaker@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-01-26 21:09:29 +0000
committergthaker <gthaker@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-01-26 21:09:29 +0000
commitfc3c90a9e9c4e34e01ae4100491cd15c79fd8480 (patch)
tree530b6384d6f3cb6c9efa6351a8659ce90de3a9bd /bin/count_lines
parent33e5d5f576cb7b64b7c9945e71fca21df5106c1e (diff)
downloadATCD-fc3c90a9e9c4e34e01ae4100491cd15c79fd8480.tar.gz
ChangeLogTag:Mon Jan 26 15:18:06 2004 Gautam Thaker <gthaker@atl.lmco.com>
Diffstat (limited to 'bin/count_lines')
-rwxr-xr-xbin/count_lines254
1 files changed, 128 insertions, 126 deletions
diff --git a/bin/count_lines b/bin/count_lines
index e2ba66d945f..9fd72453b08 100755
--- a/bin/count_lines
+++ b/bin/count_lines
@@ -21,8 +21,8 @@ if ($#ARGV < 0) {
foreach $module (@ARGV) {
if ( ! -d $module ) {
- warn "$cmd: no such directory $module\n";
- next;
+ warn "$cmd: no such directory $module\n";
+ next;
}
open(DIRS, "find $module -type d|");
@@ -31,20 +31,20 @@ foreach $module (@ARGV) {
open(FIND, "find $module -type f|");
@files = grep {if (!/build/
- && !/CVS/
- && !/rpc\+\+/
- && !/\.bpr$/
- && !/\.mdp$/
- && !/\.MDP$/
- && !/\.dsp$/
- && !/\.DSP$/
- && !/\.dsw$/
- && !/\.DSW$/
- && !/\.mak$/
- && !/\.MAK$/
- && !/\.o$/
- && !/\.sl$/
- && !/\.a$/) {chop;}} <FIND>;
+ && !/CVS/
+ && !/rpc\+\+/
+ && !/\.bpr$/
+ && !/\.mdp$/
+ && !/\.MDP$/
+ && !/\.dsp$/
+ && !/\.DSP$/
+ && !/\.dsw$/
+ && !/\.DSW$/
+ && !/\.mak$/
+ && !/\.MAK$/
+ && !/\.o$/
+ && !/\.sl$/
+ && !/\.a$/) {chop;}} <FIND>;
close(FIND);
$totdirs = $#dirs;
@@ -53,39 +53,39 @@ foreach $module (@ARGV) {
%lines = ();
foreach $file (@files) {
- $n = 0;
- if (!open(IN, $file)) {
- warn "$cmd: cannot open '$file' for reading\n";
- next;
- }
- while(<IN>) {
- $n++;
- }
- close(IN);
- $lines{$file} = $n;
- $totlines += $n;
+ $n = 0;
+ if (!open(IN, $file)) {
+ warn "$cmd: cannot open '$file' for reading\n";
+ next;
+ }
+ while(<IN>) {
+ $n++;
+ }
+ close(IN);
+ $lines{$file} = $n;
+ $totlines += $n;
}
-
+
# Define two associative arrays to keep the results for each kind
- # of file.
+ # of file.
%linespertype = ();
%filespertype = ();
foreach $type (keys %typeRE) {
- $linespertype{$type} = 0;
- $filespertype{$type} = 0;
+ $linespertype{$type} = 0;
+ $filespertype{$type} = 0;
}
# The file is classified and added to the corresponding variable.
FILE: while (($file, $l) = each %lines) {
- foreach $type (@match_order) {
- $re = $typeRE{$type};
- if($file =~ m/$re/) {
- $linespertype{$type} += $l;
- $filespertype{$type}++;
- next FILE;
- }
- }
- print STDERR "Unmatched file: $file\n";
+ foreach $type (@match_order) {
+ $re = $typeRE{$type};
+ if($file =~ m/$re/) {
+ $linespertype{$type} += $l;
+ $filespertype{$type}++;
+ next FILE;
+ }
+ }
+ print STDERR "Unmatched file: $file\n";
}
format STDOUT_TOP=
@@ -110,13 +110,13 @@ File type lines files
$type, $typelines, $typefiles
.
-
+
foreach $type (@match_order) {
- $typelines = $linespertype{$type};
- $typefiles = $filespertype{$type};
- if ($typefiles != 0) {
- write;
- }
+ $typelines = $linespertype{$type};
+ $typefiles = $filespertype{$type};
+ if ($typefiles != 0) {
+ write;
+ }
}
# Forzamos un newpage para cada modulo.
$- = 0;
@@ -125,13 +125,13 @@ $type, $typelines, $typefiles
sub updateRE {
local $desc = shift;
local $re = shift;
-
+
if (exists $typeRE{$desc}) {
- local $mix = $typeRE{$desc} . '|(' . $re . ')';
- $typeRE{$desc} = $mix;
+ local $mix = $typeRE{$desc} . '|(' . $re . ')';
+ $typeRE{$desc} = $mix;
} else {
- $typeRE{$desc} = '(' . $re . ')';
- push @match_order, $desc;
+ $typeRE{$desc} = '(' . $re . ')';
+ push @match_order, $desc;
}
}
@@ -141,94 +141,96 @@ sub initfiletypes {
# twice, but it could be unproperly classified.
local %filenames =
- ('Makefile' => 'Makefile',
- 'Makefile.*' => 'Makefile',
- 'README' => 'README files',
- 'COPYING' => 'Licenses',
- 'LICENSE.*' => 'Licenses',
- 'ChangeLog.*' => 'ChangeLog',
- 'ChangeLog-.*' => 'ChangeLog',
- '.cvsignore' => 'Control CVS',
- 'run_test.pl' => 'Test driver',
- 'run_test' => 'Test driver',
- 'run_tests' => 'Test driver',
- 'run_test.sh' => 'Test driver');
+ ('Makefile' => 'Makefile',
+ 'Makefile.*' => 'Makefile',
+ 'README' => 'README files',
+ 'COPYING' => 'Licenses',
+ 'LICENSE.*' => 'Licenses',
+ 'ChangeLog.*' => 'ChangeLog',
+ 'ChangeLog-.*' => 'ChangeLog',
+ '.cvsignore' => 'Control CVS',
+ 'run_test.pl' => 'Test driver',
+ 'run_test' => 'Test driver',
+ 'run_tests' => 'Test driver',
+ 'run_test.sh' => 'Test driver');
local %fileexts =
- ('cc' => 'C++ sources',
- 'cpp' => 'C++ sources',
- 'inl' => 'C++ sources',
- 'i' => 'C++ sources',
- 'h' => 'Headers',
- 'hh' => 'Headers',
- 'c' => 'C/C++ sources',
- 'idl' => 'IDL sources',
- 'IDL' => 'IDL sources',
- 'pidl' => 'IDL sources',
- 'y' => 'yacc source',
- 'yy' => 'yacc source',
- 'l' => 'lex source',
- 'll' => 'lex source',
- 'pm' => 'perl script',
- 'pl' => 'perl script',
- 'perl' => 'perl script',
- 'GNU' => 'GNU make config',
- 'tex' => '(La)TeX',
- 'txt' => 'Text files',
- '1' => 'man pages',
- '3' => 'man pages',
- 'html' => 'HTML',
- 'bib' => 'BibTeX',
- 'sty' => 'TeX styles',
- 'bld' => 'VxWorks build file',
- 'am' => 'Automake file',
- 'icc' => 'VisualAge project files',
- 'icp' => 'VisualAge project files',
- 'vac' => 'VisualAge project files',
- 'vcp' => 'Microsof eMbedded Visual Tools project files',
- 'vcw' => 'Microsof eMbedded Visual Tools project files',
- 'bpr' => 'Borland project files',
- 'bor' => 'Borland project files',
- 'dsp' => 'DevStudio project files',
- 'DSP' => 'DevStudio project files',
- 'mdp' => 'MSVC project files',
- 'MDP' => 'MSVC project files',
- 'dsw' => 'MSVC workspaces',
- 'DSW' => 'MSVC workspaces',
- 'mak' => 'MSVC MAK files',
- 'MAK' => 'MSVC MAK files',
- 'java' => 'JAVA source',
- 'class' => 'JAVA class',
- 'cccc' => 'codecount output',
- 'gif' => 'GIF images',
- 'conf' => 'Svc_Config files',
- 'diff' => 'patches',
- 'zip' => 'Compressed files',
- 'gz' => 'Compressed files',
- 'EXE' => 'Win32 executable',
- 'shar' => 'Shar archive',
- 'mib' => 'MIB definition files',
- 'gperf' => 'GPERF input',
- 'phil.*'=> 'Test driver'
- );
+ ('cc' => 'C++ sources',
+ 'cpp' => 'C++ sources',
+ 'inl' => 'C++ sources',
+ 'i' => 'C++ sources',
+ 'h' => 'Headers',
+ 'hh' => 'Headers',
+ 'c' => 'C/C++ sources',
+ 'idl' => 'IDL sources',
+ 'IDL' => 'IDL sources',
+ 'pidl' => 'IDL sources',
+ 'y' => 'yacc source',
+ 'yy' => 'yacc source',
+ 'l' => 'lex source',
+ 'll' => 'lex source',
+ 'php' => 'php script',
+ 'pm' => 'perl script',
+ 'pl' => 'perl script',
+ 'perl' => 'perl script',
+ 'py' => 'python script',
+ 'GNU' => 'GNU make config',
+ 'tex' => '(La)TeX',
+ 'txt' => 'Text files',
+ '1' => 'man pages',
+ '3' => 'man pages',
+ 'html' => 'HTML',
+ 'bib' => 'BibTeX',
+ 'sty' => 'TeX styles',
+ 'bld' => 'VxWorks build file',
+ 'am' => 'Automake file',
+ 'icc' => 'VisualAge project files',
+ 'icp' => 'VisualAge project files',
+ 'vac' => 'VisualAge project files',
+ 'vcp' => 'Microsof eMbedded Visual Tools project files',
+ 'vcw' => 'Microsof eMbedded Visual Tools project files',
+ 'bpr' => 'Borland project files',
+ 'bor' => 'Borland project files',
+ 'dsp' => 'DevStudio project files',
+ 'DSP' => 'DevStudio project files',
+ 'mdp' => 'MSVC project files',
+ 'MDP' => 'MSVC project files',
+ 'dsw' => 'MSVC workspaces',
+ 'DSW' => 'MSVC workspaces',
+ 'mak' => 'MSVC MAK files',
+ 'MAK' => 'MSVC MAK files',
+ 'java' => 'JAVA source',
+ 'class' => 'JAVA class',
+ 'cccc' => 'codecount output',
+ 'gif' => 'GIF images',
+ 'conf' => 'Svc_Config files',
+ 'diff' => 'patches',
+ 'zip' => 'Compressed files',
+ 'gz' => 'Compressed files',
+ 'EXE' => 'Win32 executable',
+ 'shar' => 'Shar archive',
+ 'mib' => 'MIB definition files',
+ 'gperf' => 'GPERF input',
+ 'phil.*'=> 'Test driver'
+ );
local %paths = ();
local ($desc, $reseed);
while (($reseed, $desc) = each %filenames) {
- local $re = '/' . $reseed . '$';
- updateRE($desc, $re);
+ local $re = '/' . $reseed . '$';
+ updateRE($desc, $re);
}
while (($reseed, $desc) = each %fileexts) {
- local $re = '/[^/]*\.' . $reseed . '$';
- updateRE($desc, $re);
+ local $re = '/[^/]*\.' . $reseed . '$';
+ updateRE($desc, $re);
}
while (($reseed, $desc) = each %paths) {
- local $re = $reseed;
- updateRE($desc, $re);
+ local $re = $reseed;
+ updateRE($desc, $re);
}
updateRE('Others', '.*');
# while (($desc, $reseed) = each %typeRE) {
-# print STDERR $desc, " ==> ", $reseed, "\n";
+# print STDERR $desc, " ==> ", $reseed, "\n";
# }
}