git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] diff --check: fix off by one error

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 22, 2006, 02:20 UTC
Message-ID
<Pine.LNX.4.63.0612220319440.19693@wbgn013.biozentrum.uni-wuerzburg.de>

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>
---
 diff.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 26916c3..ba6bd59 100644
--- a/diff.c
+++ b/diff.c
@@ -874,8 +874,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
 	if (line[0] == '+') {
 		int i, spaces = 0;
 
-		data->lineno++;
-
 		/* check space before tab */
 		for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
 			if (line[i] == ' ')
@@ -890,6 +888,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
 		if (isspace(line[len - 1]))
 			printf("%s:%d: white space at end: %.*s\n",
 				data->filename, data->lineno, (int)len, line);
+
+		data->lineno++;
 	} else if (line[0] == ' ')
 		data->lineno++;
 	else if (line[0] == '@') {
-- 
1.4.4.2.ga854-dirty
Message 1 of 1 in “diff --check: fix off by one error”
  1. diff --check: fix off by one errorJohannes Schindelin, Dec 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.