Xref: utzoo alt.sources.wanted:1062 comp.sources.wanted:15727 comp.software-eng:5042 comp.lang.c:37026 Path: utzoo!news-server.csri.toronto.edu!rutgers!mcnc!ecsgate!ecsvax!uncw!session From: session@uncw.UUCP (Zack C. Sessions) Newsgroups: alt.sources.wanted,comp.sources.wanted,comp.software-eng,comp.lang.c Subject: Re: WANTED: "C" code line counter program Message-ID: <1072@uncw.UUCP> Date: 13 Mar 91 16:56:31 GMT References: <1991Mar6.214157.18633@ntpal.uucp> <1991Mar11.182848.26693@comm.wang.com> Organization: Univ. of North Carolina at Wilmington Lines: 30 cpm00@duts.ccc.amdahl.com (Craig P McLaughlin) writes: |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. || | 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@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@uncw.UUCP