<div dir="ltr"><div>(sorry, been ooo.)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 28, 2020 at 11:21 PM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</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 6/26/20 2:35 PM, enh via Toybox wrote:<br>
> toybox patch fails to apply the patch<br>
> <a href="https://android.googlesource.com/platform/external/snakeyaml/+/refs/heads/master/src/patches/android/Representer.patch" rel="noreferrer" target="_blank">https://android.googlesource.com/platform/external/snakeyaml/+/refs/heads/master/src/patches/android/Representer.patch</a><br>
<br>
That's html, I clicked the ".txt" link at the bottom and it downloaded a block<br>
of "Zy95YW1sL3NuYWtleWFtbC9yZXByZXNlbnRlci9SZXByZXNlbnRlci5qYXZhCkBAIC0xNSw3"<br>
which I don't recognize the encoding of?<br>
<br>
$ file Representer.txt<br>
Representer.txt: ASCII text, with very long lines, with no line terminators<br>
<br>
The debian file command is editorializing, but not helpful.<br>
<br>
> to the file <a href="https://android.googlesource.com/platform/external/snakeyaml/+/refs/heads/master/src/main/java/org/yaml/snakeyaml/representer/Representer.java" rel="noreferrer" target="_blank">https://android.googlesource.com/platform/external/snakeyaml/+/refs/heads/master/src/main/java/org/yaml/snakeyaml/representer/Representer.java</a>.<br>
<br>
Could you send me the two files?<br></blockquote><div><br></div><div>attached.</div><div><br></div><div>note that when you're finding gittiles unhelpful (which, let's face it, it usually is), you can just chop the first part off the URL and `git clone`. so here, for example, `git clone <a href="https://android.googlesource.com/platform/external/snakeyaml/`">https://android.googlesource.com/platform/external/snakeyaml/`</a> will check out this single git project, which isn't very large.</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">
> the worst part is that it _thinks_ it succeeds :-(<br>
> <br>
> the interesting bit happens when we come to apply this hunk:<br>
> <br>
> @@ -15,7 +15,6 @@<br>
> */<br>
> package org.yaml.snakeyaml.representer;<br>
> <br>
> -import java.beans.IntrospectionException;<br>
> import java.util.ArrayList;<br>
> import java.util.Arrays;<br>
> import java.util.Iterator;<br>
> <br>
> here:<br>
> <br>
> package org.yaml.snakeyaml.representer;<br>
> <br>
> import java.beans.IntrospectionException;<br>
> import java.util.ArrayList;<br>
> import java.util.Arrays;<br>
> import java.util.Collections;<br>
> import java.util.Iterator;<br>
> import java.util.List;<br>
> <br>
> the eagle-eyed human will notice that there's an extra "Collections"<br>
> in the actual file that isn't in the patch, because the patch was<br>
> actually against an older version of the source.<br>
<br>
Didn't commit 333a10f9ef59 fix this back in February? (It was supposed to...)<br>
<br>
> the bug is that toybox drops that new line in its output.<br>
> <br>
> it reads it:<br>
> <br>
> MAYBE:<br>
> IN: import java.beans.IntrospectionException;<br>
> MAYBE: -import java.beans.IntrospectionException;<br>
> IN: import java.util.ArrayList;<br>
> MAYBE: import java.util.ArrayList;<br>
> IN: import java.util.Arrays;<br>
> MAYBE: import java.util.Arrays;<br>
> IN: import java.util.Collections;<br>
> FUZZED: 21 import java.util.Iterator;<br>
> <br>
> but then it does a `goto fuzzed` and explicitly drops that line it<br>
> just read. which is clearly wrong here, but the code comment<br>
> explicitly calls out this behavior:<br>
> <br>
> // If match failed, flush first line of buffered data and<br>
> // recheck buffered data for a new match until we find one or run<br>
> // out of buffer.<br>
<br>
That's leading data. The idea was if you're matching<br>
<br>
@@<br>
abc<br>
- def<br>
ghi<br>
<br>
And the data says:<br>
<br>
abc<br>
abc<br>
def<br>
ghi<br>
<br>
It shouldn't see the first abc, read in the second abc and go "nope, that's not<br>
def" and then discard _both_ before checking again. (It has to advance _one_<br>
line and try again, thus checking at every possible offset, including rechecking<br>
the data it's already buffered because it thought it might be a later part of<br>
the hunk under consideration. The actual _start_ of the hunk might be in that<br>
mismatched later part it's already read in.)<br>
<br>
> so i'm not quite sure i understand the intended logic here. when would<br>
> you ever want to drop an input line that doesn't have a '-' or '+'<br>
> line in the hunk?<br>
<br>
Can you send me the test files? (I can try to put together a test from what<br>
you've sent me, but I'd rather have the real one.)<br>
<br>
Thanks,<br>
<br>
Rob<br>
</blockquote></div></div>