Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | int | - |
6 | dtoastr (char *buf, size_t bufsize, int flags, int width, double x) | - |
7 | { | - |
8 | double promoted_x = x; | - |
9 | char format[sizeof "%-+ 0*.*Lg"]; | - |
10 | double abs_x = x < 0TRUE | evaluated 6 times by 1 test | FALSE | evaluated 1076 times by 2 tests |
? -x : x; | 6-1076 |
11 | int prec; | - |
12 | | - |
13 | char *p = format; | - |
14 | *p++ = '%'; | - |
15 | | - |
16 | | - |
17 | *p = '-'; p += (flags & FTOASTR_LEFT_JUSTIFY ) != 0; | - |
18 | *p = '+'; p += (flags & FTOASTR_ALWAYS_SIGNED ) != 0; | - |
19 | *p = ' '; p += (flags & FTOASTR_SPACE_POSITIVE) != 0; | - |
20 | *p = '0'; p += (flags & FTOASTR_ZERO_PAD ) != 0; | - |
21 | | - |
22 | *p++ = '*'; | - |
23 | *p++ = '.'; | - |
24 | *p++ = '*'; | - |
25 | *p = 'L'; p += 2 < 2; | - |
26 | *p++ = flags & FTOASTR_UPPER_ETRUE | never evaluated | FALSE | evaluated 1082 times by 2 tests |
? 'G' : 'g'; | 0-1082 |
27 | *p = '\0'; | - |
28 | | - |
29 | for (prec = abs_x < ((double)2.22507385850720138309e-308L) ? 1 : 15; ; prec++) | - |
30 | { | - |
31 | int n = snprintf (buf, bufsize, format, width, prec, promoted_x); | - |
32 | if (n < 0TRUE | never evaluated | FALSE | evaluated 2790 times by 2 tests |
| 0-2790 |
33 | || (((((TRUE | evaluated 357 times by 2 tests | FALSE | evaluated 2433 times by 2 tests |
53) * 1) * 146 + 484) / 485) + 1) <= precTRUE | evaluated 357 times by 2 tests | FALSE | evaluated 2433 times by 2 tests |
| 357-2433 |
34 | || (n < bufsizeTRUE | evaluated 2433 times by 2 tests | FALSE | never evaluated |
&& strtod (buf, TRUE | evaluated 725 times by 2 tests | FALSE | evaluated 1708 times by 2 tests |
| 0-2433 |
35 | ((void *)0)TRUE | evaluated 725 times by 2 tests | FALSE | evaluated 1708 times by 2 tests |
| 725-1708 |
36 | ) == xTRUE | evaluated 725 times by 2 tests | FALSE | evaluated 1708 times by 2 tests |
)) | 725-1708 |
37 | returnexecuted 1082 times by 2 tests: return n; n;executed 1082 times by 2 tests: return n; | 1082 |
38 | }executed 1708 times by 2 tests: end of block | 1708 |
39 | } never executed: end of block | 0 |
| | |