changeset 1371:0a87952492ae draft

Use dlist_terminate() in patch.
author Rob Landley <rob@landley.net>
date Sat, 28 Jun 2014 22:47:40 -0500
parents e2b84f715e93
children d46baa9adb5f
files toys/posix/patch.c
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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);
   }