/* vi: set sw=4 ts=4: */
/*
- * busybox patch applet to handle the unified diff format.
- * Copyright (C) 2003 Glenn McGrath
+ * busybox patch applet to handle the unified diff format.
+ * Copyright (C) 2003 Glenn McGrath
*
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*
- * This applet is written to work with patches generated by GNU diff,
- * where there is equivalent functionality busybox patch shall behave
- * as per GNU patch.
+ * This applet is written to work with patches generated by GNU diff,
+ * where there is equivalent functionality busybox patch shall behave
+ * as per GNU patch.
*
- * There is a SUSv3 specification for patch, however it looks to be
- * incomplete, it doesnt even mention unified diff format.
- * http://www.opengroup.org/onlinepubs/007904975/utilities/patch.html
+ * There is a SUSv3 specification for patch, however it looks to be
+ * incomplete, it doesnt even mention unified diff format.
+ * http://www.opengroup.org/onlinepubs/007904975/utilities/patch.html
*
- * Issues
- * - Non-interactive
- * - Patches must apply cleanly or patch (not just one hunk) will fail.
- * - Reject file isnt saved
+ * Issues
+ * - Non-interactive
+ * - Patches must apply cleanly or patch (not just one hunk) will fail.
+ * - Reject file isnt saved
*/
#include "libbb.h"
"no-backup-if-mismatch\0" No_argument "\xff" /*ignored*/
# endif
;
- applet_long_options = patch_longopts;
#endif
/* -f,-E,-g are ignored */
- opt = getopt32(argv, "p:i:RN""fEg:", &p, &i, NULL);
+ opt = getopt32long(argv, "p:i:RN""fEg:", patch_longopts, &p, &i, NULL);
if (opt & OPT_R)
plus = '-';
patch_level = xatoi(p); /* can be negative! */
unsigned src_last_line = 1;
unsigned dst_last_line = 1;
- if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
- && (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
+ if ((sscanf(patch_line, "@@ -%u,%u +%u,%u", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
+ && (sscanf(patch_line, "@@ -%u +%u,%u", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
) {
/* No more hunks for this file */
break;