about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-07-04 15:23:44 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-07-04 15:23:44 +0200
commitb58c34180e438c06ee2ba5b0a3324c48e1d7f7f5 (patch)
tree6e5483d7a6a3ef436b21e7758cacc93b88d2776b
parent873aa90e0411fe7a5c0cfd0cd6e89a890dc890f2 (diff)
downloadxdu-b58c34180e438c06ee2ba5b0a3324c48e1d7f7f5.tar.gz
xdu-b58c34180e438c06ee2ba5b0a3324c48e1d7f7f5.tar.xz
xdu-b58c34180e438c06ee2ba5b0a3324c48e1d7f7f5.zip
use off_t and intmax_t for file sizes
-rw-r--r--xdu.c16
-rw-r--r--xwin.c6
2 files changed, 10 insertions, 12 deletions
diff --git a/xdu.c b/xdu.c
index fb44488..aa9a5c4 100644
--- a/xdu.c
+++ b/xdu.c
@@ -76,7 +76,7 @@ struct rect {
  */
 struct node {
 	char	*name;
-	long	size;		/* from here down in the tree */
+	off_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 */
@@ -228,7 +228,7 @@ parse_file(char *filename)
 {
 	char	buf[4096];
 	char	name[4096];
-	int	size;
+	intmax_t size;
 	FILE	*fp;
 
 	if (strcmp(filename, "-") == 0) {
@@ -240,9 +240,9 @@ parse_file(char *filename)
 		}
 	}
 	while (fgets(buf,sizeof(buf),fp) != NULL) {
-		sscanf(buf, "%d %s\n", &size, name);
-		/*printf("%d %s\n", size, name);*/
-		parse_entry(name,size);
+		sscanf(buf, "%jd %4095[^\n]\n", &size, name);
+		printf("%jd %s\n", size, name);
+		parse_entry(name,(off_t)size);
 	}
 	fclose(fp);
 }
@@ -426,7 +426,7 @@ dumptree(struct node *np, int level)
 	for (i = 0; i < level; i++)
 		printf("   ");
 
-	printf("%s %d\n", np->name, np->size);
+	printf("%s %jd\n", np->name, (intmax_t)np->size);
 	for (subnp = np->child; subnp != NULL; subnp = subnp->peer) {
 		dumptree(subnp,level+1);
 	}
@@ -508,7 +508,7 @@ drawchildren(
     struct rect rect	/* rectangle to draw all children in */
 )
 {
-	int	totalsize;
+	off_t	totalsize;
 	int	totalheight;
 	struct	node	*np;
 	double	fractsize;
@@ -722,7 +722,7 @@ nodeinfo(void)
 
 	/* display each child of this node */
 	for (np = topp->child; np != NULL; np = np->peer) {
-		printf("%-8d %s\n", np->size, np->name);
+		printf("%-8ld %s\n", np->size, np->name);
 	}
 }
 
diff --git a/xwin.c b/xwin.c
index d84f1f9..0b0aee1 100644
--- a/xwin.c
+++ b/xwin.c
@@ -29,10 +29,8 @@
 #include <X11/Xaw/Label.h>
 
 #include <stdio.h>
-
-#ifndef X_NOT_STDC_ENV
+#include <stdint.h>
 #include <stdlib.h>	/* for exit() */
-#endif
 
 /* IMPORTS: routines that this module vectors out to */
 int press(int x, int y);
@@ -351,7 +349,7 @@ xdrawrect(char *name, off_t size, int x, int y, int width, int height)
 	XDrawRectangle(dpy, win, gc, x, y, width, height);
 
 	if (res.showsize) {
-		sprintf(label,"%s (%d)", name, size);
+		sprintf(label,"%s (%jd)", name, (intmax_t)size);
 		name = label;
 	}