资 源 简 介
This is an Awk script that I wrote to compute C code metrics. It looks at code and comments via regular expressions and computes
Lines of code (non-blank)
Number of comments (multiline and single-line accounted for)
Raw lines of text
Total code
Total comments
Comment percentage
The last is the most interesting. I"m a comment-zealot so mine tend to run about 24%.
It"s old code, but works great and is really quite fast.
Run it like so:
awk -f lc.awk *.c
I use a shell script called lc:
#!/bin/sh# Script to call awk line-counting script# pfh 3/19/02awk -f ${HOME}/bin/lc.awk $*%
Here"s an example, the Linux kernel 2.2.16:
----------File---Code---Comments---Raw Lines------------------------------------ sys.c 716 193 1025 panic.c 59 21 90 itimer.c 133 21 173 printk.c