C_COUNT

Section: User Commands (1)
Index Return to Main Contents
 

NAME

c_count - C-language line counter  

USAGE

c_count [options] [file-specifications]  

SYNOPSIS

C_count counts lines and statements in C-language source files. It provides related statistics on the amount of whitespace, comments and code. C_count also shows the presence of unbalanced (or nested) comments, unbalanced quotation marks and illegal characters.  

DESCRIPTION

C_count reads one or more C-language source files and displays simple statistics about them. It counts statements (i.e., sequences of tokens terminated with semicolon) and measures the relative amount of commentary. C_count ignores semicolons where they appear in comments or in quoted literals.

A count of semicolons is a reasonable way of counting C statements. Note, however, that it does not count preprocessor definitions as C statements.

The statistics summary shows you the relative amount of commentary. This is the ratio of the alphanumeric characters in comments to the total of characters in the code (ignoring tabs and other whitespace which are not inside quotes). C_count only counts alphanumeric characters, thus ignoring punctuation used as fillers. It also suppresses RCS and DEC/CMS history comments from this ratio.

C_count counts the number of tokens (names and constants) in the source files and gives this total, as well as their average length.

C_count provides you not only with measurements, but also diagnostics in the form of a set of flags shown next to each file name:

" file contains an unbalanced quote (").
?
file contains illegal characters (e.g., nonprinting, nonwhitespace characters such as an escape). C_count also flags tabs inside quotes.
*
file contains unterminated or nested comments.

Unbalanced quotes may be legal. The C preprocessor permits you to define symbols which contain an unbalanced quote mark, for example:


#define WARN    (void)printf("** warning:
        ...
        WARN item 

Rather than duplicate all of the complexity of the C preprocessor, c_count permits you to specify symbols which contain unbalanced quote marks.  

OPTIONS

Command line options of c_count are:
-c
display character-level statistics.
-d
show each token as c_count parses it from the input stream.
-i
display identifier-level statistics.
-j
annotate summary in technical format (i.e., "physical source statements" and "logical source statements" for "lines" and "statements" respectively).
-l
display line-level statistics.
-o file
write the report to the specifed file, rather than to the standard output.
-p
display statistics on a per-file basis.
-q define
define tokens which may evaluate with an unbalanced quote mark '"'. For example,

-q WARN

tells c_count that the token "WARN" contains a quote mark.

-s
display specialized statistics (e.g., code:comment ratio).
-t
generate output in spreadsheet format (e.g., comma-separated columns). If you set any of the options "-c", "-i", "-l" or "-s", c_count generates these statistics. Otherwise it generates only the lines/statements.
-v
direct c_count not only to print a summary line for each file, but also to print a running summary showing each source line, together with the current line and statement numbers, as well as the cumulative flags.
 

OPERATIONS

C_count reads one or more C language source files and writes its statistics to standard output. If you do not give any file names, c_count reads a list of file names from standard input.

The special filename "-" directs c_count to read the file itself from the standard input.

Following is an example of the use of c_count, showing the detailed types of information which it reports.


bsd(5) c_count */*.[ch]
   927   352   |src/c_count.c
     5     0?" |test/test1.c
     6     2?  |test/test2.c
    20     1   |test/test3.c
----------------
   958   355?"  total lines/statements

   121  lines had comments        12.6 %
    48  lines had history          5.0 %
    36  comments are inline       -3.8 %
    73  lines were blank           7.6 %
    22  lines for preprocessor     2.3 %
   730  lines containing code     76.2 %
   958  total lines              100.0 %

  3475  comment-chars             15.7 %
  1021  history-chars              4.6 %
  1003  nontext-comment-chars      4.5 %
  4731  whitespace-chars          21.3 %
   322  preprocessor-chars         1.5 %
 11644  statement-chars           52.5 %
 22196  total characters         100.0 %

  1541  tokens, average length 4.91

  0.29  ratio of comment:code
     3  ?:illegal characters found
     2  ":lines with unterminated quotes

If you use the "-p" option, c_count prints the detailed information for each file, as well as for all files together.  

ENVIRONMENT

C_count runs in a portable UNIX® environment. Execute it on VAX/VMS by defining it as a foreign command.  

FILES

C_count is a single binary module, that uses no auxiliary files (e.g., C_COUNT.EXE on VAX/VMS).  

AUTHOR

Thomas Dickey (dickey@clark.net).  

SEE ALSO

wc (1)


 

Index

NAME
USAGE
SYNOPSIS
DESCRIPTION
OPTIONS
OPERATIONS
ENVIRONMENT
FILES
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 15:08:09 GMT, November 05, 2024