# HG changeset patch # User Rob Landley # Date 1404013660 18000 # Node ID 0a87952492aee93efc9812025c1c357bef5fdabe # Parent e2b84f715e938df8a7c1641d99ca65dc1b5c5133 Use dlist_terminate() in patch. diff -r e2b84f715e93 -r 0a87952492ae toys/posix/patch.c --- a/toys/posix/patch.c Sat Jun 28 22:36:02 2014 -0500 +++ b/toys/posix/patch.c Sat Jun 28 22:47:40 2014 -0500 @@ -93,7 +93,7 @@ static void fail_hunk(void) { if (!TT.current_hunk) return; - TT.current_hunk->prev->next = 0; + dlist_terminate(TT.current_hunk); fprintf(stderr, "Hunk %d FAILED %ld/%ld.\n", TT.hunknum, TT.oldline, TT.newline); @@ -138,8 +138,7 @@ lcmp = (toys.optflags & FLAG_l) ? (void *)loosecmp : (void *)strcmp; - // Break doubly linked list so we can use singly linked traversal function. - TT.current_hunk->prev->next = NULL; + dlist_terminate(TT.current_hunk); // Match EOF if there aren't as many ending context lines as beginning for (plist = TT.current_hunk; plist; plist = plist->next) { @@ -235,7 +234,7 @@ TT.state = 1; done: if (buf) { - buf->prev->next = NULL; + dlist_terminate(buf); llist_traverse(buf, do_line); }