Page 1 of 1

Compare different sections of the same file

Posted: Mon Jan 11, 2010 3:18 am
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!

Re: Compare different sections of the same file

Posted: Tue Jan 12, 2010 6:21 pm
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.

Re: Compare different sections of the same file

Posted: Wed Jan 13, 2010 3:44 am
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.

Re: Compare different sections of the same file

Posted: Wed Jan 13, 2010 7:55 pm
by grigsoft
Try to rescan (F5) files

Re: Compare different sections of the same file

Posted: Thu Jan 14, 2010 5:57 am
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.

Re: Compare different sections of the same file

Posted: Thu Jan 14, 2010 8:04 am
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.