Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!rutgers!njin!princeton!pucc!EGNILGES From: EGNILGES@pucc.Princeton.EDU (Ed Nilges) Newsgroups: comp.software-eng Subject: Re: WANTED: "C" code line counter program Message-ID: <12561@pucc.Princeton.EDU> Date: 9 Mar 91 02:34:47 GMT References: <1991Mar6.214157.18633@ntpal.uucp> Reply-To: EGNILGES@pucc.Princeton.EDU Organization: Princeton University, NJ Lines: 46 Disclaimer: Author bears full responsibility for contents of this article In article <1991Mar6.214157.18633@ntpal.uucp>, dcavasso@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 >shell scripts and other UNIX utilities won't work. I'm not very >picky (although I'd like something that did a little more than count >newlines :-) > > With the growing trend toward gathering metrics, I expect >such beasts are out there in force. If you would be willing to >share your source, let me know. This request sounds innocuous: but think about it for a second. The following nonsense C code has three lines: a = 1; a = a+c; a = c*7; and the following equivalent code has one line! a = 1; a = a+c; a = c*7; It gets worse. How many lines in the following? if ( a = 1 ) { a = 0; c = 1; } Two, says the FORTRAN programmer. But if a line is roughly equivalent to a statement, there is only ONE line in the above...a line that contains two lines inside it... In short, "line" of C code is a meaningless concept. Count STATEMENTS. If you must count. In the last example above, there are 3 statements. Software engineering: computer science for people who can't program (Edsger Dijkstra.)