aboutsummaryrefslogtreecommitdiff
path: root/editors/patch.c
diff options
context:
space:
mode:
Diffstat (limited to 'editors/patch.c')
-rw-r--r--editors/patch.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/editors/patch.c b/editors/patch.c
index ec5b8e7ad..13785ef46 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -70,8 +70,7 @@ struct double_list {
70 70
71// Free all the elements of a linked list 71// Free all the elements of a linked list
72// Call freeit() on each element before freeing it. 72// Call freeit() on each element before freeing it.
73static 73static void dlist_free(struct double_list *list, void (*freeit)(void *data))
74void dlist_free(struct double_list *list, void (*freeit)(void *data))
75{ 74{
76 while (list) { 75 while (list) {
77 void *pop = list; 76 void *pop = list;
@@ -83,8 +82,7 @@ void dlist_free(struct double_list *list, void (*freeit)(void *data))
83} 82}
84 83
85// Add an entry before "list" element in (circular) doubly linked list 84// Add an entry before "list" element in (circular) doubly linked list
86static 85static struct double_list *dlist_add(struct double_list **list, char *data)
87struct double_list *dlist_add(struct double_list **list, char *data)
88{ 86{
89 struct double_list *llist; 87 struct double_list *llist;
90 struct double_list *line = xmalloc(sizeof(*line)); 88 struct double_list *line = xmalloc(sizeof(*line));
@@ -232,7 +230,7 @@ static int apply_one_hunk(void)
232 else matcheof = 0; 230 else matcheof = 0;
233 if (PATCH_DEBUG) fdprintf(2, "HUNK:%s\n", plist->data); 231 if (PATCH_DEBUG) fdprintf(2, "HUNK:%s\n", plist->data);
234 } 232 }
235 matcheof = matcheof < TT.context; 233 matcheof = !matcheof || matcheof < TT.context;
236 234
237 if (PATCH_DEBUG) fdprintf(2,"MATCHEOF=%c\n", matcheof ? 'Y' : 'N'); 235 if (PATCH_DEBUG) fdprintf(2,"MATCHEOF=%c\n", matcheof ? 'Y' : 'N');
238 236
@@ -476,19 +474,21 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
476 474
477 // We're deleting oldname if new file is /dev/null (before -p) 475 // We're deleting oldname if new file is /dev/null (before -p)
478 // or if new hunk is empty (zero context) after patching 476 // or if new hunk is empty (zero context) after patching
479 if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) 477 if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) {
480 {
481 name = reverse ? newname : oldname; 478 name = reverse ? newname : oldname;
482 empty++; 479 empty++;
483 } 480 }
484 481
485 // handle -p path truncation. 482 // handle -p path truncation.
486 for (i=0, s = name; *s;) { 483 for (i = 0, s = name; *s;) {
487 if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) break; 484 if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i)
488 if (*(s++)=='/') { 485 break;
489 name = s; 486 if (*s++ != '/')
490 i++; 487 continue;
491 } 488 while (*s == '/')
489 s++;
490 i++;
491 name = s;
492 } 492 }
493 493
494 if (empty) { 494 if (empty) {