Package: xdiskusage / 1.48-10.1

05_xdiskusage.C_support_4.3TB_and_more.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Author: Thierry Randrianiriana <randrianiriana@gmail.com>
Description: see bug #555323
--- a/xdiskusage.C
+++ b/xdiskusage.C
@@ -50,23 +50,23 @@
 #include <FL/fl_ask.H>
 #include <FL/math.h>
 
-typedef unsigned long ulong;
+typedef unsigned long long ull;
 
 // turn number of K into user-friendly text:
-const char* formatk(ulong k) {
+const char* formatk(ull k) {
   static char buffer[10];
   if (k >= 1024*1024) sprintf(buffer,"%.4gG",(double)k/(1024*1024));
   else if (k >= 1024) sprintf(buffer,"%.4gM",(double)k/1024);
-  else sprintf(buffer,"%ldK",k);
+  else sprintf(buffer,"%.0fK",(double)k);
   return buffer;
 }
 
 // Holds data read from 'df' for each disk
 struct Disk {
   const char* mount;
-  ulong total;
-  ulong used;
-  ulong avail;
+  ull total;
+  ull used;
+  ull avail;
   Disk* next;
 };
 
@@ -99,9 +99,9 @@
     // ok we found a line with a /xyz at the end:
     Disk* d = new Disk;
     d->mount = strdup(word[n-1]);
-    d->total = strtol(word[n-5],0,10);
-    d->used=strtol(word[n-4],0,10);
-    d->avail=strtol(word[n-3],0,10);
+    d->total = strtoul(word[n-5],0,10);
+    d->used=strtoul(word[n-4],0,10);
+    d->avail=strtoul(word[n-3],0,10);
     *pointer = d;
     d->next = 0;
     pointer = &d->next;
@@ -117,7 +117,7 @@
   for (Disk* d = firstdisk; d; d = d->next) {
     char buf[512];
     int pct;
-    ulong sum = d->used + d->avail;
+    ull sum = d->used + d->avail;
     if (!sum) {
       pct = 0;
     } else {
@@ -161,7 +161,7 @@
   Node* child;
   Node* brother;
   const char* name;
-  ulong size;
+  ull size;
   long ordinal; // sign bit indicates hidden
   bool hidden() const {return ordinal < 0;}
 };
@@ -187,8 +187,8 @@
   OutputWindow(int w, int h, const char* l) : Fl_Window(w,h,l),
     menu_button(0,0,w,h) {box(FL_NO_BOX);}
   void finish_drawn_row();
-  void draw_tree(Node* n, int column, ulong row, double scale, double offset);
-  void print_tree(FILE* f, Node* n, int column, ulong row, double scale, double offset, int W, int H);
+  void draw_tree(Node* n, int column, ull row, double scale, double offset);
+  void print_tree(FILE* f, Node* n, int column, ull row, double scale, double offset, int W, int H);
   void setcurrent(Node*, int);
   void setroot(Node*, int);
 public:
@@ -327,14 +327,14 @@
 // fill in missing totals by adding all sons:
 void fix_tree(Node* n) {
   if (n->size) return;
-  ulong total = 0;
+  ull total = 0;
   for (Node *x = n->child; x; x = x->brother) total += x->size;
   n->size = total;
 }
 
 static long ordinal;
 
-Node* newnode(const char* name, ulong size, Node* parent, Node* & brother) {
+Node* newnode(const char* name, ull size, Node* parent, Node* & brother) {
   Node* n = new Node;
   n->child = n->brother = 0;
   n->name = strdup(name);
@@ -477,8 +477,8 @@
   ordinal = 0;
 
   Node* lastnode[MAXDEPTH];
-  ulong runningtotal;
-  ulong totals[MAXDEPTH];
+  ull runningtotal;
+  ull totals[MAXDEPTH];
   lastnode[0] = root;
   runningtotal = 0;
   totals[0] = 0;
@@ -520,7 +520,7 @@
     char* p = buffer+len;
     if (p > buffer && p[-1] == '\n') p[-1] = 0;
 
-    ulong size = strtoul(buffer, &p, 10);
+    ull size = strtoull(buffer, &p, 10);
     if (!isspace(*p) || p == buffer) {
       if (!*p || *p=='#') continue; // ignore blank lines or comments (?)
       fl_alert("%s:%d: does not look like du output: %s", path, line_no, p);
@@ -555,7 +555,7 @@
 
     if (match == newdepth) {
       Node* p = lastnode[newdepth];
-      ulong t = totals[newdepth]+size;
+      ull t = totals[newdepth]+size;
       p->size = size;
       runningtotal = t;
     } else {
@@ -677,7 +677,7 @@
 }
 
 // Returns first pixel row not drawn into:
-void OutputWindow::draw_tree(Node* n, int column, ulong row, double scale, double offset) {
+void OutputWindow::draw_tree(Node* n, int column, ull row, double scale, double offset) {
   int X = (w()-1)*column/ncols;
   int W = (w()-1)*(column+1)/ncols - X;
   int Y = int(row*scale+offset+.5);
@@ -726,7 +726,7 @@
       if (undrawn_column < X+W+1) undrawn_column = X+W+1;
       if (column+1 < ncols) {
 	// figure out how much is not hidden:
-	ulong hidden = 0;
+	ull hidden = 0;
 	for (Node* c = n->child; c; c = c->brother)
 	  if (c->hidden()) hidden += c->size;
 	if (hidden > 0) {
@@ -811,11 +811,11 @@
     double scale = (double)(h()-1)/current_root->size;
     double offset = 0;
     Node* n = current_root;
-    ulong row = 0;
+    ull row = 0;
     int d = root_depth;
     while (n && d < column) {
       path[d] = n;
-      ulong hidden = 0;
+      ull hidden = 0;
       for (Node* c = n->child; c; c = c->brother)
 	if (c->hidden()) hidden += c->size;
       if (hidden >= n->size) {n = 0; break;}
@@ -1034,7 +1034,7 @@
 ////////////////////////////////////////////////////////////////
 // PostScript output
 
-void OutputWindow::print_tree(FILE*f,Node* n, int column, ulong row,
+void OutputWindow::print_tree(FILE*f,Node* n, int column, ull row,
 			      double scale, double offset,
 			      int bboxw, int bboxh)
 {
@@ -1058,7 +1058,7 @@
     }
     fprintf(f, "\n");
     if (n->child && column+1 < ncols) {
-      ulong hidden = 0;
+      ull hidden = 0;
       for (Node* c = n->child; c; c = c->brother)
 	if (c->hidden()) hidden += c->size;
       if (hidden > 0) {