From bdf037ff5e1b933d624ac74c62c5c1eb14464737 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 23 Oct 2008 16:44:30 -0500 Subject: Upgrade patch to detect hunks that start after a false start. Imagine a hunk that starts with a blank line, but the site to patch starts with two blank lines. Before we'd read the first blank line, think it was the start of the hunk and buffer it, read the second blank line, notice that it didn't match the second line of the hunk, and discard _both_ buffered lines of context (writing them to the output file) without checking that one of the later context lines might have been the real start of the hunk. Make it re-check the rest of the buffered context for matches each time it discards a line of buffered context. --- lib/llist.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/llist.c') diff --git a/lib/llist.c b/lib/llist.c index 4f9bc220..9adb64e0 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -14,6 +14,10 @@ void llist_free(void *list, void (*freeit)(void *data)) while (list) { void *pop = llist_pop(&list); if (freeit) freeit(pop); + else free(pop); + + // End doubly linked list too. + if (list==pop) break; } } @@ -32,7 +36,7 @@ void *llist_pop(void *list) } // Add an entry to the end off a doubly linked list -void dlist_add(struct double_list **list, char *data) +struct double_list *dlist_add(struct double_list **list, char *data) { struct double_list *line = xmalloc(sizeof(struct double_list)); @@ -43,4 +47,6 @@ void dlist_add(struct double_list **list, char *data) (*list)->prev->next = line; (*list)->prev = line; } else *list = line->next = line->prev = line; + + return line; } -- cgit v1.2.3