Skip to content

Commit

Permalink
fix: reset parser state in StreamParser::next
Browse files Browse the repository at this point in the history
StreamParser::next was missing parsing state reset.
It caused incorrectly parsing the first element of the second and later chunks.
This commit addresses the issue.
  • Loading branch information
hirohira9119 committed Oct 22, 2024
1 parent de3b763 commit e24d625
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/internal/basic_csv_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ namespace csv {
void next(size_t bytes = ITERATION_CHUNK_SIZE) override {
if (this->eof()) return;

// Reset parser state
this->field_start = UNINITIALIZED_FIELD;
this->field_length = 0;
this->reset_data_ptr();
this->data_ptr->_data = std::make_shared<std::string>();

Expand Down
3 changes: 3 additions & 0 deletions single_include/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6143,6 +6143,9 @@ namespace csv {
void next(size_t bytes = ITERATION_CHUNK_SIZE) override {
if (this->eof()) return;

// Reset parser state
this->field_start = UNINITIALIZED_FIELD;
this->field_length = 0;
this->reset_data_ptr();
this->data_ptr->_data = std::make_shared<std::string>();

Expand Down
3 changes: 3 additions & 0 deletions single_include_test/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6143,6 +6143,9 @@ namespace csv {
void next(size_t bytes = ITERATION_CHUNK_SIZE) override {
if (this->eof()) return;

// Reset parser state
this->field_start = UNINITIALIZED_FIELD;
this->field_length = 0;
this->reset_data_ptr();
this->data_ptr->_data = std::make_shared<std::string>();

Expand Down

0 comments on commit e24d625

Please sign in to comment.