From 57b2c9057964ddb059c1d21aee824972347073a5 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 19 Aug 2023 13:07:51 -0500 Subject: [PATCH] Document -F --- toys/posix/patch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/toys/posix/patch.c b/toys/posix/patch.c index 64a8abff..6ec032bb 100644 --- a/toys/posix/patch.c +++ b/toys/posix/patch.c @@ -25,6 +25,7 @@ config PATCH Apply a unified diff to one or more files. -d Modify files in DIR + -F Fuzz factor (number of non-matching context lines allowed per hunk) -i Input patch file (default=stdin) -l Loose match (ignore whitespace) -p Number of '/' to strip from start of file paths (default=all) @@ -39,7 +40,8 @@ config PATCH 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/deleted as appropriate. + created/deleted as appropriate. The default -F value is the number of + leading/trailing context lines minus one (usually 2). */ #define FOR_patch @@ -141,7 +143,7 @@ static int loosecmp(char *aa, char *bb) static int apply_one_hunk(void) { struct double_list *plist, *buf = 0, *check = 0; - int matcheof, trail = 0, allfuzz, fuzz, ii; + int matcheof, trail = 0, allfuzz = 0, fuzz, ii; int (*lcmp)(char *aa, char *bb) = FLAG(l) ? (void *)loosecmp : (void *)strcmp; long backwarn = 0; char *data = toybuf; @@ -165,8 +167,7 @@ static int apply_one_hunk(void) } } matcheof = !trail || trail < TT.context; - if (fuzz<2) allfuzz = 0; - else allfuzz = TT.F ? : TT.context ? TT.context-1 : 0; + if (fuzz>1) allfuzz = TT.F ? : TT.context ? TT.context-1 : 0; // Loop through input data searching for this hunk. Match all context // lines and lines to be removed until we've found end of complete hunk. -- 2.39.2