Compare different sections of the same file

Post your new features ideas and suggestions here.
Post Reply
adiroot
Posts: 4
Joined: Mon Jan 11, 2010 3:07 am

Compare different sections of the same file

Post by adiroot »

I would appreciate being able to compare a section of a file to another section of the same file.

I often write routines that look near identical to each other except for a few differences. The routines are in the same file and I need to compare them.

Currently, what I have to do is create a temporary file, copy one of the sections to it, then compare that file with the original.

E.g. File has these two routines:

CTxInstruct::CTxInstruct(const CTxInstruct& other)
{
memcpy((char*)this, (char *)&other, sizeof(CTxInstruct));
}

const CTxInstruct& CTxInstruct::operator=(const CTxInstruct& other)
{
memcpy((char*)this, (char *)&other, sizeof(CTxInstruct));
return *this;
}

I would be great if I could see the comparison of those two routines just as if each were in its own file.
Thanks!

grigsoft
Site Admin
Posts: 1673
Joined: Tue Sep 23, 2003 7:37 pm
Contact:

Re: Compare different sections of the same file

Post by grigsoft »

You can do that now, in fact. Select same file twice, and then put Manual Anchor (CTRL+M) on both sides for section you need. Recompare files and you will get what you probably need.

adiroot
Posts: 4
Joined: Mon Jan 11, 2010 3:07 am

Re: Compare different sections of the same file

Post by adiroot »

I tried the Manual Anchor but could not get it to work.
I compared a file to itself and set one anchor in each of the compared 'files'.

However, that does nothing except show markers where I put the anchors. Clicking on show anchor does not do a compare.
Attachments
CompareItManMatch.jpg
CompareItManMatch.jpg (102.81 KiB) Viewed 17054 times

grigsoft
Site Admin
Posts: 1673
Joined: Tue Sep 23, 2003 7:37 pm
Contact:

Re: Compare different sections of the same file

Post by grigsoft »

Try to rescan (F5) files

adiroot
Posts: 4
Joined: Mon Jan 11, 2010 3:07 am

Re: Compare different sections of the same file

Post by adiroot »

It does not work nearly as well. Most of the great features of CompareIt! are missing when done with anchors. See screenshots for comparing the same content when using the same file vs using different files.
Attachments
DiffFiles.jpg
DiffFiles.jpg (75.68 KiB) Viewed 17041 times
SameFile.jpg
SameFile.jpg (125.19 KiB) Viewed 17041 times

grigsoft
Site Admin
Posts: 1673
Joined: Tue Sep 23, 2003 7:37 pm
Contact:

Re: Compare different sections of the same file

Post by grigsoft »

Yes, in your case same lines after anchors confuses program. At the moment the only option I can think of is some way to select block in file, mark it "for comparison", select block in other file, and say "Compare marked blocks". I guess this might be useful for some other cases too. This will work as manual anchor but for blocks, not for lines.

Post Reply