diff options
author | Rob Landley <rob@landley.net> | 2011-08-22 04:58:32 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-08-22 04:58:32 +0200 |
commit | c5f7847659ccddd27c99b300e01f36516326aa3a (patch) | |
tree | 408e1a46ee4fb273ea385824583ac73ef7f24c9b | |
parent | 251fc70e9722f931eec23a34030d05ba5f747b0e (diff) | |
download | busybox-w32-c5f7847659ccddd27c99b300e01f36516326aa3a.tar.gz busybox-w32-c5f7847659ccddd27c99b300e01f36516326aa3a.tar.bz2 busybox-w32-c5f7847659ccddd27c99b300e01f36516326aa3a.zip |
patch: make it able to create files (again)
I broke patch's ability to create files in November, and nobody noticed in
the ensuing 11 months. Sigh.
Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/patch.c | 8 | ||||
-rwxr-xr-x | testsuite/patch.tests | 1 |
2 files changed, 3 insertions, 6 deletions
diff --git a/editors/patch.c b/editors/patch.c index ec5b8e7ad..1f2a49b66 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. |
73 | static | 73 | static void dlist_free(struct double_list *list, void (*freeit)(void *data)) |
74 | void 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 |
86 | static | 85 | static struct double_list *dlist_add(struct double_list **list, char *data) |
87 | struct 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 | ||
diff --git a/testsuite/patch.tests b/testsuite/patch.tests index 7cd716ce5..8caeed5bd 100755 --- a/testsuite/patch.tests +++ b/testsuite/patch.tests | |||
@@ -212,7 +212,6 @@ patching file input | |||
212 | 666 | 212 | 666 |
213 | " \ | 213 | " \ |
214 | 214 | ||
215 | # Currently fails | ||
216 | # testing "test name" "command(s)" "expected result" "file input" "stdin" | 215 | # testing "test name" "command(s)" "expected result" "file input" "stdin" |
217 | testing "patch creates new file" \ | 216 | testing "patch creates new file" \ |
218 | 'patch 2>&1; echo $?; cat testfile; rm testfile' \ | 217 | 'patch 2>&1; echo $?; cat testfile; rm testfile' \ |