]> git.neil.brown.name Git - wiggle.git/commitdiff
extract: allow blank lines in unified diffs.
authorNeilBrown <neilb@suse.de>
Sat, 3 Aug 2019 02:11:56 +0000 (12:11 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 3 Aug 2019 02:11:56 +0000 (12:11 +1000)
When a unified diff report that both files have a blank line,
it shows this as a line containing just a space.
Sometimes that space can go missing (spaces at the end of a line
are like that).
So if we find a completely empty line, treat it like a line
containing just a space.

Resolves-github-issue: #12
Reported-by: luckydonald @ github.com
Signed-off-by: NeilBrown <neilb@suse.de>
extract.c

index c3c47e679f486def577793a17611584a9cbcd002..ac61421fccc8a4b9b87e16bde2e4fa74dadaa9a3 100644 (file)
--- a/extract.c
+++ b/extract.c
@@ -199,6 +199,12 @@ int split_patch(struct stream f, struct stream *f1, struct stream *f2)
                                cp++;
                                copyline(&r2, &cp, end);
                                bcnt--;
+                       } else if (*cp == '\n') {
+                               /* Empty line - treat like " \n" - a blank line in both */
+                               char *cp2 = cp;
+                               copyline(&r1, &cp, end);
+                               copyline(&r2, &cp2, end);
+                               acnt --; bcnt--;
                        } else {
                                fprintf(stderr, "%s: bad unified patch at line %d\n",
                                        Cmd, lineno);