diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-21 00:42:15 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-21 00:42:15 +0200 |
commit | e7599d1cc7885017fa53955e257af248d183f2e3 (patch) | |
tree | b07aaf83baa475d002e96adfa84c6fd0747b3077 | |
parent | f0c7e0c8d53fc1cbbccf0b23c5e5242a9707c6e3 (diff) | |
download | busybox-w32-e7599d1cc7885017fa53955e257af248d183f2e3.tar.gz busybox-w32-e7599d1cc7885017fa53955e257af248d183f2e3.tar.bz2 busybox-w32-e7599d1cc7885017fa53955e257af248d183f2e3.zip |
revert last change (wrong author)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/patch.c | 25 | ||||
-rw-r--r-- | include/usage.src.h | 12 |
2 files changed, 14 insertions, 23 deletions
diff --git a/editors/patch.c b/editors/patch.c index fff06907f..66a9474fe 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * -o outfile output here instead of in place | 17 | * -o outfile output here instead of in place |
18 | * -r rejectfile write rejected hunks to this file | 18 | * -r rejectfile write rejected hunks to this file |
19 | * | 19 | * |
20 | * -E remove empty files --remove-empty-files | ||
20 | * -f force (no questions asked) | 21 | * -f force (no questions asked) |
21 | * -F fuzz (number, default 2) | 22 | * -F fuzz (number, default 2) |
22 | * [file] which file to patch | 23 | * [file] which file to patch |
@@ -41,7 +42,7 @@ config PATCH | |||
41 | hunks to stderr, and exits with nonzero status if any hunks fail. | 42 | hunks to stderr, and exits with nonzero status if any hunks fail. |
42 | 43 | ||
43 | A file compared against /dev/null (or with a date <= the epoch) is | 44 | A file compared against /dev/null (or with a date <= the epoch) is |
44 | created or deleted if -E or --remove-empty-files set. | 45 | created/deleted as appropriate. |
45 | */ | 46 | */ |
46 | #include "libbb.h" | 47 | #include "libbb.h" |
47 | 48 | ||
@@ -242,16 +243,15 @@ struct globals { | |||
242 | } while (0) | 243 | } while (0) |
243 | 244 | ||
244 | 245 | ||
245 | #define FLAG_STR "Rup:i:NEx" | 246 | #define FLAG_STR "Rup:i:Nx" |
246 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ | 247 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ |
247 | #define FLAG_REVERSE (1 << 0) | 248 | #define FLAG_REVERSE (1 << 0) |
248 | #define FLAG_u (1 << 1) | 249 | #define FLAG_u (1 << 1) |
249 | #define FLAG_PATHLEN (1 << 2) | 250 | #define FLAG_PATHLEN (1 << 2) |
250 | #define FLAG_INPUT (1 << 3) | 251 | #define FLAG_INPUT (1 << 3) |
251 | #define FLAG_IGNORE (1 << 4) | 252 | #define FLAG_IGNORE (1 << 4) |
252 | #define FLAG_RMEMPTY (1 << 5) | ||
253 | //non-standard: | 253 | //non-standard: |
254 | #define FLAG_DEBUG (1 << 6) | 254 | #define FLAG_DEBUG (1 << 5) |
255 | 255 | ||
256 | // Dispose of a line of input, either by writing it out or discarding it. | 256 | // Dispose of a line of input, either by writing it out or discarding it. |
257 | 257 | ||
@@ -551,7 +551,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
551 | 551 | ||
552 | // If this is the first hunk, open the file. | 552 | // If this is the first hunk, open the file. |
553 | if (TT.filein == -1) { | 553 | if (TT.filein == -1) { |
554 | int oldsum, newsum, empty = 0; | 554 | int oldsum, newsum, del = 0; |
555 | char *name; | 555 | char *name; |
556 | 556 | ||
557 | oldsum = TT.oldline + TT.oldlen; | 557 | oldsum = TT.oldline + TT.oldlen; |
@@ -564,7 +564,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
564 | if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) | 564 | if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) |
565 | { | 565 | { |
566 | name = reverse ? newname : oldname; | 566 | name = reverse ? newname : oldname; |
567 | empty++; | 567 | del++; |
568 | } | 568 | } |
569 | 569 | ||
570 | // handle -p path truncation. | 570 | // handle -p path truncation. |
@@ -576,17 +576,10 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | if (empty) { | 579 | if (del) { |
580 | // File is empty after the patches have been applied | 580 | printf("removing %s\n", name); |
581 | xunlink(name); | ||
581 | state = 0; | 582 | state = 0; |
582 | if (option_mask32 & FLAG_RMEMPTY) { | ||
583 | // If flag -E or --remove-empty-files is set | ||
584 | printf("removing %s\n", name); | ||
585 | xunlink(name); | ||
586 | } else { | ||
587 | printf("patching file %s\n", name); | ||
588 | xclose(xopen(name, O_WRONLY | O_TRUNC)); | ||
589 | } | ||
590 | // If we've got a file to open, do so. | 583 | // If we've got a file to open, do so. |
591 | } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) { | 584 | } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) { |
592 | // If the old file was null, we're creating a new one. | 585 | // If the old file was null, we're creating a new one. |
diff --git a/include/usage.src.h b/include/usage.src.h index f5ddd7ba5..2445c1b9b 100644 --- a/include/usage.src.h +++ b/include/usage.src.h | |||
@@ -2857,19 +2857,17 @@ INSERT | |||
2857 | "[OPTIONS] [ORIGFILE [PATCHFILE]]" | 2857 | "[OPTIONS] [ORIGFILE [PATCHFILE]]" |
2858 | #define patch_full_usage "\n\n" \ | 2858 | #define patch_full_usage "\n\n" \ |
2859 | IF_LONG_OPTS( \ | 2859 | IF_LONG_OPTS( \ |
2860 | " -p,--strip N Strip N leading components from file names" \ | 2860 | " -p,--strip N Strip N leading components from file names" \ |
2861 | "\n -i,--input DIFF Read DIFF instead of stdin" \ | 2861 | "\n -i,--input DIFF Read DIFF instead of stdin" \ |
2862 | "\n -R,--reverse Reverse patch" \ | 2862 | "\n -R,--reverse Reverse patch" \ |
2863 | "\n -N,--forward Ignore already applied patches" \ | 2863 | "\n -N,--forward Ignore already applied patches" \ |
2864 | "\n --dry-run Don't actually change files" \ | 2864 | "\n --dry-run Don't actually change files" \ |
2865 | "\n -E,--remove-empty-files Remove output files if they become empty" \ | ||
2866 | ) \ | 2865 | ) \ |
2867 | IF_NOT_LONG_OPTS( \ | 2866 | IF_NOT_LONG_OPTS( \ |
2868 | " -p N Strip N leading components from file names" \ | 2867 | " -p N Strip N leading components from file names" \ |
2869 | "\n -i DIFF Read DIFF instead of stdin" \ | 2868 | "\n -i DIFF Read DIFF instead of stdin" \ |
2870 | "\n -R Reverse patch" \ | 2869 | "\n -R Reverse patch" \ |
2871 | "\n -N Ignore already applied patches" \ | 2870 | "\n -N Ignore already applied patches" \ |
2872 | "\n -E Remove output files if they become empty" \ | ||
2873 | ) | 2871 | ) |
2874 | 2872 | ||
2875 | #define patch_example_usage \ | 2873 | #define patch_example_usage \ |