Skip to content

Commit

Permalink
[fix](csv-reader) fix column split error when there is escape charact…
Browse files Browse the repository at this point in the history
…er (#34364) (#34505)
  • Loading branch information
liaoxin01 authored May 8, 2024
1 parent 21db960 commit 0a38945
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ void EncloseCsvLineReaderContext::_on_normal(const uint8_t* start, size_t& len)
}

void EncloseCsvLineReaderContext::_on_pre_match_enclose(const uint8_t* start, size_t& len) {
bool should_escape = false;
do {
do {
if (start[_idx] == _escape) [[unlikely]] {
should_escape = !should_escape;
} else if (should_escape) [[unlikely]] {
should_escape = false;
_should_escape = !_should_escape;
} else if (_should_escape) [[unlikely]] {
_should_escape = false;
} else if (start[_idx] == _enclose) [[unlikely]] {
_state.forward_to(ReaderState::MATCH_ENCLOSE);
++_idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class EncloseCsvLineReaderContext final

inline void refresh_impl() {
_idx = 0;
_should_escape = false;
_result = nullptr;
_column_sep_positions.clear();
_state.reset();
Expand Down Expand Up @@ -168,6 +169,7 @@ class EncloseCsvLineReaderContext final
const size_t _column_sep_len;

size_t _idx = 0;
bool _should_escape = false;

const std::string _column_sep;
std::vector<size_t> _column_sep_positions;
Expand Down

0 comments on commit 0a38945

Please sign in to comment.