| 497 | } |
| 498 | |
| 499 | static enum field_terminator |
| 500 | scan_mb_blank_field (mbbuf_t *mbbuf, struct mbfield_parser *parser, |
| 501 | bool *have_pending_line, bool write_field, |
| 502 | idx_t *n_bytes) |
| 503 | { |
| 504 | if (parser->trim_outer_whitespace && parser->at_line_start) |
| 505 | { |
| 506 | enum field_terminator terminator |
| 507 | = skip_whitespace_run (mbbuf, parser, have_pending_line, false); |
| 508 | if (terminator != FIELD_DATA) |
| 509 | return terminator; |
| 510 | } |
| 511 | |
| 512 | parser->at_line_start = false; |
| 513 | |
| 514 | while (true) |
| 515 | { |
| 516 | mcel_t g = mbbuf_get_saved_char (mbbuf, &parser->have_saved, |
| 517 | &parser->saved_g); |
| 518 | if (g.ch == MBBUF_EOF) |
| 519 | return FIELD_EOF; |
| 520 | |
| 521 | *have_pending_line = true; |
| 522 | |
| 523 | if (g.ch == line_delim) |
| 524 | return FIELD_LINE_DELIMITER; |
| 525 | |
| 526 | if (mcel_isblank (g)) |
| 527 | return skip_whitespace_run (mbbuf, parser, have_pending_line, true); |
| 528 | |
| 529 | if (n_bytes) |
| 530 | append_field_1_bytes (mbbuf, g, n_bytes); |
| 531 | else if (write_field) |
| 532 | write_bytes (mbbuf_char_offset (mbbuf, g), g.len); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | static enum field_terminator |
| 537 | scan_mb_delim_field (mbbuf_t *mbbuf, bool *have_pending_line, |
no test coverage detected