OpenCoverage

human.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/human.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static const char power_letter[] =-
9{-
10 0,-
11 'K',-
12 'M',-
13 'G',-
14 'T',-
15 'P',-
16 'E',-
17 'Z',-
18 'Y'-
19};-
20-
21-
22-
23-
24-
25static long double-
26adjust_value (int inexact_style, long double value)-
27{-
28-
29-
30-
31-
32 if (inexact_style != human_round_to_nearest
inexact_style ...und_to_nearestDescription
TRUEnever evaluated
FALSEevaluated 220 times by 1 test
Evaluated by:
  • dd
&& value <
value < (18446...73709551615UL)Description
TRUEnever evaluated
FALSEnever evaluated
0-220
33 (18446744073709551615UL)
value < (18446...73709551615UL)Description
TRUEnever evaluated
FALSEnever evaluated
0
34 )-
35 {-
36 uintmax_t u = value;-
37 value = u + (inexact_style == human_ceiling
inexact_style == human_ceilingDescription
TRUEnever evaluated
FALSEnever evaluated
&& u != value
u != valueDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
38 }
never executed: end of block
0
39-
40 return
executed 220 times by 1 test: return value;
Executed by:
  • dd
value;
executed 220 times by 1 test: return value;
Executed by:
  • dd
220
41}-
42static char *-
43group_number (char *number, size_t numberlen,-
44 char const *grouping, char const *thousands_sep)-
45{-
46 register char *d;-
47 size_t grouplen = -
48 (18446744073709551615UL)-
49 ;-
50 size_t thousands_seplen = strlen (thousands_sep);-
51 size_t i = numberlen;-
52-
53-
54-
55 char buf[2 * (((((sizeof (uintmax_t) * 8) - (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) + 1];-
56-
57 memcpy (buf, number, numberlen);-
58 d = number + numberlen;-
59-
60 for (;;)-
61 {-
62 unsigned char g = *grouping;-
63-
64 if (g
gDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
65 {-
66 grouplen = g < 0x7f
g < 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
? g : i;
0
67 grouping++;-
68 }
never executed: end of block
0
69-
70 if (i < grouplen
i < grouplenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
71 grouplen = i;
never executed: grouplen = i;
0
72-
73 d -= grouplen;-
74 i -= grouplen;-
75 memcpy (d, buf + i, grouplen);-
76 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
77 return
never executed: return d;
d;
never executed: return d;
0
78-
79 d -= thousands_seplen;-
80 memcpy (d, thousands_sep, thousands_seplen);-
81 }
never executed: end of block
0
82}
never executed: end of block
0
83char *-
84human_readable (uintmax_t n, char *buf, int opts,-
85 uintmax_t from_block_size, uintmax_t to_block_size)-
86{-
87 int inexact_style =-
88 opts & (human_round_to_nearest | human_floor | human_ceiling);-
89 unsigned int base = opts & human_base_1024
opts & human_base_1024Description
TRUEevaluated 224 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 4623 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
? 1024 : 1000;
224-4623
90 uintmax_t amt;-
91 int tenths;-
92 int exponent = -1;-
93 int exponent_max = sizeof power_letter - 1;-
94 char *p;-
95 char *psuffix;-
96 char const *integerlim;-
97-
98-
99-
100-
101-
102 int rounding;-
103-
104 char const *decimal_point = ".";-
105 size_t decimal_pointlen = 1;-
106 char const *grouping = "";-
107 char const *thousands_sep = "";-
108 struct lconv const *l = localeconv ();-
109 size_t pointlen = strlen (l->decimal_point);-
110 if (0 < pointlen
0 < pointlenDescription
TRUEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
&& pointlen <=
pointlen <= 16Description
TRUEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
0-4847
111 16
pointlen <= 16Description
TRUEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
0-4847
112 )-
113 {-
114 decimal_point = l->decimal_point;-
115 decimal_pointlen = pointlen;-
116 }
executed 4847 times by 6 tests: end of block
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
4847
117 grouping = l->grouping;-
118 if (strlen (l->thousands_sep) <=
strlen (l->tho...nds_sep) <= 16Description
TRUEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
0-4847
119 16
strlen (l->tho...nds_sep) <= 16Description
TRUEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
0-4847
120 )-
121 thousands_sep = l->thousands_sep;
executed 4847 times by 6 tests: thousands_sep = l->thousands_sep;
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
4847
122-
123-
124 psuffix = buf + ((2 * sizeof (uintmax_t) * 8 * 146 / 485 + 1) * (-
125 16 -
126 + 1) - -
127 16 -
128 + 1 + 3) - 1 - 3;-
129 p = psuffix;-
130-
131-
132-
133-
134 if (to_block_size <= from_block_size
to_block_size ...rom_block_sizeDescription
TRUEevaluated 1975 times by 5 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • vdir
FALSEevaluated 2872 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
)
1975-2872
135 {-
136 if (from_block_size % to_block_size == 0
from_block_siz...lock_size == 0Description
TRUEevaluated 1828 times by 5 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • vdir
FALSEevaluated 147 times by 1 test
Evaluated by:
  • dd
)
147-1828
137 {-
138 uintmax_t multiplier = from_block_size / to_block_size;-
139 amt = n * multiplier;-
140 if (amt / multiplier == n
amt / multiplier == nDescription
TRUEevaluated 1828 times by 5 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • vdir
FALSEnever evaluated
)
0-1828
141 {-
142 tenths = 0;-
143 rounding = 0;-
144 goto
executed 1828 times by 5 tests: goto use_integer_arithmetic;
Executed by:
  • dd
  • df
  • du
  • ls
  • vdir
use_integer_arithmetic;
executed 1828 times by 5 tests: goto use_integer_arithmetic;
Executed by:
  • dd
  • df
  • du
  • ls
  • vdir
1828
145 }-
146 }
never executed: end of block
0
147 }
executed 147 times by 1 test: end of block
Executed by:
  • dd
147
148 else if (from_block_size != 0
from_block_size != 0Description
TRUEevaluated 2872 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
&& to_block_size % from_block_size == 0
to_block_size ...lock_size == 0Description
TRUEevaluated 2869 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
FALSEevaluated 3 times by 1 test
Evaluated by:
  • dd
)
0-2872
149 {-
150 uintmax_t divisor = to_block_size / from_block_size;-
151 uintmax_t r10 = (n % divisor) * 10;-
152 uintmax_t r2 = (r10 % divisor) * 2;-
153 amt = n / divisor;-
154 tenths = r10 / divisor;-
155 rounding = r2 < divisor
r2 < divisorDescription
TRUEevaluated 2865 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
FALSEevaluated 4 times by 1 test
Evaluated by:
  • sum
? 0 < r2 : 2 + (divisor < r2);
4-2865
156 goto
executed 2869 times by 5 tests: goto use_integer_arithmetic;
Executed by:
  • df
  • du
  • ls
  • sum
  • vdir
use_integer_arithmetic;
executed 2869 times by 5 tests: goto use_integer_arithmetic;
Executed by:
  • df
  • du
  • ls
  • sum
  • vdir
2869
157 }-
158-
159 {-
160-
161-
162-
163-
164 long double dto_block_size = to_block_size;-
165 long double damt = n * (from_block_size / dto_block_size);-
166 size_t buflen;-
167 size_t nonintegerlen;-
168-
169 if (! (opts & human_autoscale)
! (opts & human_autoscale)Description
TRUEnever evaluated
FALSEevaluated 150 times by 1 test
Evaluated by:
  • dd
)
0-150
170 {-
171 sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt));-
172 buflen = strlen (buf);-
173 nonintegerlen = 0;-
174 }
never executed: end of block
0
175 else-
176 {-
177 long double e = 1;-
178 exponent = 0;-
179-
180 do-
181 {-
182 e *= base;-
183 exponent++;-
184 }
executed 237 times by 1 test: end of block
Executed by:
  • dd
237
185 while (e * base <= damt
e * base <= damtDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 150 times by 1 test
Evaluated by:
  • dd
&& exponent < exponent_max
exponent < exponent_maxDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • dd
FALSEnever evaluated
);
0-150
186-
187 damt /= e;-
188-
189 sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt));-
190 buflen = strlen (buf);-
191 nonintegerlen = decimal_pointlen + 1;-
192-
193 if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen
1 + noninteger...1024) < buflenDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 80 times by 1 test
Evaluated by:
  • dd
70-80
194 || ((
(opts & human_...ss_point_zero)Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • dd
opts & human_suppress_point_zero)
(opts & human_...ss_point_zero)Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • dd
0-80
195 && buf[buflen - 1] == '0'
buf[buflen - 1] == '0'Description
TRUEnever evaluated
FALSEnever evaluated
))
0
196 {-
197 sprintf (buf, "%.0Lf",-
198 adjust_value (inexact_style, damt * 10) / 10);-
199 buflen = strlen (buf);-
200 nonintegerlen = 0;-
201 }
executed 70 times by 1 test: end of block
Executed by:
  • dd
70
202 }
executed 150 times by 1 test: end of block
Executed by:
  • dd
150
203-
204 p = psuffix - buflen;-
205 memmove (p, buf, buflen);-
206 integerlim = p + buflen - nonintegerlen;-
207 }-
208 goto
executed 150 times by 1 test: goto do_grouping;
Executed by:
  • dd
do_grouping;
executed 150 times by 1 test: goto do_grouping;
Executed by:
  • dd
150
209-
210 use_integer_arithmetic:-
211 {-
212-
213-
214-
215-
216-
217 if (opts & human_autoscale
opts & human_autoscaleDescription
TRUEevaluated 375 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 4322 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
)
375-4322
218 {-
219 exponent = 0;-
220-
221 if (base <= amt
base <= amtDescription
TRUEevaluated 241 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 134 times by 1 test
Evaluated by:
  • dd
)
134-241
222 {-
223 do-
224 {-
225 unsigned int r10 = (amt % base) * 10 + tenths;-
226 unsigned int r2 = (r10 % base) * 2 + (rounding >> 1);-
227 amt /= base;-
228 tenths = r10 / base;-
229 rounding = (r2 < base
r2 < baseDescription
TRUEevaluated 316 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 68 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
68-316
230 ? (r2 + rounding) != 0-
231 : 2 + (base < r2 + rounding));-
232 exponent++;-
233 }
executed 384 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
384
234 while (base <= amt
base <= amtDescription
TRUEevaluated 143 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 241 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
&& exponent < exponent_max
exponent < exponent_maxDescription
TRUEevaluated 143 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEnever evaluated
);
0-241
235-
236 if (amt < 10
amt < 10Description
TRUEevaluated 108 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 133 times by 2 tests
Evaluated by:
  • dd
  • df
)
108-133
237 {-
238 if (inexact_style == human_round_to_nearest
inexact_style ...und_to_nearestDescription
TRUEevaluated 43 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 65 times by 2 tests
Evaluated by:
  • df
  • du
inexact_style ...& 0 < roundingDescription
TRUEevaluated 14 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 94 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
14-94
239 ? 2 < rounding + (tenths & 1)
inexact_style ...& 0 < roundingDescription
TRUEevaluated 14 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 94 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
14-94
240 : inexact_style == human_ceiling
inexact_style == human_ceilingDescription
TRUEevaluated 65 times by 2 tests
Evaluated by:
  • df
  • du
FALSEnever evaluated
&& 0 < rounding
0 < roundingDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • df
  • du
FALSEevaluated 57 times by 2 tests
Evaluated by:
  • df
  • du
inexact_style ...& 0 < roundingDescription
TRUEevaluated 14 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 94 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
)
0-94
241 {-
242 tenths++;-
243 rounding = 0;-
244-
245 if (tenths == 10
tenths == 10Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • dd
FALSEevaluated 13 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
)
1-13
246 {-
247 amt++;-
248 tenths = 0;-
249 }
executed 1 time by 1 test: end of block
Executed by:
  • dd
1
250 }
executed 14 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
14
251-
252 if (amt < 10
amt < 10Description
TRUEevaluated 108 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEnever evaluated
0-108
253 && (tenths
tenthsDescription
TRUEevaluated 27 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 81 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
|| ! (opts & human_suppress_point_zero)
! (opts & huma...ss_point_zero)Description
TRUEevaluated 29 times by 2 tests
Evaluated by:
  • dd
  • du
FALSEevaluated 52 times by 1 test
Evaluated by:
  • df
))
27-81
254 {-
255 *--p = '0' + tenths;-
256 p -= decimal_pointlen;-
257 memcpy (p, decimal_point, decimal_pointlen);-
258 tenths = rounding = 0;-
259 }
executed 56 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
56
260 }
executed 108 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
108
261 }
executed 241 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
241
262 }
executed 375 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
375
263-
264 if (inexact_style == human_round_to_nearest
inexact_style ...und_to_nearestDescription
TRUEevaluated 304 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 4393 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
inexact_style ...ths + roundingDescription
TRUEevaluated 47 times by 3 tests
Evaluated by:
  • dd
  • df
  • sum
FALSEevaluated 4650 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
47-4650
265 ? 5 < tenths + (0 < rounding + (amt & 1))
inexact_style ...ths + roundingDescription
TRUEevaluated 47 times by 3 tests
Evaluated by:
  • dd
  • df
  • sum
FALSEevaluated 4650 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
47-4650
266 : inexact_style == human_ceiling
inexact_style == human_ceilingDescription
TRUEevaluated 4393 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
FALSEnever evaluated
&& 0 < tenths + rounding
0 < tenths + roundingDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • df
  • sum
FALSEevaluated 4371 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
inexact_style ...ths + roundingDescription
TRUEevaluated 47 times by 3 tests
Evaluated by:
  • dd
  • df
  • sum
FALSEevaluated 4650 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
)
0-4650
267 {-
268 amt++;-
269-
270 if ((
(opts & human_autoscale)Description
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • dd
  • df
FALSEevaluated 16 times by 1 test
Evaluated by:
  • sum
opts & human_autoscale)
(opts & human_autoscale)Description
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • dd
  • df
FALSEevaluated 16 times by 1 test
Evaluated by:
  • sum
16-31
271 && amt == base
amt == baseDescription
TRUEnever evaluated
FALSEevaluated 31 times by 2 tests
Evaluated by:
  • dd
  • df
&& exponent < exponent_max
exponent < exponent_maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-31
272 {-
273 exponent++;-
274 if (! (opts & human_suppress_point_zero)
! (opts & huma...ss_point_zero)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
275 {-
276 *--p = '0';-
277 p -= decimal_pointlen;-
278 memcpy (p, decimal_point, decimal_pointlen);-
279 }
never executed: end of block
0
280 amt = 1;-
281 }
never executed: end of block
0
282 }
executed 47 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • sum
47
283-
284 integerlim = p;-
285-
286 do-
287 {-
288 int digit = amt % 10;-
289 *--p = digit + '0';-
290 }
executed 10791 times by 6 tests: end of block
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
10791
291 while ((
(amt /= 10) != 0Description
TRUEevaluated 6094 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEevaluated 4697 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
amt /= 10) != 0
(amt /= 10) != 0Description
TRUEevaluated 6094 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
FALSEevaluated 4697 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
);
4697-6094
292 }-
293-
294 do_grouping:
code before this statement executed 4697 times by 6 tests: do_grouping:
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
4697
295 if (opts & human_group_digits
opts & human_group_digitsDescription
TRUEnever evaluated
FALSEevaluated 4847 times by 6 tests
Evaluated by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
)
0-4847
296 p = group_number (p, integerlim - p, grouping, thousands_sep);
never executed: p = group_number (p, integerlim - p, grouping, thousands_sep);
0
297-
298 if (opts & human_SI
opts & human_SIDescription
TRUEevaluated 525 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 4322 times by 5 tests
Evaluated by:
  • df
  • du
  • ls
  • sum
  • vdir
)
525-4322
299 {-
300 if (exponent < 0
exponent < 0Description
TRUEnever evaluated
FALSEevaluated 525 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
)
0-525
301 {-
302 uintmax_t power;-
303 exponent = 0;-
304 for (power = 1; power < to_block_size
power < to_block_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; power *= base)
0
305 if (++
++exponent == exponent_maxDescription
TRUEnever evaluated
FALSEnever evaluated
exponent == exponent_max
++exponent == exponent_maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
306 break;
never executed: break;
0
307 }
never executed: end of block
0
308-
309 if ((
(exponent | (opts & human_B))Description
TRUEevaluated 525 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEnever evaluated
exponent | (opts & human_B))
(exponent | (opts & human_B))Description
TRUEevaluated 525 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEnever evaluated
&& (
(opts & human_...e_before_unit)Description
TRUEevaluated 454 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 71 times by 2 tests
Evaluated by:
  • df
  • du
opts & human_space_before_unit)
(opts & human_...e_before_unit)Description
TRUEevaluated 454 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 71 times by 2 tests
Evaluated by:
  • df
  • du
)
0-525
310 *
executed 454 times by 1 test: *psuffix++ = ' ';
Executed by:
  • dd
psuffix++ = ' ';
executed 454 times by 1 test: *psuffix++ = ' ';
Executed by:
  • dd
454
311-
312 if (exponent
exponentDescription
TRUEevaluated 391 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
FALSEevaluated 134 times by 1 test
Evaluated by:
  • dd
)
134-391
313 *
executed 391 times by 3 tests: *psuffix++ = (! (opts & human_base_1024) && exponent == 1 ? 'k' : power_letter[exponent]);
Executed by:
  • dd
  • df
  • du
psuffix++ = (! (opts & human_base_1024)
! (opts & human_base_1024)Description
TRUEevaluated 234 times by 2 tests
Evaluated by:
  • dd
  • du
FALSEevaluated 157 times by 3 tests
Evaluated by:
  • dd
  • df
  • du
&& exponent == 1
exponent == 1Description
TRUEevaluated 86 times by 2 tests
Evaluated by:
  • dd
  • du
FALSEevaluated 148 times by 1 test
Evaluated by:
  • dd
executed 391 times by 3 tests: *psuffix++ = (! (opts & human_base_1024) && exponent == 1 ? 'k' : power_letter[exponent]);
Executed by:
  • dd
  • df
  • du
86-391
314 ? 'k'
executed 391 times by 3 tests: *psuffix++ = (! (opts & human_base_1024) && exponent == 1 ? 'k' : power_letter[exponent]);
Executed by:
  • dd
  • df
  • du
391
315 : power_letter[exponent]);
executed 391 times by 3 tests: *psuffix++ = (! (opts & human_base_1024) && exponent == 1 ? 'k' : power_letter[exponent]);
Executed by:
  • dd
  • df
  • du
391
316-
317 if (opts & human_B
opts & human_BDescription
TRUEevaluated 454 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 71 times by 2 tests
Evaluated by:
  • df
  • du
)
71-454
318 {-
319 if ((
(opts & human_base_1024)Description
TRUEevaluated 154 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 300 times by 1 test
Evaluated by:
  • dd
opts & human_base_1024)
(opts & human_base_1024)Description
TRUEevaluated 154 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 300 times by 1 test
Evaluated by:
  • dd
&& exponent
exponentDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • dd
FALSEevaluated 67 times by 1 test
Evaluated by:
  • dd
)
67-300
320 *
executed 87 times by 1 test: *psuffix++ = 'i';
Executed by:
  • dd
psuffix++ = 'i';
executed 87 times by 1 test: *psuffix++ = 'i';
Executed by:
  • dd
87
321 *psuffix++ = 'B';-
322 }
executed 454 times by 1 test: end of block
Executed by:
  • dd
454
323 }
executed 525 times by 3 tests: end of block
Executed by:
  • dd
  • df
  • du
525
324-
325 *psuffix = '\0';-
326-
327 return
executed 4847 times by 6 tests: return p;
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
p;
executed 4847 times by 6 tests: return p;
Executed by:
  • dd
  • df
  • du
  • ls
  • sum
  • vdir
4847
328}-
329static char const *const block_size_args[] = { "human-readable", "si", 0 };-
330static int const block_size_opts[] =-
331 {-
332 human_autoscale + human_SI + human_base_1024,-
333 human_autoscale + human_SI-
334 };-
335-
336static uintmax_t-
337default_block_size (void)-
338{-
339 return
executed 1622 times by 5 tests: return getenv ("POSIXLY_CORRECT") ? 512 : 1024;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
getenv ("POSIXLY_CORRECT") ? 512 : 1024;
executed 1622 times by 5 tests: return getenv ("POSIXLY_CORRECT") ? 512 : 1024;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
1622
340}-
341-
342static strtol_error-
343humblock (char const *spec, uintmax_t *block_size, int *options)-
344{-
345 int i;-
346 int opts = 0;-
347-
348 if (! spec
! specDescription
TRUEevaluated 1618 times by 5 tests
Evaluated by:
  • df
  • dir
  • du
  • ls
  • vdir
FALSEevaluated 183 times by 4 tests
Evaluated by:
  • df
  • dir
  • du
  • vdir
183-1618
349 && ! (spec = getenv ("BLOCK_SIZE"))
! (spec = gete..."BLOCK_SIZE"))Description
TRUEevaluated 1618 times by 5 tests
Evaluated by:
  • df
  • dir
  • du
  • ls
  • vdir
FALSEnever evaluated
0-1618
350 && ! (spec = getenv ("BLOCKSIZE"))
! (spec = gete...("BLOCKSIZE"))Description
TRUEevaluated 1618 times by 5 tests
Evaluated by:
  • df
  • dir
  • du
  • ls
  • vdir
FALSEnever evaluated
)
0-1618
351 *
executed 1618 times by 5 tests: *block_size = default_block_size ();
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
block_size = default_block_size ();
executed 1618 times by 5 tests: *block_size = default_block_size ();
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
1618
352 else-
353 {-
354 if (*
*spec == '\''Description
TRUEnever evaluated
FALSEevaluated 183 times by 4 tests
Evaluated by:
  • df
  • dir
  • du
  • vdir
spec == '\''
*spec == '\''Description
TRUEnever evaluated
FALSEevaluated 183 times by 4 tests
Evaluated by:
  • df
  • dir
  • du
  • vdir
)
0-183
355 {-
356 opts |= human_group_digits;-
357 spec++;-
358 }
never executed: end of block
0
359-
360 if (0 <= (i = argmatch (spec, block_size_args, (char const *) (block_size_opts), sizeof *(block_size_opts)))
0 <= (i = argm...k_size_opts)))Description
TRUEnever evaluated
FALSEevaluated 183 times by 4 tests
Evaluated by:
  • df
  • dir
  • du
  • vdir
)
0-183
361 {-
362 opts |= block_size_opts[i];-
363 *block_size = 1;-
364 }
never executed: end of block
0
365 else-
366 {-
367 char *ptr;-
368 strtol_error e = xstrtoumax (spec, &ptr, 0, block_size,-
369 "eEgGkKmMpPtTyYzZ0");-
370 if (e != LONGINT_OK
e != LONGINT_OKDescription
TRUEevaluated 6 times by 4 tests
Evaluated by:
  • df
  • dir
  • du
  • vdir
FALSEevaluated 177 times by 2 tests
Evaluated by:
  • df
  • du
)
6-177
371 {-
372 *options = 0;-
373 return
executed 6 times by 4 tests: return e;
Executed by:
  • df
  • dir
  • du
  • vdir
e;
executed 6 times by 4 tests: return e;
Executed by:
  • df
  • dir
  • du
  • vdir
6
374 }-
375 for (; ! ('0' <= *spec
'0' <= *specDescription
TRUEevaluated 177 times by 2 tests
Evaluated by:
  • df
  • du
FALSEnever evaluated
&& *
*spec <= '9'Description
TRUEevaluated 177 times by 2 tests
Evaluated by:
  • df
  • du
FALSEnever evaluated
spec <= '9'
*spec <= '9'Description
TRUEevaluated 177 times by 2 tests
Evaluated by:
  • df
  • du
FALSEnever evaluated
); spec++)
0-177
376 if (spec == ptr
spec == ptrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
377 {-
378 opts |= human_SI;-
379 if (ptr[-1] == 'B'
ptr[-1] == 'B'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
380 opts |= human_B;
never executed: opts |= human_B;
0
381 if (ptr[-1] != 'B'
ptr[-1] != 'B'Description
TRUEnever evaluated
FALSEnever evaluated
|| ptr[-2] == 'i'
ptr[-2] == 'i'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
382 opts |= human_base_1024;
never executed: opts |= human_base_1024;
0
383 break;
never executed: break;
0
384 }-
385 }
executed 177 times by 2 tests: end of block
Executed by:
  • df
  • du
177
386 }-
387-
388 *options = opts;-
389 return
executed 1795 times by 5 tests: return LONGINT_OK;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
LONGINT_OK;
executed 1795 times by 5 tests: return LONGINT_OK;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
1795
390}-
391-
392enum strtol_error-
393human_options (char const *spec, int *opts, uintmax_t *block_size)-
394{-
395 strtol_error e = humblock (spec, block_size, opts);-
396 if (*
*block_size == 0Description
TRUEevaluated 4 times by 3 tests
Evaluated by:
  • df
  • dir
  • vdir
FALSEevaluated 1797 times by 5 tests
Evaluated by:
  • df
  • dir
  • du
  • ls
  • vdir
block_size == 0
*block_size == 0Description
TRUEevaluated 4 times by 3 tests
Evaluated by:
  • df
  • dir
  • vdir
FALSEevaluated 1797 times by 5 tests
Evaluated by:
  • df
  • dir
  • du
  • ls
  • vdir
)
4-1797
397 {-
398 *block_size = default_block_size ();-
399 e = LONGINT_INVALID;-
400 }
executed 4 times by 3 tests: end of block
Executed by:
  • df
  • dir
  • vdir
4
401 return
executed 1801 times by 5 tests: return e;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
e;
executed 1801 times by 5 tests: return e;
Executed by:
  • df
  • dir
  • du
  • ls
  • vdir
1801
402}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2