| 747 | } |
| 748 | |
| 749 | static bool cv2_line(cv2_context_t *ctx, cv2_span_t input, size_t *position, bool test_row, |
| 750 | cv2_span_t *line) { |
| 751 | size_t start = *position; |
| 752 | while (*position < input.length) { |
| 753 | if (!cv2_step(ctx)) |
| 754 | return false; |
| 755 | unsigned char byte = input.data[(*position)++]; |
| 756 | if (!byte || (!test_row && byte == '\r')) |
| 757 | return cv2_fail(ctx, CBM_COVERAGE_PARSE_FORMAT); |
| 758 | if (byte == '\n') { |
| 759 | size_t length = *position - start - 1; |
| 760 | if (test_row && length && input.data[start + length - 1] == '\r') |
| 761 | length--; |
| 762 | *line = (cv2_span_t){input.data + start, length}; |
| 763 | return true; |
| 764 | } |
| 765 | } |
| 766 | return cv2_fail(ctx, CBM_COVERAGE_PARSE_FORMAT); |
| 767 | } |
| 768 | |
| 769 | static bool cv2_fields(cv2_context_t *ctx, cv2_span_t line, cv2_span_t fields[4]) { |
| 770 | size_t start = 0; |