mirror of
https://github.com/red0124/ssp.git
synced 2025-12-14 21:59:55 +01:00
Fix resplit segmentation fault, fix issues when working with empty files
This commit is contained in:
@@ -37,6 +37,10 @@ public:
|
||||
: file_name_{file_name}, reader_{file_name_, delim} {
|
||||
if (reader_.file_) {
|
||||
read_line();
|
||||
if (eof_) {
|
||||
set_error_eof_reached();
|
||||
return;
|
||||
}
|
||||
if constexpr (ignore_header) {
|
||||
ignore_next();
|
||||
} else {
|
||||
|
||||
@@ -78,11 +78,10 @@ private:
|
||||
const std::string& delimiter = default_delimiter) {
|
||||
|
||||
// resplitting, continue from last slice
|
||||
if constexpr (!quote::enabled || !multiline::enabled) {
|
||||
if (split_data_.empty() || !unterminated_quote()) {
|
||||
set_error_invalid_resplit();
|
||||
return split_data_;
|
||||
}
|
||||
if (!quote::enabled || !multiline::enabled || split_data_.empty() ||
|
||||
!unterminated_quote()) {
|
||||
set_error_invalid_resplit();
|
||||
return split_data_;
|
||||
}
|
||||
|
||||
const auto [old_line, old_begin] = *std::prev(split_data_.end());
|
||||
@@ -90,7 +89,6 @@ private:
|
||||
|
||||
// safety measure
|
||||
if (new_size != -1 && static_cast<size_t>(new_size) < begin) {
|
||||
unterminated_quote_ = false;
|
||||
set_error_invalid_resplit();
|
||||
return split_data_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user