include/stencil_expfix.h

filter: Statementstmt 0.0% 0 / 10 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 30 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/arch/Template/Stencil/Install/Files.pm ↑ Summary include/st_abi_impl.h »
1 /* stencil_expfix.h - two-digit exponents everywhere.
2 *
3 * C99 prints at least two exponent digits (1.5e+03); the Windows CRT prints
4 * three (1.5e+003), and the fmt filter's float path goes through that CRT
5 * on purpose (see stencil_filters.c). Dropping the leading zero of a
6 * three-digit exponent gives the same bytes on every platform; a real
7 * three-digit exponent (1e+100) has no leading zero and is kept. Perl-free
8 * so it can be unit-tested on its own.
9 */
10 #ifndef STENCIL_EXPFIX_H
11 #define STENCIL_EXPFIX_H
12  
13 #include <string.h>
14  
15 /* s is NUL-terminated with len bytes before the NUL; returns the new len. */
16 0 static int stencil_expfix(char *s, int len)
17 {
18 int i;
19 0 ▶ for (i = 0; i + 4 < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i + 4 < len; i++) { 0 0 0
20 0 ▶ if ((s[i] == 'e' || s[i] == 'E')
Branch: 2 branches
BranchTrueFalseTotal
if ((s[i] == 'e' || s[i] == 'E') 0 0 0
if ((s[i] == 'e' || s[i] == 'E') 0 0 0
21 0 ▶ && (s[i + 1] == '+' || s[i + 1] == '-')
Branch: 2 branches
BranchTrueFalseTotal
&& (s[i + 1] == '+' || s[i + 1] == '-') 0 0 0
&& (s[i + 1] == '+' || s[i + 1] == '-') 0 0 0
22 0 ▶ && s[i + 2] == '0'
Branch: 1 branch
BranchTrueFalseTotal
&& s[i + 2] == '0' 0 0 0
23 0 ▶ && s[i + 3] >= '0' && s[i + 3] <= '9'
Branch: 2 branches
BranchTrueFalseTotal
&& s[i + 3] >= '0' && s[i + 3] <= '9' 0 0 0
&& s[i + 3] >= '0' && s[i + 3] <= '9' 0 0 0
24 0 ▶ && s[i + 4] >= '0' && s[i + 4] <= '9') {
Branch: 2 branches
BranchTrueFalseTotal
&& s[i + 4] >= '0' && s[i + 4] <= '9') { 0 0 0
&& s[i + 4] >= '0' && s[i + 4] <= '9') { 0 0 0
25 0 memmove(s + i + 2, s + i + 3, (size_t)(len - (i + 3)) + 1);
26 0 len--;
27 }
28 }
29 0 return len;
30 }
31  
32 #endif /* STENCIL_EXPFIX_H */
« blib/arch/Template/Stencil/Install/Files.pm ↑ Summary include/st_abi_impl.h »