diff --check: fix off by one error
When parsing the diff line starting with '@@', the line number of the '+' file is parsed. For the subsequent line parses, the line number should therefore be incremented after the parse, not before it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
ec722203ee
commit
e6d40d65df
4
diff.c
4
diff.c
@ -825,8 +825,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
|
|||||||
if (line[0] == '+') {
|
if (line[0] == '+') {
|
||||||
int i, spaces = 0;
|
int i, spaces = 0;
|
||||||
|
|
||||||
data->lineno++;
|
|
||||||
|
|
||||||
/* check space before tab */
|
/* check space before tab */
|
||||||
for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
|
for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
|
||||||
if (line[i] == ' ')
|
if (line[i] == ' ')
|
||||||
@ -841,6 +839,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
|
|||||||
if (isspace(line[len - 1]))
|
if (isspace(line[len - 1]))
|
||||||
printf("%s:%d: white space at end: %.*s\n",
|
printf("%s:%d: white space at end: %.*s\n",
|
||||||
data->filename, data->lineno, (int)len, line);
|
data->filename, data->lineno, (int)len, line);
|
||||||
|
|
||||||
|
data->lineno++;
|
||||||
} else if (line[0] == ' ')
|
} else if (line[0] == ' ')
|
||||||
data->lineno++;
|
data->lineno++;
|
||||||
else if (line[0] == '@') {
|
else if (line[0] == '@') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user