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

Re: [PATCH] Fix ptrdiff_t vs. int

From
Linus Torvalds <torvalds@osdl.org>
Date
May 27, 2005, 17:25 UTC
Message-ID
<Pine.LNX.4.58.0505271024280.17402@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0505271013260.17402@ppc970.osdl.org>
On Fri, 27 May 2005, Linus Torvalds wrote:
> 
> I can compile a kernel with "-m64", but since I don't have any 64-bit
> libraries installed, user space doesn't work that well ;)

Btw, since this was the piece of code that I didn't bother simplifying last time it was discussed (then it was just "ugly"), I took a different approach instead, and committed the following..

		Linus
---
diff-tree 84c1afd7e7c69c6c3c0677d5ee01925d4c70d318 (from a9c9cef161b26ca610783dd0b180d18956c7b119)
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date:   Fri May 27 10:22:09 2005 -0700
    
    git-diff-tree: simplify header output with '-z'
    
    No need to make them multiple lines, in fact we explicitly don't want that.
    
    This also fixes a 64-bit problem pointed out by Markus F.X.J. Oberhumer,
    where we gave "%.*s" a "ptrdiff_t" length argument instead of an "int".
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -269,18 +269,11 @@ static int call_diff_flush(void)
 		return 0;
 	}
 	if (header) {
-		if (diff_output_format == DIFF_FORMAT_MACHINE) {
-			const char *ep, *cp;
-			for (cp = header; *cp; cp = ep) {
-				ep = strchr(cp, '\n');
-				if (ep == 0) ep = cp + strlen(cp);
-				printf("%.*s%c", ep-cp, cp, 0);
-				if (*ep) ep++;
-			}
-		}
-		else {
-			printf("%s", header);
-		}
+		const char *fmt = "%s";
+		if (diff_output_format == DIFF_FORMAT_MACHINE)
+			fmt = "%s%c";
+		
+		printf(fmt, header, 0);
 		header = NULL;
 	}
 	diff_flush(diff_output_format, 1);
Previous: Linus TorvaldsNext: Markus F.X.J. Oberhumer
Message 6 of 13 in “Fix ptrdiff_t vs. int”
  1. Fix ptrdiff_t vs. intMarkus F.X.J. Oberhumer, May 27, 2005
  2. Danjel McGouganMay 27, 2005
  3. Morten WelinderMay 27, 2005
  4. H. Peter AnvinMay 27, 2005
  5. Linus TorvaldsMay 27, 2005
  6. Linus TorvaldsMay 27, 2005
  7. Markus F.X.J. OberhumerMay 27, 2005
  8. H. Peter AnvinMay 27, 2005
  9. Linus TorvaldsMay 27, 2005
  10. Junio C HamanoMay 27, 2005
  11. Adjust diff-helper to diff-tree -v -z changes.Junio C Hamano, May 28, 2005
  12. Linus TorvaldsMay 29, 2005
  13. Junio C HamanoMay 29, 2005

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.