// Free all the elements of a linked list
// Call freeit() on each element before freeing it.
-static
-void dlist_free(struct double_list *list, void (*freeit)(void *data))
+static void dlist_free(struct double_list *list, void (*freeit)(void *data))
{
while (list) {
void *pop = list;
}
// Add an entry before "list" element in (circular) doubly linked list
-static
-struct double_list *dlist_add(struct double_list **list, char *data)
+static struct double_list *dlist_add(struct double_list **list, char *data)
{
struct double_list *llist;
struct double_list *line = xmalloc(sizeof(*line));
else matcheof = 0;
if (PATCH_DEBUG) fdprintf(2, "HUNK:%s\n", plist->data);
}
- matcheof = matcheof < TT.context;
+ matcheof = !matcheof || matcheof < TT.context;
if (PATCH_DEBUG) fdprintf(2,"MATCHEOF=%c\n", matcheof ? 'Y' : 'N');
// We're deleting oldname if new file is /dev/null (before -p)
// or if new hunk is empty (zero context) after patching
- if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum))
- {
+ if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) {
name = reverse ? newname : oldname;
empty++;
}
// handle -p path truncation.
- for (i=0, s = name; *s;) {
- if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) break;
- if (*(s++)=='/') {
- name = s;
- i++;
- }
+ for (i = 0, s = name; *s;) {
+ if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i)
+ break;
+ if (*s++ != '/')
+ continue;
+ while (*s == '/')
+ s++;
+ i++;
+ name = s;
}
if (empty) {