diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-01-23 05:13:15 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-01-23 05:13:15 +0100 |
| commit | eb5091070f6876993d868d2b2bb49b4b4d3ed002 (patch) | |
| tree | fd8633a0b0379c4932012a6625499994b0b2dd63 | |
| parent | c7e47cf6273830a59f5d3f822e4a6855a80312c6 (diff) | |
| download | busybox-w32-eb5091070f6876993d868d2b2bb49b4b4d3ed002.tar.gz busybox-w32-eb5091070f6876993d868d2b2bb49b4b4d3ed002.tar.bz2 busybox-w32-eb5091070f6876993d868d2b2bb49b4b4d3ed002.zip | |
patch: correctly handle "patch FILE_TO_PATCH" form. Closes 7736
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | editors/patch.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/editors/patch.c b/editors/patch.c index cb25e4140..988021d77 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
| @@ -372,10 +372,6 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
| 372 | xmove_fd(xopen_stdin(argv[1]), STDIN_FILENO); | 372 | xmove_fd(xopen_stdin(argv[1]), STDIN_FILENO); |
| 373 | } | 373 | } |
| 374 | } | 374 | } |
| 375 | if (argv[0]) { | ||
| 376 | oldname = xstrdup(argv[0]); | ||
| 377 | newname = xstrdup(argv[0]); | ||
| 378 | } | ||
| 379 | 375 | ||
| 380 | // Loop through the lines in the patch | 376 | // Loop through the lines in the patch |
| 381 | for(;;) { | 377 | for(;;) { |
| @@ -486,10 +482,10 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
| 486 | // or if new hunk is empty (zero context) after patching | 482 | // or if new hunk is empty (zero context) after patching |
| 487 | if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) { | 483 | if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) { |
| 488 | name = reverse ? newname : oldname; | 484 | name = reverse ? newname : oldname; |
| 489 | empty++; | 485 | empty = 1; |
| 490 | } | 486 | } |
| 491 | 487 | ||
| 492 | // handle -p path truncation. | 488 | // Handle -p path truncation. |
| 493 | for (i = 0, s = name; *s;) { | 489 | for (i = 0, s = name; *s;) { |
| 494 | if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) | 490 | if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) |
| 495 | break; | 491 | break; |
| @@ -500,6 +496,9 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
| 500 | i++; | 496 | i++; |
| 501 | name = s; | 497 | name = s; |
| 502 | } | 498 | } |
| 499 | // If "patch FILE_TO_PATCH", completely ignore name from patch | ||
| 500 | if (argv[0]) | ||
| 501 | name = argv[0]; | ||
| 503 | 502 | ||
| 504 | if (empty) { | 503 | if (empty) { |
| 505 | // File is empty after the patches have been applied | 504 | // File is empty after the patches have been applied |
