From b58c34180e438c06ee2ba5b0a3324c48e1d7f7f5 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 4 Jul 2017 15:23:44 +0200 Subject: use off_t and intmax_t for file sizes --- xdu.c | 16 ++++++++-------- xwin.c | 6 ++---- 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 #include - -#ifndef X_NOT_STDC_ENV +#include #include /* 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; } -- cgit 1.4.1