sclc -- Source-code line counter
sclc [-counts SPEC] [-sections SPEC] [-language [EXT=]LANG] [-delim-ignore] [-ignore] [-diff] [-vcstring STRING] [-name REGEXP] [-except REGEXP] [-recurse] [-filelist] [-fromversion SELECTOR] [-toversion SELECTOR] [-pred] [-prefix REGEXP] [-separate REGEXP] [-output FILE] [FILE ...]
Print this help message and exit.
Print version information and exit
Assume that any file with a suffix of ``EXT'' is a LANG
source file (note that you must supply any leading '.'). If the ``EXT'' begins with a slash ('/'), then the name that follows it is considered
to be the name of an interpreter that is invoked using ``#!path/EXT`` as the first line of the script (and if the language can't be determined
from the extension, then the first line of the file will be used). If ''EXT=`` is omitted then LANG
will be the default language for any files whose language cannot be
determined. LANG
must be one of the following:
Ada, Assembly, Awk, C, C++, Eiffel, Java, Lisp, Pascal, Perl, Tcl, shell, make
Language names may not be abbreviated. This option may be specified multiple times.
Ignore all statement delimiters. This means that lines containing nothing but statement delimiters/terminators are *not* considered lines of code. For C/C++ this would have the effect of ignoring lines containing nothing but ';', '{', and '}'.
Treat the input as output from diff(1) and report counts for both inserted and deleted source. Note that the -diff option is implied by any of -pred, -fromversion or -toversion. If the -diff option is explicitly specified and none of these other three options are, then the input is assumed to already be in 'diff' format (that means regular diff format or context-diff only; ed-script format and uni-diff output will not be understood!)
Don't bother with files whose language can't be determined.
Assume that the source files to read are listed in the contents of the files given on the command line (filelist is read from standard input if no files are given). This is useful if you wish to use the output of commands Like find(1) as input to this command.
Only look at files whose filename (not including the directory path)
completely match the given perl-style regular expression. Does not apply to
directories when -recurse is used. May be specified multiple times (for a description of Perl's
regular expression syntax, invoke man perlre
or perldoc perlre
).
Don't look at files whose filename (not including the directory path)
completely match the given perl-style regular expression (even if it would
be matched by a -name expression). Does not apply to directories when -recurse is used. May be specified multiple times (for a description of Perl's
regular expression syntax, invoke man perlre
or perldoc perlre
).
Ignore/strip the leading portion of each line that matches the given
perl-style regular expression. Do not use a leading '^' unless you mean to match the caret character itself (for
a description of Perl's regular expression syntax, invoke man perlre
or perldoc perlre
)
For every ``source'' file that is actually a directory, read all source files in the directory.
When used with -diff, assumes that SELECTOR is a valid ClearCase version selector and uses it in conjunction with cdiff as the ``from'' version of each file specified. Only one of -fromversion
and -pred
may be specified!
When used with -diff, assumes that SELECTOR is a valid ClearCase version selector and uses it in conjunction with cdiff as the ``to'' version of each file specified.
When used with -diff, assumes that each file is an element in a ClearCase VOB and uses it in conjunction with cdiff as the ``from'' version of each file specified (note that the predecessor version is chosen relative to the ``to'' version of the file). Only one of -pred and -fromversion may be specified!
Assume that whenever a source line is encountered that completely matches
the given perl-style regular expression, it indicates the end of the
current source context. Useful if you are trying to count lines from the
output of a command like diff(1) and you dont want a comment or quote in one changed section to be treated
as if it continued into the next block of modifications. May be specified
multiple times (for a description of Perl's regular expression syntax,
invoke man perlre
or perldoc perlre
).
Specify which counts/columns to display in the output. SPEC may contain any of the following (separated by '+'):
"Lines" : print the total # of lines "Blank" : print the total # of blank-lines "Cmnts" : print the total # of comments "NCSL" : print the total # of non-comment source lines "AESL" : print the total # of assembly-equivalent source lines
The above keywords may be abbreviated to a unique prefix if desired. If the -counts option is not specified, then
Lines+Blank+Cmnts+NCSL+AESL
is implied.
Specify the sections in the output. SPEC may contain any of the following (separated by '+'):
"Header" : the column labels and separator bar "Files" : the counts for each input file "LangTotals" : the totals for each language encountered. "Totals" : the totals for all files.
The above keywords may be abbreviated to a unique prefix if desired. If the -sections option is NOT specified, then Header+Files+LangTotals+Totals
is implied.
Specify that STRING is the delimiter used by your version control system and that the file suffix should be determined by only considering the portion of the file path that precedes the first occurrence of STRING.
Redirect output to the named file (should have the same effect as redirecting STDOUT on the cmdline using ``> FILE'').
Name of an input file.
Option names are case insensitive and only a unique prefix is required.
sclc will count the number of lines, blank-lines, comments, non-comment source lines (NCSL), and assembly equivalent source lines (AESL) in the given input files (which are assumed to be free of syntax errors). The output format will look something like the following:
<header with column titles and separator line> <count1> <count2> ... <filename> (<language>) ... ... ... ... <total1> <total2> ... ----- <language> ----- (# files) ... ... ... ... <total1> <total2> ... ***** TOTAL ***** (# files)
If the -diff option is given than two lines are printed for each set of counts: one for
deleted lines and one for inserted lines (and the DELETED
or INSERTED
keyword will appear on each output-line). If -pred or
-fromversion or -toversion is given then -diff is implied and cdiff
command is invoked with the -blank_ignore option to compare file versions.
The -counts and -sections options may be used to control which counts and/or sections to print. The counts are always printed in an order such that:
lines --> blank-lines --> comments --> NCSL --> AESL
where ``X --> Y'' means that the count of Xs always precedes the count of Ys.
The typical use for sclc would be to just give it the filenames on the command line:
$ sclc dir.c dir.h Lines Blank Cmnts NCSL AESL ===== ===== ===== ===== ========== ============================= 215 26 14 158 395.0 dir.c (C) 41 8 16 24 60.0 dir.h (C) 256 34 30 182 455.0 ----- C ----- (2 files)
There are options to control which columns you do/dont want to see. The NCSL
column is for ``non-comment source lines''. The AESL
column is for ``assembly equivalent source lines'' (it calculates this
using assembly-equivalence factors published by Software Productivity
Research). If all you care about is NCSL, you could simply invoke it as:
$ sclc -counts ncsl dir.[ch] NCSL ===== ============================================================== 158 dir.c (C) 24 dir.h (C) 182 ----- C ----- (2 files)
If you dont want the header columns, and want to see the overall totals instead of the totals per programming language (sclc can handle C, C++, Java, Perl, Assembly, Pascal, and several other languages) then you could simply say:
$ sclc -counts ncsl -sections file+totals *.[ch]
158 dir.c (C) 24 dir.h (C) 182 ***** TOTAL ***** (2 files)
If you want to know the number of lines of code that have changed between versions of files, you can use the -pred option, or a combination of the -fromversion and -toversion options. If you simply want to know the number of new and changed lines of code between a set of files and their immediate predecessors, use the -pred option:
$ sclc -pred *.[ch]
Lines Blank Cmnts NCSL AESL ===== ===== ===== ===== ========== =============================== 3 1 0 2 5.0 dir.c DELETED (C) 5 1 0 4 10.0 dir.c INSERTED (C) 1 0 0 1 2.5 dir.h DELETED (C) 2 0 0 2 5.0 dir.h INSERTED (C) 4 1 0 3 7.5 ----- C DELETED ----- (2 files) 7 1 0 6 15.0 ----- C INSERTED ----- (2 files)
Again, if you want to limit the output to include only the NCSL counts for the individual files and their totals, add the -counts and -sections options into the fold:
$ sclc -pred -counts ncsl -sections file+totals *.[ch]
2 dir.c DELETED (C) 4 dir.c INSERTED (C) 1 dir.h DELETED (C) 2 dir.h INSERTED (C) 3 ***** TOTAL DELETED ***** (2 files) 6 ***** TOTAL INSERTED ***** (2 files)
If you want to count the difference in source lines between specific versions (not just the predecessor) you may use the -fromversion option to specify the base (``from'') version to use for all comparisons. If the base version is not explicitly specified, it defaults to whatever version is selected in the users view. Similarly, the -toversion option may be used to specify the target (``to'') version to use for all comparisons. If the target version is not specified, then (like the base version) it defaults to whatever version is selected in the users view.
So if I want to count the changed lines of code between what is in my view
and what was on the REL1.0.0
label, I would do the following:
$ sclc -fromver REL1.0.0 *.[ch]
And if I wanted to count the changed lines of code between files on my /main/rel1/mychanges
branch and the REL1.0.0 baseline label they where branched off from, I
would use:
$ sclc -fromver REL1.0.0 -tover .../mychanges/LATEST *.[ch]
If I wanted to see the difference in lines of code for files on to different labels I would do something like:
$ sclc -fromver REL1.0.0 -tover REL2.0.0 *.[ch]
If I wanted to do the same as the above, but my view was already selecting everything in the REL1.0.0 baseline, then I could simply do:
$ sclc -tover REL2.0.0 *.[ch]
Hopefully, this ``tutorial'' should have provided you with a good set of cookbook examples for using sclc. if you ever want to see this manual page, you need only invoke sclc using the -help option:
$ sclc -help
cdiff -- sclc uses cdiff to compare versions of files.
Brad Appleton <brad@bradapp.net