Mercurial > hg > toybox
changeset 1060:c2663b7eca78 draft
Adjust patch to use dlist_pop()
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 09 Sep 2013 05:26:52 -0500 |
parents | ef72a16f4b3a |
children | ed2694ccf2ae |
files | lib/llist.c scripts/test/test.test toys/posix/patch.c |
diffstat | 3 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/llist.c Mon Sep 09 04:26:03 2013 -0500 +++ b/lib/llist.c Mon Sep 09 05:26:52 2013 -0500 @@ -37,8 +37,11 @@ { struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist; - dlist->next->prev = dlist->prev; - dlist->prev->next = *pdlist = dlist->next; + if (dlist->next == dlist) *pdlist = 0; + else { + dlist->next->prev = dlist->prev; + dlist->prev->next = *pdlist = dlist->next; + } return dlist; }
--- a/scripts/test/test.test Mon Sep 09 04:26:03 2013 -0500 +++ b/scripts/test/test.test Mon Sep 09 05:26:52 2013 -0500 @@ -61,3 +61,7 @@ testing "test -ge" "arith_test -ge" "e\ng\n" "" "" testing "test -lt" "arith_test -lt" "l\n" "" "" testing "test -le" "arith_test -le" "l\ne\n" "" "" + +# test ! = -o a +# test ! \( = -o a \) +# test \( ! = \) -o a
--- a/toys/posix/patch.c Mon Sep 09 04:26:03 2013 -0500 +++ b/toys/posix/patch.c Mon Sep 09 05:26:52 2013 -0500 @@ -204,18 +204,12 @@ if (PATCH_DEBUG) fprintf(stderr, "NOT: %s\n", plist->data); TT.state = 3; - check = llist_pop(&buf); - check->prev->next = buf; - buf->prev = check->prev; - do_line(check); + do_line(check = dlist_pop(&buf)); plist = TT.current_hunk; // If we've reached the end of the buffer without confirming a // match, read more lines. - if (check==buf) { - buf = 0; - break; - } + if (!buf) break; check = buf; } else { if (PATCH_DEBUG) fprintf(stderr, "MAYBE: %s\n", plist->data);