LOC counter ?

LOC counter ?

Post by Tomato M » Tue, 16 Sep 1997 04:00:00



Hi -

  Its that season again - the managers are asking for counts of lines
of code - not counting comments, or else I'd just pipe it all thru
'wc -l'. Yeah, its a meaningless number, but, well, I do have to
produce some kind of number.

  Programs to do this have been done about a million times - I'm looking
for one. It has to be public domain, and it has to do both old c and c++.
Any ideas on a product name I can search for ?
-P

 
 
 

LOC counter ?

Post by James Youngma » Wed, 17 Sep 1997 04:00:00


  Tomato>   Its that season again - the managers are asking for counts
  Tomato> of lines of code - not counting comments, or else I'd just
  Tomato> pipe it all thru 'wc -l'. Yeah, its a meaningless number,
  Tomato> but, well, I do have to produce some kind of number.

Only slightly more savvy than "wc -l" is

tr -dc '{;#' | wc -c

IMHO a more useful metric tool is one that ONLY counts comments...

If you MUST delete comments, use this Perl script.  It is derived from
one of Larry Wall's examples in the perlop(1) manpage:-

---cut here---
#!/usr/bin/perl -p -n077

# Option -p: sed-like behaviour; at end of script, do "print;" and repeat.
# Option -n077: slurp input files whole.

s { /\*      # Match the opening delimiter
    .*?      # Match a minimal number of characters
    \*/      # Match the closing delimiter

Quote:} []gsx;

---cut here---

 
 
 

LOC counter ?

Post by Mike Jagdi » Wed, 17 Sep 1997 04:00:00


Tomato Man said

Quote:>  Its that season again - the managers are asking for counts of lines
>of code - not counting comments, or else I'd just pipe it all thru
>'wc -l'. Yeah, its a meaningless number, but, well, I do have to
>produce some kind of number.

It's worse than meaningless! Many companies have been burnt by such
dumb ideas - IBM among them - and if managers aren't aware of that
they aren't managing very well! (Of course, they may just figure
that the company can afford to throw money at IT without it
contributing anything useful back :-) )

Quote:>  Programs to do this have been done about a million times - I'm looking
>for one. It has to be public domain, and it has to do both old c and c++.
>Any ideas on a product name I can search for ?

You probably already have it. Run the source through "cc -E". This
preprocesses the source, stripping comments, expanding headers and
adding "#line" directives (which allow the main compiler to generate
the correct debug references). Presumably you aren't going to be
allowed to count standard headers all over the place so you need
to run this output through a simple filter that discards lines if
the last "#line" directive named a .h file and counts, or outputs,
them if it named a .c file. It should only be half a dozen lines
of shell script :-).

                                Mike

--
.----------------------------------------------------------------------.

|  Roan Technology Ltd.         |                                      |
|  54A Peach Street, Wokingham  |  Telephone:  +44 118 989 0403        |

 
 
 

1. WANTED: CM Tracking Tools and LOC counters

  I am a Configuration Manager and I am looking for tools to help automate my
job, either off-the-shelf or public domain.

I will need tools to help track the following items:

        problem reports
        action items
        meeting minutes (including code and design walkthroughs)
        turnovers and release forms
        lines-of-code (also need LOC counters for various platforms and languages)

I would appreciate any information you can offer.  Thanks in advace...

Patrick Lefeld

2. 2.4.19-pre2 Cyrix III SEGFAULT (Cyrix II redux?)

3. Reading the timestamp counter or other cycle counters on x86 Linux?

4. I want original permissions on my backup CDs, dammit.

5. performance counters 3.1 for 2.5.45 [2/4]: per-process counters

6. All HAIL Bill GATES, <if they could run them, they would come>

7. Apache and <!--#exec cgi="/cgi-bin/counter/counter.cgi" -->

8. stty erase ^H, bad karma, why?

9. x86 performance counters driver 3.0-pre2 for 2.5.44: [3/4] per-process counters

10. Accessing Ultra's performace counters and TICK counter

11. How to find out how many LOC's are added/modified between 2 files

12. searching for bos.loc.iso.de_DE

13. Help: where do I find bos.loc.pc_compat.En_US ???