<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 26, 2022 at 3:04 PM Ray Gardner <<a href="mailto:raygard@gmail.com">raygard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Aug 24, 2022 at 2:26 AM Rob Landley <<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>> wrote:<br>
><br>
> On 8/22/22 10:39, enh via Toybox wrote:<br>
> > On Sun, Aug 21, 2022 at 9:12 AM Ray Gardner <<a href="mailto:raygard@gmail.com" target="_blank">raygard@gmail.com</a><br>
> > <mailto:<a href="mailto:raygard@gmail.com" target="_blank">raygard@gmail.com</a>>> wrote:<br>
> ><br>
> >     I guess I'll skip writing up an explanation of these algos then; I<br>
> >     thought you were looking for a less "mathematical" explanation ("why<br>
> >     can nobody explain what the old stuff is doing without pretending it's<br>
> >     math instead of an algorithm?" "Doug McIlroy's old diff paper from<br>
> >     1976 is still written in math-ese. It SEEMS to be describing very<br>
> >     simple concepts but it's trying to explain them as if this is<br>
> >     calculus, which it is not." etc.) But that's moot if you're going with<br>
> >     what appears to be the old "look ahead a little for matching lines to<br>
> >     re-sync on" heuristic diff method.<br>
> ><br>
> > (fwiw, i think such a document would be a useful thing to leave lying around on<br>
> > the internet ... someone will want it sooner or later :-) )<br>
><br>
> I'm also interested. I've just been a bit distracted because my air conditioner<br>
> broke over the weekend (soonest somebody can come fix it is thursday. It's<br>
> August in Texas...) and because my diff code isn't quite ready to go back and<br>
> run this new test through yet, and I wanted to include that in my reply.<br>
<br>
Thanks for the encouragement, guys. Check it out. I've posted it at<br>
<a href="https://www.raygard.net/2022/08/26/diff-LCS-Hunt-Szymanski-Kuo-Cross/" rel="noreferrer" target="_blank">https://www.raygard.net/2022/08/26/diff-LCS-Hunt-Szymanski-Kuo-Cross/</a><br>
along with the code. C code is<br>
<a href="https://github.com/raygard/lcs_diff_demo/blob/main/src/c/diff.c" rel="noreferrer" target="_blank">https://github.com/raygard/lcs_diff_demo/blob/main/src/c/diff.c</a> ;<br>
there is also Python code in that repo, including a version of<br>
Hunt-McIlroy that may satisfy Rob's complaint "Alas, I've read that<br>
paper through twice and have not managed to turn their explanation<br>
into pseudo-code, and that's WITH an implementation in front of me",<br>
if you find that Python is acceptable as executable pseudocode, as<br>
I've heard it said. The code is written very closely to the paper's<br>
appendix. But, if you read the post linked above, you'll see that it's<br>
probably better to use Kuo/Cross (or my mod of that) instead.<br>
<br>
I did find a bug in the diff.c I posted earlier and I think this<br>
version gets everything right. I expanded it a bit to include<br>
Hunt/Szymanski but that's just for demo, it's not as good as the<br>
Kuo/Cross implementations also included. (Compile it with HS, KC, or<br>
KCMOD defined to get the different algos.)<br>
<br>
I do this for my own enjoyment but also hoping someone will benefit<br>
from it. I wrote the earlier C code I posted to the list in the hope<br>
that it would help Rob. He's decided to go his own way, so that was<br>
probably many wasted hours. But if you want to get, e.g. a unified<br>
diff with -U 0 (no context lines), I have it. I think that may be<br>
harder with Rob's approach. I will also bet that my diff.c will be<br>
faster on large-ish files and produce better diffs but that remains to<br>
be tested. And I've also back-tested it by patch-ing the files with<br>
the diff output, including context lines of 0, 1, 2, 3, 4.<br>
<br>
So, nobody reads my blog ("glob") at least not yet. I spent many many<br>
hours developing the world's fastest qsort() implementations, but I<br>
have no way to get anyone who can get them used to look at it.<br></blockquote><div><br></div><div>have you tried? the llvm-libc folks are effectively starting from scratch (<a href="https://github.com/llvm/llvm-project/blob/main/libc/src/stdlib/qsort.cpp">https://github.com/llvm/llvm-project/blob/main/libc/src/stdlib/qsort.cpp</a>), and i'd imagine the BSDs would be receptive to improvements, even if it's super annoying that there are three BSDs that don't really share code in any organized fashion? (we've never found qsort() important enough to do anything but track BSD; i forget which one!)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Now I've written what I hope is a good explanation of a couple of LCS<br>
algos. I sure hope you'll read it and give me feedback. If you don't,<br>
I may never speak to you again :-).<br>
<br>
Ray<br>
<br>
Ray<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div></div>