aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-17 01:31:40 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-17 01:31:40 +0200
commitcda815996b92edec880943a11fe8f9e33c1ad904 (patch)
tree61a03cf608760e87371081b6f212f5d9fb95d80e
parentbdaea46318e4fe10b3fe4b20345baff2e1d69afc (diff)
downloadbusybox-w32-cda815996b92edec880943a11fe8f9e33c1ad904.tar.gz
busybox-w32-cda815996b92edec880943a11fe8f9e33c1ad904.tar.bz2
busybox-w32-cda815996b92edec880943a11fe8f9e33c1ad904.zip
patch: fix -N regression
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/patch.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/editors/patch.c b/editors/patch.c
index eb16bca12..3ed4eba45 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -12,7 +12,6 @@
12 * TODO: 12 * TODO:
13 * -b backup 13 * -b backup
14 * -l treat all whitespace as a single space 14 * -l treat all whitespace as a single space
15 * -N ignore already applied
16 * -d chdir first 15 * -d chdir first
17 * -D define wrap #ifdef and #ifndef around changes 16 * -D define wrap #ifdef and #ifndef around changes
18 * -o outfile output here instead of in place 17 * -o outfile output here instead of in place
@@ -244,14 +243,12 @@ struct globals {
244} while (0) 243} while (0)
245 244
246 245
247//bbox had: "p:i:RN"
248#define FLAG_STR "Rup:i:Nx" 246#define FLAG_STR "Rup:i:Nx"
249/* FLAG_REVERSE must be == 1! Code uses this fact. */ 247/* FLAG_REVERSE must be == 1! Code uses this fact. */
250#define FLAG_REVERSE (1 << 0) 248#define FLAG_REVERSE (1 << 0)
251#define FLAG_u (1 << 1) 249#define FLAG_u (1 << 1)
252#define FLAG_PATHLEN (1 << 2) 250#define FLAG_PATHLEN (1 << 2)
253#define FLAG_INPUT (1 << 3) 251#define FLAG_INPUT (1 << 3)
254// -N: not supported yet
255#define FLAG_IGNORE (1 << 4) 252#define FLAG_IGNORE (1 << 4)
256//non-standard: 253//non-standard:
257#define FLAG_DEBUG (1 << 5) 254#define FLAG_DEBUG (1 << 5)
@@ -314,6 +311,10 @@ static int apply_one_hunk(void)
314{ 311{
315 struct double_list *plist, *buf = NULL, *check; 312 struct double_list *plist, *buf = NULL, *check;
316 int matcheof = 0, reverse = option_mask32 & FLAG_REVERSE, backwarn = 0; 313 int matcheof = 0, reverse = option_mask32 & FLAG_REVERSE, backwarn = 0;
314 /* Do we try "dummy" revert to check whether
315 * to silently skip this hunk? Used to implement -N.
316 */
317 int dummy_revert = 0;
317 318
318 // Break doubly linked list so we can use singly linked traversal function. 319 // Break doubly linked list so we can use singly linked traversal function.
319 TT.current_hunk->prev->next = NULL; 320 TT.current_hunk->prev->next = NULL;
@@ -343,9 +344,14 @@ static int apply_one_hunk(void)
343 while (plist && *plist->data == "+-"[reverse]) { 344 while (plist && *plist->data == "+-"[reverse]) {
344 if (data && !strcmp(data, plist->data+1)) { 345 if (data && !strcmp(data, plist->data+1)) {
345 if (!backwarn) { 346 if (!backwarn) {
347 backwarn++;
348 if (option_mask32 & FLAG_IGNORE) {
349 dummy_revert = 1;
350 reverse ^= 1;
351 continue;
352 }
346 fdprintf(2,"Possibly reversed hunk %d at %ld\n", 353 fdprintf(2,"Possibly reversed hunk %d at %ld\n",
347 TT.hunknum, TT.linenum); 354 TT.hunknum, TT.linenum);
348 backwarn++;
349 } 355 }
350 } 356 }
351 plist = plist->next; 357 plist = plist->next;
@@ -409,7 +415,7 @@ static int apply_one_hunk(void)
409 } 415 }
410out: 416out:
411 // We have a match. Emit changed data. 417 // We have a match. Emit changed data.
412 TT.state = "-+"[reverse]; 418 TT.state = "-+"[reverse ^ dummy_revert];
413 llist_free(TT.current_hunk, do_line); 419 llist_free(TT.current_hunk, do_line);
414 TT.current_hunk = NULL; 420 TT.current_hunk = NULL;
415 TT.state = 1; 421 TT.state = 1;