diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-20 23:33:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-20 23:33:19 +0200 |
commit | d7874ed1d498454b3c7342f9e6df0aacb9873186 (patch) | |
tree | 424e75417b35ccd42cfcfb6ce9c0e519f8dd9c2f /editors | |
parent | 0793491ff884bbb70b51c2b05c42d5dad60bcc5f (diff) | |
download | busybox-w32-d7874ed1d498454b3c7342f9e6df0aacb9873186.tar.gz busybox-w32-d7874ed1d498454b3c7342f9e6df0aacb9873186.tar.bz2 busybox-w32-d7874ed1d498454b3c7342f9e6df0aacb9873186.zip |
patch: support -N. By Olivier Duclos (olivier.duclos AT gmail.com)
function old new delta
packed_usage 26646 26656 +10
patch_main 1101 1110 +9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/patch.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/editors/patch.c b/editors/patch.c index e8482a7a9..4a9715144 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -74,12 +74,18 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
74 | int patch_level; | 74 | int patch_level; |
75 | int ret = 0; | 75 | int ret = 0; |
76 | char plus = '+'; | 76 | char plus = '+'; |
77 | unsigned opt; | ||
78 | enum { | ||
79 | OPT_R = (1 << 2), | ||
80 | OPT_N = (1 << 3), | ||
81 | }; | ||
77 | 82 | ||
78 | xfunc_error_retval = 2; | 83 | xfunc_error_retval = 2; |
79 | { | 84 | { |
80 | const char *p = "-1"; | 85 | const char *p = "-1"; |
81 | const char *i = "-"; /* compat */ | 86 | const char *i = "-"; /* compat */ |
82 | if (getopt32(argv, "p:i:R", &p, &i) & 4) | 87 | opt = getopt32(argv, "p:i:RN", &p, &i); |
88 | if (opt & OPT_R) | ||
83 | plus = '-'; | 89 | plus = '-'; |
84 | patch_level = xatoi(p); /* can be negative! */ | 90 | patch_level = xatoi(p); /* can be negative! */ |
85 | patch_file = xfopen_stdin(i); | 91 | patch_file = xfopen_stdin(i); |
@@ -202,6 +208,10 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
202 | src_line = NULL; | 208 | src_line = NULL; |
203 | } | 209 | } |
204 | } | 210 | } |
211 | /* Do not patch an already patched hunk with -N */ | ||
212 | if (src_line == 0 && (opt & OPT_N)) { | ||
213 | continue; | ||
214 | } | ||
205 | if (!src_line) { | 215 | if (!src_line) { |
206 | bb_error_msg("hunk #%u FAILED at %u", hunk_count, hunk_offset_start); | 216 | bb_error_msg("hunk #%u FAILED at %u", hunk_count, hunk_offset_start); |
207 | bad_hunk_count++; | 217 | bad_hunk_count++; |