| 796 | } |
| 797 | |
| 798 | static bool cv2_decimal(cv2_context_t *ctx, cv2_span_t span, bool canonical, uint64_t *out) { |
| 799 | if (!span.length || (canonical && span.length > 1 && span.data[0] == '0')) |
| 800 | return cv2_fail(ctx, CBM_COVERAGE_PARSE_FORMAT); |
| 801 | uint64_t value = 0; |
| 802 | for (size_t i = 0; i < span.length; i++) { |
| 803 | if (!cv2_step(ctx)) |
| 804 | return false; |
| 805 | unsigned char byte = span.data[i]; |
| 806 | if (byte < '0' || byte > '9') |
| 807 | return cv2_fail(ctx, CBM_COVERAGE_PARSE_FORMAT); |
| 808 | unsigned digit = (unsigned)(byte - '0'); |
| 809 | if (value > (UINT64_MAX - digit) / 10) |
| 810 | return cv2_fail(ctx, CBM_COVERAGE_PARSE_FORMAT); |
| 811 | value = value * 10 + digit; |
| 812 | } |
| 813 | *out = value; |
| 814 | return true; |
| 815 | } |
| 816 | |
| 817 | static int cv2_hex_digit(unsigned char byte) { |
| 818 | if (byte >= '0' && byte <= '9') |
no test coverage detected