|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Jul 1999
Città: Torino
Messaggi: 2221
|
LOC counter
Avete mica qualche script o programmino per il conteggio delle LOC?? Ve ne sarei molto grato...
|
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Che sono le LOC ?
|
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 5707
|
LOCuste?
![]() ![]() Se sono LinesOfCode non e' difficile, a parte se vuoi scriverti a mano il parsing.. |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Jul 1999
Città: Torino
Messaggi: 2221
|
Line of codes.... non poso scrivere un programma java, stavo provando uno script in PERL...funziona, ma devo riuscire a togliere alcune directory....Ne capite??...
Codice:
#!/usr/bin/perl # Author: Tom Mutdosch # This program counts the number of lines of code, excluding # comment characters and whitespace. # Usage: # LOC [-c commentchar] filename # The default comment character is "//" $commentChar = "\/\/"; # the default comment is // $total = 0; # the total count of all files LOC #$ARGV[0] || die "Usage: LOC [-c commentcharacter] filename\n"; # get filename from each argurment on command line #foreach $subdir (`find . -type d | awk '{if(match($1,/^\.\/test$$|^\.\/bilancio|\.$$|^\.\/java|^\.\/workflow|old$$|bak$$|test$$/) == 0) print;}'`) { foreach $file (`find . -name '*.java'`) { #foreach $file (@ARGV) { #foreach $file (`ls | awk '/.java$$/'`) { print ( "working...$file\n" ); $flag = 0; #this flag is set if there is a command line comment if ( $nextComment ) { #change default comment to command line comment $commentChar = $file; $flag = 1; $nextComment = 0; } if ( $file eq "-c" ) { #a comment is given on command line... $nextComment = 1; $flag = 1; } if ( $flag == 0 ) { open ( FILE, "<$file" ) || die "Errore!\n\n"; #$line = ; $count = 0; while ( $line = <FILE>) { chop ($line) ; $line =~ s/\s//g; #remove all whitespace if ( $line =~ /^\/\*/ ) { #if comment is /*, stop counting... $state = 1; } if ( $line =~ /^\*\// || $line =~ /\*\/$/ ) { #resume counting #print ( "resume counting..." ); $state = 0; $count--; } #if it's not a comment or a blank line, count this as a LOC if ( $line eq "" || $line =~ /^$commentChar/ || $state == 1 ) { } else { #print ( "$line\n" ); $count = $count + 1; } } print ( "....Total lines of code: $count \n") ; $total += $count; } } print( "-----------------------------\n" ); print ("Total LOC : $total\n" ); |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
andrebbe bene uno scriptino del genere?
# $ENV{HOME} = tua home open(FP, "$ENV{HOME}/perl/sample.dat"); while(<FP> ![]() print "Number of lines -> $.\n"; # That's it. # $. -> the current input line number of the last #filehandle that was read. Reset only when #the filehandle is closed explicitly.
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo |
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: Jul 2002
Messaggi: 4334
|
Scusate, ma non basterebbe un semplice:
grep -rwvc \/\/ *.c ? Magari lavorandoci un po', inserendo una regexp, adesso non ho tempo per provare... ![]() Poi dipende da che devi fare, non so neanche se funziona ![]() |
![]() |
![]() |
![]() |
#7 | |
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
Quote:
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo |
|
![]() |
![]() |
![]() |
#8 |
Senior Member
Iscritto dal: Jul 1999
Città: Torino
Messaggi: 2221
|
Quello ch ho scritto funziona...il problema era eliminare le righe coi commenti
![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 04:23.