NO

Author Topic: Line Counter Add-IN  (Read 17312 times)

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #15 on: May 20, 2021, 12:42:51 PM »
Version 1.0  :)
Attachments:
ReadMe.txt - brief introduction and instructions
LineCount.dll - the add-in dll
LineCount.zip - The entire project as zipped by PellesC

John Z
« Last Edit: May 22, 2021, 01:46:20 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #16 on: May 20, 2021, 01:40:40 PM »
Quote
File name:C:\Users\51966\Documents\Pelles C Projects\TestSSE\Fusion.asm
startLine:1, endLine:107
Total Lines: 107
 Empty Lines: 32
 Data : 3
 Labels  : 5
 Comment Lines: 19
 Code Lines: 48


EXACT


 :D :D :D :D :D :D

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #17 on: May 20, 2021, 01:54:11 PM »
With the following comment it is OK too



/////////////////////////////
// This is a valid comment //
/////////////////////////////

You would say that if there are errors at compile time the results you display can be wrong.
The file you read must be FREE of ERRORS

Very good job

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #18 on: May 20, 2021, 02:11:56 PM »
It seems that the count of "}" is wrong.
I have 24 "{" and you find them.
I have 24 "}" and you find 22.
Verified with Notepad++


When I saw the numbers I thought I had removed some lines.
This indication is very important for me.
"startline" and "endline" are in lowercase but for the other lines the first letters is in uppercase.


I would prefer the following style :



     File name: C:\Users\...\TestSSE\Main.c
    Start Line: 1, EndLine: 262
   Total Lines: 262
   Empty Lines: 64
        Lone {: 24
        Lone }: 22
Comment Lines: 3
    Code Lines: 149


In the case the number of '{' is deferent that the number of '}' you could display a warning.
For me this add-in is useful when reformating the text, after removing unnecessary lines...
Knowing that there is no problem with the pair {} is a good thing.

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #19 on: May 20, 2021, 04:08:44 PM »
I'll check, but point out that it counts lone } not brackets that are with preceded with code.
so
{
  A=1;
}

and
{
 A=1;}

and
{ A=1;}

and
{
  A=1;
} B=2;

all give different counts
example 1 would be 1{ and 1} and 1 Code,
example 2 would be 1{ and 0} and 1 Code,
example 3 would be 0{ and 0} and 1 Code
example 4 would be 1{ and 0} and 2 Code

So I was not trying to match Open and Close counts I was distinguishing code from just a lone bracket which I don't really consider a line of 'code', I might add that …

John Z
« Last Edit: May 20, 2021, 05:53:41 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #20 on: May 20, 2021, 04:15:26 PM »
Ok but with the file I used it is the case 1.
The file used is in the 7zip file of my post about TestSSE
I join it here

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #21 on: May 20, 2021, 04:28:33 PM »
Good to have examples - Thanks.

From your file
Code: [Select]
typedef struct tagBITMAPINFOV5
{
BITMAPV5HEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFOV5,*LPBITMAPINFOV5;

The last line is the second example case.  There are two spots where this is done. Here is the second:
Code: [Select]
typedef struct tagIMAGEINFOS
{
LPBYTE lpOriginal ;
double dRatio ; // Height Divided by Width (double = 64 bits)
BITMAPINFOV5 BitmapInfo ;
} IMAGEINFOS,*LPIMAGEINFOS ;

Both of these would give 1 count of {, and no } counts because there is 'code' after the }

Perhaps not optimum, I'll think on it.

John Z

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #22 on: May 20, 2021, 05:51:44 PM »
I have not thought to structures!


I join some examples of code of mine

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #23 on: May 20, 2021, 05:56:41 PM »
That's all I have

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #24 on: May 20, 2021, 05:58:48 PM »
Thanks,

I may add structure detection to handle differently as a unique (but standard) case.  Thinking about it.....

Appreciate the additional examples. I'll try them.

John Z


Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #25 on: May 21, 2021, 05:51:05 PM »
Next version to test.
Modified to count every { and } report separately,
as well as counting the Lone { and }.
Should be more representative, however it is not perfect.  For example if there is a text string containing
{ or } they are counted too.  Not sure it is worth the code to detect these cases.....

Change output format ;)

John Z
« Last Edit: May 22, 2021, 01:46:47 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #26 on: May 22, 2021, 03:28:32 AM »
Quote
File name:C:\Users\51966\Documents\Pelles C Projects\Cfe\Fusion.c
 Start Line:1, End Line:2033
  Total Lines   : 2033
  Empty Lines   : 351
  Lone {      : 54
  Lone }      : 54
  ALL {      : 67
  All }      : 67
  Comment Lines   : 694
  Code Lines   : 880


PERFECT

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #27 on: May 22, 2021, 11:34:27 AM »
Thanks
Here is all of version 1.1. 

It currently only processes the 'active' project source window.  Might be nice to be able to process every source file in the project.  To do that I'll have to figure out how to open each file in the source tree.  Then it could give the project totals too.


John Z

P.S. It works best if the source code has been processed using PellesC "Convert to"-"Formatted C code"  :)

removed old attachment to free upload space
« Last Edit: August 17, 2022, 04:25:10 PM by John Z »

Grincheux

  • Guest
Re: Line Counter Add-IN
« Reply #28 on: May 22, 2021, 03:39:56 PM »
Publicity is prohibited... Like the internet site, "This is better if using G...C... Or M...."

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Line Counter Add-IN
« Reply #29 on: May 23, 2021, 04:55:09 PM »
Here is a new version which will process all source files open in the edit window.  When there are multiple files open there will be a summary at the end of the output. So if you want the project totals just have the files open in the edit window then invoke the Line Counter.  As long as the file is a source file it will be processed.  To process a resource file it must be opened as text.  If there are both C and asm and h they are all summarized together.  If multiple files are open but a selection is made in one file and Line Counter is invoked with the selection the other files are not processed, just the selection.

I think this is much more useful now....

Example Output:
Code: [Select]
File name:C:\Program Files\PellesC\Files\LCounter\Line_Count.c
 Start Line:1, End Line:748
  Total Lines : 748
  Empty Lines : 89
  Lone { : 57
  Lone } : 66
  All { : 95
  All } : 96
  Comment Lines : 165
  Code Lines : 371
File name:C:\Program Files\PellesC\Files\LCounter\LineCount.h
 Start Line:1, End Line:23
  Total Lines : 23
  Empty Lines : 2
  All { : 1
  All } : 1
  Comment Lines : 2
  Code Lines : 19

*Summary results*
  Total Lines : 771
  Empty Lines : 91
  Lone { : 57
  Lone } : 66
  All { : 96
  All } : 97
  Comment Lines : 167
  Code Lines : 390

I need to update the doc and clean the source before posting them.

John Z

Update attached project zip and document ReadMe....

removed old attachments to free upload space
« Last Edit: August 17, 2022, 04:26:06 PM by John Z »