Source Line Counting

Watts S. Humphrey gives some recommendations on how to do it in his book "A Discipline for Software Engineering".

C++ line counting Ruby script
Based on the ideas in this book.

C++ line counting Ruby script (syntax highlighted)
Based on the ideas in this book.

Further reading

C.M. Lott's metrics site.
Has links to several programs/scripts to do line counting in various languages.

Brad Appleton's clc Perl script.
Similar to ours (only better). Supports various languages and gives a different line count for C++ than my script. Recommended.

David A. Wheeler's SLOCCount
Used to estimate the size of the Linux source tree. I think it is more about physical line count and not about logical line count.