Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counter of C/C++ code

0 views
Skip to first unread message

Alex Vinokur

unread,
Dec 30, 2003, 11:38:08 PM12/30/03
to
Counter of C/C++ code can be downloaded at :
http://alexvn.freeservers.com/s1/download.html#label1_cncc


1. Description.

NAME
cncc - count C/C++ source lines and bytes

SYNOPSIS
cncc [OPTIONS]... [FILE]...

DESCRIPTION
Count code-lines, empty-lines, comment-lines,
code-fields, empty-fields, comment-fields of C/C++-sources
which have been successfully compiled.

The program accepts the following options.

`-a'
Print code-line, empty-line and comment-line counts for each FILE.
This option is DEFAULT.

`-b'
Print line-type for each LINE of each FILE.

`-c'
Print
* line-type
and
* code-field, empty-field and comment-field counts
for each line of each FILE.
### Note. This option is incompatible with option `-d'.

`-d'
Print field-type for each field of each line of each FILE.
### Note. This option is incompatible with option `-c'.

`-h'
Display this help and exit.

`-v'
Print the version number and exit.

2. Report samples.

========================
### File : hello.cpp ###
========================

------------------------------------
Files purified from comments created
* hello.ii2
* hello.ii3
------------------------------------

--- Summary Report ---
==================================
| : Lines : Bytes |
|--------------------------------|
| Code Only : 6 : 81 |
| Code+Comment : 1 : - |
| Comment Only : 1 : 46 |
| Empty : 1 : 17 |
|................................|
| * Total : 9 : 144 |
==================================

--- Detailed Report (Line Info-1) ---
===============================
| Line# : Content |
|-----------------------------|
| Line# 1 : Code Only |
| Line# 2 : Code Only |
| Line# 3 : Empty |
| Line# 4 : Code+Comment |
| Line# 5 : Code Only |
| Line# 6 : Comment Only |
| Line# 7 : Code Only |
| Line# 8 : Code Only |
| Line# 9 : Code Only |
===============================


--- Detailed Report (Line Info-2) ---
=============================================================
| Line# : Content : Code : Comment : Blank |
| : : Bytes : Bytes : Bytes |
|-----------------------------------------------------------|
| Line# 1 : Code Only : 18 : 0 : 1 |
| Line# 2 : Code Only : 18 : 0 : 2 |
| Line# 3 : Empty : 0 : 0 : 0 |
| Line# 4 : Code+Comment : 9 : 24 : 3 |
| Line# 5 : Code Only : 1 : 0 : 0 |
| Line# 6 : Comment Only : 0 : 22 : 2 |
| Line# 7 : Code Only : 26 : 0 : 6 |
| Line# 8 : Code Only : 8 : 0 : 3 |
| Line# 9 : Code Only : 1 : 0 : 0 |
=============================================================

--- Detailed Report (Line & Byte Info) ---
==========================================
| Line# : Content |
|----------------------------------------|
| Line# 1 : Code Only |
| * Byte[ 1][ 1] : code |
| * Byte[ 1][ 2] : code |
| * Byte[ 1][ 3] : code |
| * Byte[ 1][ 4] : code |
| * Byte[ 1][ 5] : code |
| * Byte[ 1][ 6] : code |
| * Byte[ 1][ 7] : code |
| * Byte[ 1][ 8] : code |
| * Byte[ 1][ 9] : blank |
| * Byte[ 1][ 10] : code |
| * Byte[ 1][ 11] : code |
| * Byte[ 1][ 12] : code |
| * Byte[ 1][ 13] : code |
| * Byte[ 1][ 14] : code |
| * Byte[ 1][ 15] : code |
| * Byte[ 1][ 16] : code |
| * Byte[ 1][ 17] : code |
| * Byte[ 1][ 18] : code |
| * Byte[ 1][ 19] : code |
| : |
| Line# 2 : Code Only |
| * Byte[ 2][ 1] : code |
| * Byte[ 2][ 2] : code |
| * Byte[ 2][ 3] : code |
| * Byte[ 2][ 4] : code |
| * Byte[ 2][ 5] : code |
| * Byte[ 2][ 6] : blank |
| * Byte[ 2][ 7] : code |
| * Byte[ 2][ 8] : code |
| * Byte[ 2][ 9] : code |
| * Byte[ 2][ 10] : code |
| * Byte[ 2][ 11] : code |
| * Byte[ 2][ 12] : code |
| * Byte[ 2][ 13] : code |
| * Byte[ 2][ 14] : code |
| * Byte[ 2][ 15] : code |
| * Byte[ 2][ 16] : blank |
| * Byte[ 2][ 17] : code |
| * Byte[ 2][ 18] : code |
| * Byte[ 2][ 19] : code |
| * Byte[ 2][ 20] : code |
| : |
| Line# 3 : Empty |
| : |
| Line# 4 : Code+Comment |
| * Byte[ 4][ 1] : code |
| * Byte[ 4][ 2] : code |
| * Byte[ 4][ 3] : code |
| * Byte[ 4][ 4] : blank |
| * Byte[ 4][ 5] : code |
| * Byte[ 4][ 6] : code |
| * Byte[ 4][ 7] : code |
| * Byte[ 4][ 8] : code |
| * Byte[ 4][ 9] : code |
| * Byte[ 4][ 10] : code |
| * Byte[ 4][ 11] : blank |
| * Byte[ 4][ 12] : blank |
| * Byte[ 4][ 13] : comment |
| * Byte[ 4][ 14] : comment |
| * Byte[ 4][ 15] : comment |
| * Byte[ 4][ 16] : comment |
| * Byte[ 4][ 17] : comment |
| * Byte[ 4][ 18] : comment |
| * Byte[ 4][ 19] : comment |
| * Byte[ 4][ 20] : comment |
| * Byte[ 4][ 21] : comment |
| * Byte[ 4][ 22] : comment |
| * Byte[ 4][ 23] : comment |
| * Byte[ 4][ 24] : comment |
| * Byte[ 4][ 25] : comment |
| * Byte[ 4][ 26] : comment |
| * Byte[ 4][ 27] : comment |
| * Byte[ 4][ 28] : comment |
| * Byte[ 4][ 29] : comment |
| * Byte[ 4][ 30] : comment |
| * Byte[ 4][ 31] : comment |
| * Byte[ 4][ 32] : comment |
| * Byte[ 4][ 33] : comment |
| * Byte[ 4][ 34] : comment |
| * Byte[ 4][ 35] : comment |
| * Byte[ 4][ 36] : comment |
| : |
| Line# 5 : Code Only |
| * Byte[ 5][ 1] : code |
| : |
| Line# 6 : Comment Only |
| * Byte[ 6][ 1] : blank |
| * Byte[ 6][ 2] : blank |
| * Byte[ 6][ 3] : comment |
| * Byte[ 6][ 4] : comment |
| * Byte[ 6][ 5] : comment |
| * Byte[ 6][ 6] : comment |
| * Byte[ 6][ 7] : comment |
| * Byte[ 6][ 8] : comment |
| * Byte[ 6][ 9] : comment |
| * Byte[ 6][ 10] : comment |
| * Byte[ 6][ 11] : comment |
| * Byte[ 6][ 12] : comment |
| * Byte[ 6][ 13] : comment |
| * Byte[ 6][ 14] : comment |
| * Byte[ 6][ 15] : comment |
| * Byte[ 6][ 16] : comment |
| * Byte[ 6][ 17] : comment |
| * Byte[ 6][ 18] : comment |
| * Byte[ 6][ 19] : comment |
| * Byte[ 6][ 20] : comment |
| * Byte[ 6][ 21] : comment |
| * Byte[ 6][ 22] : comment |
| * Byte[ 6][ 23] : comment |
| * Byte[ 6][ 24] : comment |
| : |
| Line# 7 : Code Only |
| * Byte[ 7][ 1] : blank |
| * Byte[ 7][ 2] : blank |
| * Byte[ 7][ 3] : code |
| * Byte[ 7][ 4] : code |
| * Byte[ 7][ 5] : code |
| * Byte[ 7][ 6] : code |
| * Byte[ 7][ 7] : blank |
| * Byte[ 7][ 8] : code |
| * Byte[ 7][ 9] : code |
| * Byte[ 7][ 10] : blank |
| * Byte[ 7][ 11] : code (string) |
| * Byte[ 7][ 12] : code (string) |
| * Byte[ 7][ 13] : code (string) |
| * Byte[ 7][ 14] : code (string) |
| * Byte[ 7][ 15] : code (string) |
| * Byte[ 7][ 16] : code (string) |
| * Byte[ 7][ 17] : code (string) |
| * Byte[ 7][ 18] : code (string) |
| * Byte[ 7][ 19] : code (string) |
| * Byte[ 7][ 20] : code (string) |
| * Byte[ 7][ 21] : code (string) |
| * Byte[ 7][ 22] : code (string) |
| * Byte[ 7][ 23] : code (string) |
| * Byte[ 7][ 24] : blank |
| * Byte[ 7][ 25] : code |
| * Byte[ 7][ 26] : code |
| * Byte[ 7][ 27] : blank |
| * Byte[ 7][ 28] : code |
| * Byte[ 7][ 29] : code |
| * Byte[ 7][ 30] : code |
| * Byte[ 7][ 31] : code |
| * Byte[ 7][ 32] : code |
| : |
| Line# 8 : Code Only |
| * Byte[ 8][ 1] : blank |
| * Byte[ 8][ 2] : blank |
| * Byte[ 8][ 3] : code |
| * Byte[ 8][ 4] : code |
| * Byte[ 8][ 5] : code |
| * Byte[ 8][ 6] : code |
| * Byte[ 8][ 7] : code |
| * Byte[ 8][ 8] : code |
| * Byte[ 8][ 9] : blank |
| * Byte[ 8][ 10] : code |
| * Byte[ 8][ 11] : code |
| : |
| Line# 9 : Code Only |
| * Byte[ 9][ 1] : code |
==========================================


--
=====================================
Alex Vinokur
mailto:ale...@connect.to
http://mathforum.org/library/view/10978.html
news://news.gmane.org/gmane.comp.lang.c++.perfometer
=====================================

Thomas Dickey

unread,
Dec 31, 2003, 8:31:32 AM12/31/03
to
Alex Vinokur <ale...@big.foot.com> wrote:
> Counter of C/C++ code can be downloaded at :
> http://alexvn.freeservers.com/s1/download.html#label1_cncc

it needs an option to get rid of the boxes.
better:
http://invisible-island.net/c_count/

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Thomas Dickey

unread,
Dec 31, 2003, 8:44:06 AM12/31/03
to
Alex Vinokur <ale...@big.foot.com> wrote:
> Counter of C/C++ code can be downloaded at :
> http://alexvn.freeservers.com/s1/download.html#label1_cncc


> 1. Description.

> NAME
> cncc - count C/C++ source lines and bytes

c_count cncc.cpp gives

2128 769 |cncc.cpp
----------------
2128 769 total lines/statements

123 lines had comments 5.8 %
10 comments are inline -0.5 %
479 lines were blank 22.5 %
77 lines for preprocessor 3.6 %
1459 lines containing code 68.6 %
2128 total lines 100.0 %

926 comment-chars 1.9 %
1718 nontext-comment-chars 3.6 %
11874 whitespace-chars 24.7 %
1489 preprocessor-chars 3.1 %
32143 statement-chars 66.8 %
48150 total characters 100.0 %

3611 tokens, average length 7.19

0.03 ratio of comment:code

58 top-level blocks/statements
7 maximum blocklevel
2.46 ratio of blocklevel:code

Compare with c_count c_count.c:

1277 496 |c_count.c
----------------
1277 496 total lines/statements

193 lines had comments 15.1 %
33 comments are inline -2.6 %
98 lines were blank 7.7 %
50 lines for preprocessor 3.9 %
969 lines containing code 75.9 %
1277 total lines 100.0 %

5279 comment-chars 17.3 %
1071 nontext-comment-chars 3.5 %
7492 whitespace-chars 24.5 %
871 preprocessor-chars 2.9 %
15840 statement-chars 51.8 %
30553 total characters 100.0 %

2180 tokens, average length 5.03

0.32 ratio of comment:code

71 top-level blocks/statements
7 maximum blocklevel
2.88 ratio of blocklevel:code

(c_count can also make a comma-separated file for spreadsheets, but I find
the column layout here more readable)

Alex Vinokur

unread,
May 28, 2004, 11:18:13 AM5/28/04
to

"Alex Vinokur" <ale...@big.foot.com> wrote in message news:bstjrc$19bd0$1...@ID-79865.news.uni-berlin.de...

> Counter of C/C++ code can be downloaded at :
> http://alexvn.freeservers.com/s1/download.html#label1_cncc

Also at https://sourceforge.net/projects/cncc/

[snip]

--
Alex Vinokur
http://mathforum.org/library/view/10978.html

0 new messages