Xref: utzoo alt.sources.wanted:1066 comp.sources.wanted:15738 comp.software-eng:5050 comp.lang.c:37062 Path: utzoo!utgpu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!ulysses!ulysses.att.com!mwb From: mwb@ulysses.att.com (Michael W. Balk) Newsgroups: alt.sources.wanted,comp.sources.wanted,comp.software-eng,comp.lang.c Subject: Re: WANTED: "C" code line counter program Summary: Counting semi-colons could be misleading. Message-ID: <14461@ulysses.att.com> Date: 14 Mar 91 04:06:48 GMT References: <1991Mar6.214157.18633@ntpal.uucp> <1991Mar11.182848.26693@comm.wang.com> Sender: netnews@ulysses.att.com Followup-To: comp.lang.c Lines: 23 In article <1991Mar11.182848.26693@comm.wang.com>, lws@comm.wang.com (Lyle Seaman) writes: > 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 > > 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. If you just count semi-colons, then in for-loops such as for(i = 0; i < 10; i++) { ... } i = 0; and i < 10; will be counted as individual statements. In fact they are, but if you want to count for( ... ) as a single statement then count the semi-colons and correct the count by subtracting 1 for every for-statement. There might be other cases like this that you may want to consider. Then again, in most cases this is just probably nit-picking.