diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 16:21:22 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 16:21:22 +0000 |
| commit | 371cf3aa2a132401a4557e227577a9f3a57f4477 (patch) | |
| tree | 1ce345520f684fd56ed1445d237e14174f6e6dd7 /scripts | |
| parent | 58885c244c2b9625d0917797dedd3850bf07ae53 (diff) | |
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/astyle.sh | 15 | ||||
| -rw-r--r-- | scripts/modules/file.pm | 28 | ||||
| -rwxr-xr-x | scripts/stats.pl | 95 | ||||
| -rwxr-xr-x | scripts/version.sh | 6 |
4 files changed, 144 insertions, 0 deletions
diff --git a/scripts/astyle.sh b/scripts/astyle.sh new file mode 100755 index 0000000..757364e --- /dev/null +++ b/scripts/astyle.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# The yChat Project (2004, 2005) +# +# This uses "astyle" to format C++ code into a specific code style! + +for f in h cpp tmpl +do + for i in `find . -name "*.$f"` + do + echo $i + astyle --style=ansi -s2 $i + rm -f $i.orig + done +done diff --git a/scripts/modules/file.pm b/scripts/modules/file.pm new file mode 100644 index 0000000..b11e2b3 --- /dev/null +++ b/scripts/modules/file.pm @@ -0,0 +1,28 @@ +sub dopen +{ + my $shift = shift; + opendir DIR, $shift or die "$shift: $!\n"; + my @dir = readdir(DIR); + closedir DIR; + return @dir; +} + +sub fopen +{ + my $shift = shift; + open FILE, $shift or die "$shift: $!\n"; + my @file = <FILE>; + close FILE; + return @file; +} + +sub fwrite +{ + my $shift = shift; + my @file = @_; + open FILE, ">$shift" or die "$shift: $!\n"; + print FILE @file; + close FILE; +} + +1; diff --git a/scripts/stats.pl b/scripts/stats.pl new file mode 100755 index 0000000..0eea04d --- /dev/null +++ b/scripts/stats.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# The yChat Project (2003 - 2005) +# +# This script generates source code and project statistics + +use strict; + +use scripts::modules::file; + +my %stats; +my $param = shift; + +&recursive("."); + +$stats{"Lines total"} = $stats{"Lines of source"} + + $stats{"Lines of scripts"} + + $stats{"Lines of text"} + + $stats{"Lines of HTML"}; + +unless (defined $param) { + + print "$_ = " . $stats{$_} . "\n" + for ( sort keys %stats ); + +} else { + + print $stats{$_} . " " + for sort keys %stats; + +} + +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|\.pm|\.sh|configure.*|Makefile.*)$/ ) + { + $stats{"Number of script files"}++; + $stats{"Lines of scripts"} += countlines($shift); + } + elsif ( $shift =~ /(\.txt|[A-Z]+)$/ ) + { + $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; +} diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..be1b351 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# The yChat Project (2005) +# +# This script shows yChat VERSION-BRANCH + +sed -n 's/.*VERSION.*: \(.*\)".*/\1/p' src/msgs.h |
