mirror of
https://github.com/git/git.git
synced 2024-10-30 22:07:53 +01:00
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 <gitster@pobox.com>
This commit is contained in:
parent
efa574438f
commit
92a1747eea
1 changed files with 15 additions and 9 deletions
|
@ -1055,23 +1055,29 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void check_whitespace(const char *line, int len, unsigned ws_rule)
|
||||
static void record_ws_error(unsigned result, const char *line, int len, int linenr)
|
||||
{
|
||||
char *err;
|
||||
unsigned result = ws_check(line + 1, len - 1, ws_rule);
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
whitespace_error++;
|
||||
if (squelch_whitespace_errors &&
|
||||
squelch_whitespace_errors < whitespace_error)
|
||||
;
|
||||
else {
|
||||
err = whitespace_error_string(result);
|
||||
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
|
||||
patch_input_file, linenr, err, len - 2, line + 1);
|
||||
free(err);
|
||||
}
|
||||
return;
|
||||
|
||||
err = whitespace_error_string(result);
|
||||
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
|
||||
patch_input_file, linenr, err, len, line);
|
||||
free(err);
|
||||
}
|
||||
|
||||
static void check_whitespace(const char *line, int len, unsigned ws_rule)
|
||||
{
|
||||
unsigned result = ws_check(line + 1, len - 1, ws_rule);
|
||||
|
||||
record_ws_error(result, line + 1, len - 2, linenr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue