<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 0424ccc2af61b4c87f52cde7e50571d9f32ff2dc Mon Sep 17 00:00:00 2001
From: Adam Sampson &lt;ats@offog.org&gt;
Date: Fri, 4 Jul 2025 00:33:50 +0100
Subject: [PATCH 1/6] Use intmax_t for file sizes.

long isn't big enough these days.
---
 xdu.c  | 27 ++++++++++++++-------------
 xwin.c |  5 +++--
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/xdu.c b/xdu.c
index fe05843..22d1359 100644
--- a/xdu.c
+++ b/xdu.c
@@ -19,6 +19,7 @@
  * limitation a license to do the foregoing actions under any patents of
  * the party supplying this software to the X Consortium.
  */
+#include &lt;inttypes.h&gt;
 #include &lt;stdio.h&gt;
 #include "version.h"
 
@@ -74,7 +75,7 @@ struct rect {
  */
 struct node {
 	char	*name;
-	long	size;		/* from here down in the tree */
+	intmax_t size;		/* from here down in the tree */
 	long	num;		/* entry number - for resorting */
 	struct	rect rect;	/* last drawn screen rectangle */
 	struct	node *peer;	/* siblings */
@@ -91,7 +92,7 @@ long nnodes = 0;
 struct node *
 makenode(name,size)
 char *name;
-int size;
+intmax_t size;
 {
 	struct	node	*np;
 
@@ -157,7 +158,7 @@ struct node *nodep;
  * 	      had their sizes initialized. [DPT911113]
  *	      * * * This function is recursive * * *
  */
-long
+intmax_t
 fix_tree(top)
 struct node *top;
 {
@@ -233,7 +234,7 @@ char *filename;
 {
 	char	buf[4096];
 	char	name[4096];
-	int	size;
+	intmax_t size;
 	FILE	*fp;
 
 	if (strcmp(filename, "-") == 0) {
@@ -245,7 +246,7 @@ char *filename;
 		}
 	}
 	while (fgets(buf,sizeof(buf),fp) != NULL) {
-		sscanf(buf, "%d %s\n", &amp;size, name);
+		sscanf(buf, "%" SCNdMAX " %s\n", &amp;size, name);
 		/*printf("%d %s\n", size, name);*/
 		parse_entry(name,size);
 	}
@@ -256,7 +257,7 @@ char *filename;
 void
 parse_entry(name,size)
 char *name;
-int size;
+intmax_t size;
 {
 	char	*path[MAXDEPTH]; /* break up path into this list */
 	char	buf[MAXNAME];	 /* temp space for path element name */
@@ -308,7 +309,7 @@ compare(n1,n2,order)
 struct node *n1, *n2;
 int order;
 {
-	int	ret;
+	intmax_t ret;
 
 	switch (order) {
 	case ORD_SIZE:
@@ -393,7 +394,7 @@ void
 addtree(top, path, size)
 struct node *top;
 char *path[];
-int size;
+intmax_t size;
 {
 	struct	node *np;
 
@@ -439,7 +440,7 @@ int level;
 	for (i = 0; i &lt; level; i++)
 		printf("   ");
 
-	printf("%s %d\n", np-&gt;name, np-&gt;size);
+	printf("%s %" PRIdMAX "\n", np-&gt;name, np-&gt;size);
 	for (subnp = np-&gt;child; subnp != NULL; subnp = subnp-&gt;peer) {
 		dumptree(subnp,level+1);
 	}
@@ -518,14 +519,14 @@ drawchildren(nodep, rect)
 struct node *nodep;	/* node whose children we should draw */
 struct rect rect;	/* rectangle to draw all children in */
 {
-	int	totalsize;
+	intmax_t totalsize;
 	int	totalheight;
 	struct	node	*np;
 	double	fractsize;
 	int	height;
 	int	top;
 
-	/*printf("Drawing children of \"%s\", %d\n", nodep-&gt;name, nodep-&gt;size);*/
+	/*printf("Drawing children of \"%s\", %" PRIdMAX "\n", nodep-&gt;name, nodep-&gt;size);*/
 	/*printf("In [%d,%d,%d,%d]\n", rect.left,rect.top,rect.width,rect.height);*/
 
 	top = rect.top;
@@ -618,7 +619,7 @@ pwd()
 		if (num != 0)
 			strcat(path,"/");
 	}
-	printf("%s %d (%.2f%%)\n", path, topp-&gt;size,
+	printf("%s %" PRIdMAX " (%.2f%%)\n", path, topp-&gt;size,
 		100.0*topp-&gt;size/rootp-&gt;size);
 }
 
@@ -748,7 +749,7 @@ nodeinfo()
 
 	/* display each child of this node */
 	for (np = topp-&gt;child; np != NULL; np = np-&gt;peer) {
-		printf("%-8d %s\n", np-&gt;size, np-&gt;name);
+		printf("%-8" PRIdMAX " %s\n", np-&gt;size, np-&gt;name);
 	}
 }
 
diff --git a/xwin.c b/xwin.c
index dbecb5d..6b90494 100644
--- a/xwin.c
+++ b/xwin.c
@@ -29,6 +29,7 @@
 #include &lt;X11/Xaw/Label.h&gt;
 
 #include &lt;stdio.h&gt;
+#include &lt;inttypes.h&gt;
 
 #ifndef X_NOT_STDC_ENV
 #include &lt;stdlib.h&gt;	/* for exit() */
@@ -379,7 +380,7 @@ xrepaint_noclear()
 
 xdrawrect(name, size, x, y, width, height)
 char *name;
-int size;
+intmax_t size;
 int x, y, width, height;
 {
 	int	textx, texty;
@@ -392,7 +393,7 @@ int x, y, width, height;
 	XDrawRectangle(dpy, win, gc, x, y, width, height);
 
 	if (res.showsize) {
-		sprintf(label,"%s (%d)", name, size);
+		sprintf(label,"%s (%" PRIdMAX ")", name, size);
 		name = label;
 	}
 
-- 
2.50.0

</pre></body></html>