diff options
Diffstat (limited to 'editors/patch.c')
-rw-r--r-- | editors/patch.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/editors/patch.c b/editors/patch.c index c40f54155..66a9474fe 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -344,14 +344,12 @@ static int apply_one_hunk(void) | |||
344 | while (plist && *plist->data == "+-"[reverse]) { | 344 | while (plist && *plist->data == "+-"[reverse]) { |
345 | if (data && !strcmp(data, plist->data+1)) { | 345 | if (data && !strcmp(data, plist->data+1)) { |
346 | if (!backwarn) { | 346 | if (!backwarn) { |
347 | backwarn++; | 347 | backwarn = TT.linenum; |
348 | if (option_mask32 & FLAG_IGNORE) { | 348 | if (option_mask32 & FLAG_IGNORE) { |
349 | dummy_revert = 1; | 349 | dummy_revert = 1; |
350 | reverse ^= 1; | 350 | reverse ^= 1; |
351 | continue; | 351 | continue; |
352 | } | 352 | } |
353 | fdprintf(2,"Possibly reversed hunk %d at %ld\n", | ||
354 | TT.hunknum, TT.linenum); | ||
355 | } | 353 | } |
356 | } | 354 | } |
357 | plist = plist->next; | 355 | plist = plist->next; |
@@ -364,6 +362,10 @@ static int apply_one_hunk(void) | |||
364 | // Does this hunk need to match EOF? | 362 | // Does this hunk need to match EOF? |
365 | if (!plist && matcheof) break; | 363 | if (!plist && matcheof) break; |
366 | 364 | ||
365 | if (backwarn) | ||
366 | fdprintf(2,"Possibly reversed hunk %d at %ld\n", | ||
367 | TT.hunknum, TT.linenum); | ||
368 | |||
367 | // File ended before we found a place for this hunk. | 369 | // File ended before we found a place for this hunk. |
368 | fail_hunk(); | 370 | fail_hunk(); |
369 | goto done; | 371 | goto done; |
@@ -552,7 +554,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
552 | int oldsum, newsum, del = 0; | 554 | int oldsum, newsum, del = 0; |
553 | char *name; | 555 | char *name; |
554 | 556 | ||
555 | oldsum = TT.oldline + TT.oldlen; | 557 | oldsum = TT.oldline + TT.oldlen; |
556 | newsum = TT.newline + TT.newlen; | 558 | newsum = TT.newline + TT.newlen; |
557 | 559 | ||
558 | name = reverse ? oldname : newname; | 560 | name = reverse ? oldname : newname; |
@@ -589,10 +591,10 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
589 | xmkpath(name, -1); | 591 | xmkpath(name, -1); |
590 | *s = '/'; | 592 | *s = '/'; |
591 | } | 593 | } |
592 | TT.filein = xopen3(name, O_CREAT|O_EXCL|O_RDWR, 0666); | 594 | TT.filein = xopen(name, O_CREAT|O_EXCL|O_RDWR); |
593 | } else { | 595 | } else { |
594 | printf("patching file %s\n", name); | 596 | printf("patching file %s\n", name); |
595 | TT.filein = xopen(name, O_RDWR); | 597 | TT.filein = xopen(name, O_RDONLY); |
596 | } | 598 | } |
597 | TT.fileout = copy_tempfile(TT.filein, name, &TT.tempname); | 599 | TT.fileout = copy_tempfile(TT.filein, name, &TT.tempname); |
598 | TT.linenum = 0; | 600 | TT.linenum = 0; |