Skip to content

Instantly share code, notes, and snippets.

@icco
Created June 1, 2009 06:11
Show Gist options
  • Select an option

  • Save icco/121261 to your computer and use it in GitHub Desktop.

Select an option

Save icco/121261 to your computer and use it in GitHub Desktop.
LOC Counter by Hyperlisk
#!/bin/bash
START=`pwd`;
script=$START"/hyperliskLOC.php";
cd /tmp/;
svn co http://wiki.csc.calpoly.edu/blugoo/svn/trunk/
cd trunk;
for i in $(seq 820 972);
do
svn up -r $i > /dev/null;
echo $i `php $script`;
done;
<?php
// Java source line counter
// By: Nicholas Trevino
// Directory to scan, needs trailing slash.
$dirs[] = "goograde/WEB-INF/classes/goograde/";
$dirs[] = "goograde/TestSrc/goograde/";
$dirs[] = "goograde/WEB-INF/web/";
$dirs[] = "goograde/WEB-INF/web/teacher/";
$dirs[] = "goograde/WEB-INF/web/student/";
$lines = 0;
foreach($dirs as $dir){
$files = glob($dir.'/*.java');
foreach($files as $file){
$code = implode('',file($file));
$code = preg_replace("/(\s*\/\/[^\n]*|\s*\/\*.*?\*\/ *|\n\s*\n+|)+/mis",'',$code);
$lines += count(explode("\n",$code));
}
$files = glob($dir.'/*.jsp');
foreach($files as $file){
$code = implode('',file($file));
$lines += count(explode("\n",$code));
}
$files = glob($dir.'/*.jspf');
foreach($files as $file){
$code = implode('',file($file));
$lines += count(explode("\n",$code));
}
}
echo $lines;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment