* busybox patch applet to handle the unified diff format.
* Copyright (C) 2003 Glenn McGrath <bug1@iinet.net.au>
*
- * Licensed under the GPL v2, see the file LICENSE in this tarball.
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*
* This applet is written to work with patches generated by GNU diff,
* where there is equivalent functionality busybox patch shall behave
#include <unistd.h>
#include "busybox.h"
-static int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int lines_count)
+static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int lines_count)
{
- int i = 0;
+ unsigned int i = 0;
while (src_stream && (i < lines_count)) {
char *line;
* returns malloc'ed filename
*/
-static unsigned char *extract_filename(char *line, unsigned short patch_level)
+static char *extract_filename(char *line, int patch_level)
{
char *filename_start_ptr = line + 4;
int i;
return(stat(filename, &statbuf));
}
-extern int patch_main(int argc, char **argv)
+int patch_main(int argc, char **argv)
{
- unsigned int patch_level = -1;
+ int patch_level = -1;
char *patch_line;
int ret;
FILE *patch_file = NULL;
char *p, *i;
ret = bb_getopt_ulflags(argc, argv, "p:i:", &p, &i);
if (ret & 1)
- patch_level = atoi(p);
+ patch_level = bb_xgetlarg(p, 10, -1, USHRT_MAX);
if (ret & 2) {
patch_file = bb_xfopen(i, "r");
} else {