Skip to content

Commit 92a1747

Browse files
committed
apply.c: split check_whitespace() into two
This splits the logic to record the presence of whitespace errors out of the check_whitespace() function, which checks and then records. The new function, record_ws_error(), can be used by the blank-at-eof check that does not use ws_check() logic to report its findings in the same output format. Signed-off-by: Junio C Hamano <[email protected]>
1 parent efa5744 commit 92a1747

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

builtin-apply.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,23 +1055,29 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
10551055
return -1;
10561056
}
10571057

1058-
static void check_whitespace(const char *line, int len, unsigned ws_rule)
1058+
static void record_ws_error(unsigned result, const char *line, int len, int linenr)
10591059
{
10601060
char *err;
1061-
unsigned result = ws_check(line + 1, len - 1, ws_rule);
1061+
10621062
if (!result)
10631063
return;
10641064

10651065
whitespace_error++;
10661066
if (squelch_whitespace_errors &&
10671067
squelch_whitespace_errors < whitespace_error)
1068-
;
1069-
else {
1070-
err = whitespace_error_string(result);
1071-
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
1072-
patch_input_file, linenr, err, len - 2, line + 1);
1073-
free(err);
1074-
}
1068+
return;
1069+
1070+
err = whitespace_error_string(result);
1071+
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
1072+
patch_input_file, linenr, err, len, line);
1073+
free(err);
1074+
}
1075+
1076+
static void check_whitespace(const char *line, int len, unsigned ws_rule)
1077+
{
1078+
unsigned result = ws_check(line + 1, len - 1, ws_rule);
1079+
1080+
record_ws_error(result, line + 1, len - 2, linenr);
10751081
}
10761082

10771083
/*

0 commit comments

Comments
 (0)