{"thread":{"id":"6072","subject":"[PATCH] diff --check: fix off by one error","startedAt":"2006-12-22T02:20:11Z","lastAt":"2006-12-22T02:20:11Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"30001","messageId":"Pine.LNX.4.63.0612220319440.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6072","inReplyTo":null,"subject":"[PATCH] diff --check: fix off by one error","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-22T02:20:11Z","receivedAt":"2006-12-22T02:20:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen parsing the diff line starting with '@@', the line number of the\n'+' file is parsed. For the subsequent line parses, the line number\nshould therefore be incremented after the parse, not before it.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n diff.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 26916c3..ba6bd59 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -874,8 +874,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n \tif (line[0] == '+') {\n \t\tint i, spaces = 0;\n \n-\t\tdata->lineno++;\n-\n \t\t/* check space before tab */\n \t\tfor (i = 1; i < len && (line[i] == ' ' || line[i] == '\\t'); i++)\n \t\t\tif (line[i] == ' ')\n@@ -890,6 +888,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n \t\tif (isspace(line[len - 1]))\n \t\t\tprintf(\"%s:%d: white space at end: %.*s\\n\",\n \t\t\t\tdata->filename, data->lineno, (int)len, line);\n+\n+\t\tdata->lineno++;\n \t} else if (line[0] == ' ')\n \t\tdata->lineno++;\n \telse if (line[0] == '@') {\n-- \n1.4.4.2.ga854-dirty\n"}]}