WANTED: "C" code line counter program

Zack C. Sessions session at uncw.UUCP
Thu Mar 14 02:56:31 AEST 1991


cpm00 at duts.ccc.amdahl.com (Craig P McLaughlin) writes:

|In article <1991Mar11.182848.26693 at comm.wang.com> lws at comm.wang.com (Lyle Seaman) writes:
||dcavasso at ntpal.uucp (Dana Cavasso) writes:
|||     I need a "C" code line counter program, preferably written in
|||"C".  It will be used on several platforms, so solutions involving
||
||Counting semi-colons is a pretty good approach, as that counts C 
||statements.  Lines is kind of less meaningful.  Counting '{' is 
||an interesting one, too.
||

|  Counting semi-colons may miscount setups like the one below:

|    while(condition)
|        do_this;

|  That's two, I think. :)  What about counting newlines, but ignoring those
|that immediately follow another newline (ie, skip blank lines)?

|Craig McLaughlin   cpm00 at duts.ccc.amdahl.com   V:(408)737-5502

Counting newlines may not be the way to go either. It is perfectly
legitimate for a statement to span multiple source lines. Take a
complex if() condition, for example, which for readability, you
span a few lines with it. A true C source line counter would almost
have to be the front end to a full compiler.

Zack Sessions
session at uncw.UUCP



More information about the Comp.lang.c mailing list