summaryrefslogtreecommitdiff
path: root/yhttpd-0.7.0/scripts/stats.pl
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
commit9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (patch)
tree631c295a4a4a16b57502b847626763a279bf6df7 /yhttpd-0.7.0/scripts/stats.pl
parent13aaf70af703748fe096e0664c305cd202637ad2 (diff)
tagging tags
Diffstat (limited to 'yhttpd-0.7.0/scripts/stats.pl')
-rwxr-xr-xyhttpd-0.7.0/scripts/stats.pl97
1 files changed, 97 insertions, 0 deletions
diff --git a/yhttpd-0.7.0/scripts/stats.pl b/yhttpd-0.7.0/scripts/stats.pl
new file mode 100755
index 0000000..fcbcd33
--- /dev/null
+++ b/yhttpd-0.7.0/scripts/stats.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+
+# The yhttpd Project (2003 - 2004)
+#
+# This script generates source code and project statistics
+
+use strict;
+
+use scripts::modules::file;
+
+my %stats;
+
+&recursive(".");
+
+$stats{"Lines total"} = $stats{"Lines of source"}
+ + $stats{"Lines of scripts"}
+ + $stats{"Lines of text"}
+ + $stats{"Lines of HTML"};
+
+my $bool = 0;
+foreach ( sort keys %stats )
+{
+ if ($bool == 0)
+ {
+ print "$_ = " . $stats{$_} . "\n";
+ $bool = 1;
+ }
+ else
+ {
+ print "$_ = " . $stats{$_} . "\n";
+ $bool = 0;
+ }
+}
+
+print "\n";
+
+sub recursive
+{
+ my $shift = shift;
+ my @dir = &dopen($shift);
+
+ foreach (@dir)
+ {
+ next if /^\.$/ or /^\.{2}$/;
+
+ if ( -f "$shift/$_" )
+ {
+ $stats{"Number of files total"}++;
+ &filestats("$shift/$_");
+ }
+ elsif ( -d "$shift/$_" )
+ {
+ $stats{"Number of dirs total"}++;
+ &recursive("$shift/$_");
+ }
+ }
+}
+
+sub filestats
+{
+ my $shift = shift;
+ if ( $shift =~ /\.(cpp|h|tmpl)$/ )
+ {
+ $stats{"Number of source files"}++;
+ $stats{"Lines of source"} += countlines($shift);
+ }
+ elsif ( $shift =~ /\.(html|css)$/ )
+ {
+ $stats{"Number of HTML files"}++;
+ $stats{"Lines of HTML"} += countlines($shift);
+ }
+ elsif ( $shift =~ /\.(gif|png|jpg)$/ )
+ {
+ $stats{"Number of gfx files"}++;
+ }
+ elsif ( $shift =~ /(\.pl|\.sh|configure.*|Makefile.*)$/ )
+ {
+ $stats{"Number of script files"}++;
+ $stats{"Lines of scripts"} += countlines($shift);
+ }
+ elsif ( $shift =~ /(\.txt|README|INSTALL|COPYING|NEWS|SNAPSHOT|ChangeLog)$/ )
+ {
+ $stats{"Number of text files"}++;
+ $stats{"Lines of text"} += countlines($shift);
+ }
+ elsif ( $shift =~ /\.so$/ )
+ {
+ $stats{"Number of compiled module files"}++;
+ }
+}
+
+sub countlines
+{
+ my $shift = shift;
+ my @file = fopen($shift);
+ return $#file;
+}