@matheusbsbs / matheus-bagliano / commits / e6d40d65df
Fork 0

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>

Johannes Schindelin committed Dec 22, 2006 at 03:20 UTC e6d40d65df07059fc655fabe62fa5b575ead7815
1 file changed +2 -2
diff.c
+2 -2
@@ -825,8 +825,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
825 if (line[0] == '+') {
826 int i, spaces = 0;
827
828 - data->lineno++;
829 -
828 /* check space before tab */
829 for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
830 if (line[i] == ' ')
@@ -841,6 +839,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
839 if (isspace(line[len - 1]))
840 printf("%s:%d: white space at end: %.*s\n",
841 data->filename, data->lineno, (int)len, line);
842 +
843 + data->lineno++;
844 } else if (line[0] == ' ')
845 data->lineno++;
846 else if (line[0] == '@') {