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 /editors | |
parent | f0c7e0c8d53fc1cbbccf0b23c5e5242a9707c6e3 (diff) | |
download | busybox-e7599d1cc7885017fa53955e257af248d183f2e3.tar.gz |
revert last change (wrong author)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/patch.c | 25 |
1 files changed, 9 insertions, 16 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 @@ * -o outfile output here instead of in place * -r rejectfile write rejected hunks to this file * + * -E remove empty files --remove-empty-files * -f force (no questions asked) * -F fuzz (number, default 2) * [file] which file to patch @@ -41,7 +42,7 @@ config PATCH hunks to stderr, and exits with nonzero status if any hunks fail. A file compared against /dev/null (or with a date <= the epoch) is - created or deleted if -E or --remove-empty-files set. + created/deleted as appropriate. */ #include "libbb.h" @@ -242,16 +243,15 @@ struct globals { } while (0) -#define FLAG_STR "Rup:i:NEx" +#define FLAG_STR "Rup:i:Nx" /* FLAG_REVERSE must be == 1! Code uses this fact. */ #define FLAG_REVERSE (1 << 0) #define FLAG_u (1 << 1) #define FLAG_PATHLEN (1 << 2) #define FLAG_INPUT (1 << 3) #define FLAG_IGNORE (1 << 4) -#define FLAG_RMEMPTY (1 << 5) //non-standard: -#define FLAG_DEBUG (1 << 6) +#define FLAG_DEBUG (1 << 5) // Dispose of a line of input, either by writing it out or discarding it. @@ -551,7 +551,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) // If this is the first hunk, open the file. if (TT.filein == -1) { - int oldsum, newsum, empty = 0; + int oldsum, newsum, del = 0; char *name; oldsum = TT.oldline + TT.oldlen; @@ -564,7 +564,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) { name = reverse ? newname : oldname; - empty++; + del++; } // handle -p path truncation. @@ -576,17 +576,10 @@ int patch_main(int argc UNUSED_PARAM, char **argv) } } - if (empty) { - // File is empty after the patches have been applied + if (del) { + printf("removing %s\n", name); + xunlink(name); state = 0; - if (option_mask32 & FLAG_RMEMPTY) { - // If flag -E or --remove-empty-files is set - printf("removing %s\n", name); - xunlink(name); - } else { - printf("patching file %s\n", name); - xclose(xopen(name, O_WRONLY | O_TRUNC)); - } // If we've got a file to open, do so. } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) { // If the old file was null, we're creating a new one. |