Page 1 of 2
Compare text files (or sources)
Posted: Tue Nov 30, 2021 11:30 am
by Michael Vogel
Has anyone made a tool to compare text files? Most of the programs (included the purebasic IDE tool) are not able to do a good job for source codes, see the example below (
Screenshot):
Code 1:
Code: Select all
blah
procedure a_simple_one
one for i=1 to endless
two Str(GetJSONInteger(GetJSONMember(o,"id"))) +": "+ GetJSONString(GetJSONMember(o,"title"))
three next i
endprocedure
blah, blah
procedure be_more_complex
alpha #InternalFontFile="Huii IBM Plex Mono.ttf"; "Huii Console.ttf"
bravo #BirdFilter=Chr(#BirdFilterChar)
charlie #CharReturn=Chr($21a9); $21a9, $21b5, $23ce, $2386
endprocedure
blah, blah, blah
procedure code_or_not_code
ypsilon !mov rax,[p.p_m]
chi !gifdecoder_GifSkipBlock_loop:
omega !lea rax,[rax + rcx + 1]
endprocedure
Code 2:
Code: Select all
blah
blah, blah
procedure code_or_not_code
ypsilon !mov rax,[p.p_m]
chi !gifdecoder_GifSkipBlock_loop:
psi !movzx rcx,byte [rax]
omega !lea rax,[rax + rcx + 1]
endprocedure
procedure be_more_complex
alpha #InternalFontFile="Huii IBM Plex Mono.ttf"; "Huii Console.ttf"
charlie #CharReturn=Chr($21a9); $21a9, $21b5, $23ce, $2386
endprocedure
blah, blah, blah
another new line
procedure a_simple_one
one for i=1 to endless
two Str(GetJSONInteger(GetJSONMember(o,"id"))) +": "+ GetJSONString(GetJSONMember
(o,"title"))
three next i
endprocedure
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 12:37 pm
by BarryG
Your image is too small to view, so here's my view of your two codes with the PureBasic comparison. What's so bad about it? Looks great to me.
You could try
https://winmerge.org (free); and Windows has "fc" built-in to use from the command-line.

Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 1:18 pm
by #NULL
git diff has an option to detect code moves. You can diff any two files without having any git repo initialized. It's only coloring though, not giving any patch info. Not sure how useful it is.
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 1:19 pm
by Michael Vogel
Procedure '
a' has moved to the bottom and procedure '
c' to the top, but this hasn't been recognized by tools like winmerge, windiff, etc.
I will check git diff, thank you for the hint.

Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 1:51 pm
by dige
Notepad++ will do the job right
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 2:11 pm
by Marc56us
Procedure 'a' has moved to the bottom and procedure 'c' to the top, but this hasn't been recognized by tools like winmerge, windiff, etc.
Winmerge can do it. See help
"
Moved differences
Moved differences are identical lines in different locations. They are shown only if the Enable moved block detection is checked in the Options dialog Compare page. See Difference highlighting for more details about moved differences in the File pane. The Location pane draws a line connecting moved differences in the left and right location bars."
(or right click on map and check "No moved blocks / All moved blocks")

Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 2:55 pm
by Michael Vogel
Not very happy with the results of WinMerge and the Notepad++ plugin as well (did some tests earlier).
Still investigating
git diff - will take a while (first I've reduced the portable installation of git to keep only needed files. Seems that not more than the files git.exe, libiconv-2.dll, libpcre2-8-0.dll, libssl-1_1-x64.dll, libintl-8.dll and libssp-0.dll are needed

)
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 3:36 pm
by ebs
My favorite tool for comparing files is CompareIt! (
https://www.grigsoft.com/wincmp3.htm).
It clearly indicates the moved procedure, but I don't have anywhere to post a screenshot.
The usual price for a license is $29, which I consider a bargain, but if you use the coupon code
COVID, it's 50% off.
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 3:38 pm
by skywalk
My order of preference for text diff's.
1. WinMerge
2. Notepad++ plugin, x64 preferred, x86 fails on larger files.
3. Fossil, quick and dirty comparisons but most often trigger WinMerge.
4. git is too heavy but similar to Fossil.
There are many other tools, but these suffice.
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 4:57 pm
by dige
Is the result of the comparison with Notepadd++ not what you need?
Screenshot Notepad compare result:
https://u.pcloud.link/publink/show?code ... F3YQoQeqS7
Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 5:07 pm
by Marc56us
Michael Vogel wrote: Tue Nov 30, 2021 11:30 am
Has anyone made a tool to compare text files? Most of the programs (included the purebasic IDE tool) are not able to do a good job for source codes, ...
Yes, you are right. And moreover, these programs are often difficult to read.
It could be interesting to make a special PB program in several steps
1. List the procedures that exist or not between the two
Then
2. For each procedure, see the differences

Re: Compare text files (or sources)
Posted: Tue Nov 30, 2021 7:07 pm
by Tenaja
Your minimal test might be detected as changes even if the tool is capable of detecting moves. Might make them the test more substantial or useable, so it's more than single character comparisons. With the given files, single character could be considered a change, but real functions might be evaluated as moves.
Re: Compare text files (or sources)
Posted: Wed Dec 01, 2021 7:17 am
by RASHAD
Any Hex Editor like WinHex has a tool to compare data
It's much faster and accurate
BTW:Winmerge looks fine with me
Re: Compare text files (or sources)
Posted: Wed Dec 01, 2021 6:19 pm
by IzzyB
There's a rather nice compare (and more) software product out there called 'Beyond Compare'. It's not free, but it's pretty strong.
Re: Compare text files (or sources)
Posted: Sun Dec 05, 2021 4:07 pm
by Michael Vogel
First of all, thanks for all replies here, they all contain valuable hints for me...
Meanwhile I've expanded the text content in the example texts (see initial post) to have a more realistic test scenario. Anyhow the results of my tested programs (including additional programs like UEDiff and HxD64) are still far away from good.
WinMerge seems to do a good job in recognizing some of the moved lines (except the mutiple "endprocedure" lines) but is not able to display the corresponding lines.