blacksqr / sclc

Automatically exported from code.google.com/p/sclc
0 stars 1 forks source link

XML total lines different the console output for some files #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. sclc -xml_output test.xml LOCChartMaker.java

What is the expected output? What do you see instead?
Expected:
===================================================
   319     17     29    275 ./src/net/sf/statcvs/charts/LOCChartMaker.java
 (Java)
<?xml version='1.0'?>
<sclc>
  <file blankLines="17" commentLines="29"
fileName="/home/maihde/workspace/statcvs/src/net/sf/statcvs/charts/LOCChartMaker
.java"
fileType="Java" sdt="FileMetric" sourceLines="275" tool="SCLC"
totalLines="321" tptoks="2205" />
</sclc>

I would expect that the totalLines in the XML output would be identical to
the total lines in the console output.  "wc -l" reports 319, but the sum of
the sclc output is 321.

What version of the product are you using? On what operating system?
2.5.525

Please provide any additional information below.

Original issue reported on code.google.com by mike.i...@gmail.com on 27 Feb 2008 at 8:13

Attachments:

GoogleCodeExporter commented 8 years ago
Further investigation shows that the issue is related to end-of-line comments 
that
share the same line as code.  These lines get counted twice, once as NBLC and 
once as
a comment.  The XML output for total lines is:

$fileInfoHash{'totalLines'} = $src_lines + $cmnt_lines + $blank_lines;

where the console output for total lines is:

$CNTS{'Lines'}

The following patch seems to resolve the issue for me.  However, there may be a 
good
reason that totalLines was recalculated for the XML output so this patch may 
not be
the correct fix.

--- workspace/archives/sclc-2.5.525/src/sclc    2007-05-25 14:37:24.000000000 
-0400
+++ /usr/local/bin/sclc 2008-02-28 09:26:31.000000000 -0500
@@ -2356,6 +2356,7 @@
     my $src_lines = 0;
     my $cmnt_lines = 0;
     my $blank_lines = 0;
+    my $lines = 0;

     foreach (@$Name) {
       my $set = $CNTS{lc $_};
@@ -2366,7 +2367,8 @@
       }
       elsif ($_ eq 'Lines') {
         # Don't need lines with included blanks.
-        #$lines = $$Count{"$type$_"};
+        $lines = $$Count{"$type$_"};
+        $fileInfoHash{'totalLines'} = $lines;
       }
       elsif ($_ eq 'Blank') {
         $blank_lines = $$Count{"$type$_"} || 0;
@@ -2381,7 +2383,7 @@
       }
     }
     # calculate total lines  (cmmnts + src + blank)
-    $fileInfoHash{'totalLines'} = $src_lines + $cmnt_lines + $blank_lines;
+    #$fileInfoHash{'totalLines'} = $src_lines + $cmnt_lines + $blank_lines;

     # Get MPI and OpenMP counts
     if($language eq 'C++' || $language eq 'C' || $language eq 'FORTRAN') {

Original comment by mike.i...@gmail.com on 28 Feb 2008 at 2:28

GoogleCodeExporter commented 8 years ago
Issue 9 has been merged into this issue.

Original comment by lorinh on 6 Apr 2010 at 1:42