Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zsv_row_length_raw_bytes #184

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/zsv/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ ZSV_EXPORT size_t zsv_scanned_length(zsv_parser);
*/
ZSV_EXPORT size_t zsv_cum_scanned_length(zsv_parser parser);

/**
* @return number of raw bytes scanned from the beginning to the end of this row
*/
ZSV_EXPORT size_t zsv_row_length_raw_bytes(zsv_parser parser);

/**
* Check the quoted status of the last cell that was read. This function is only
* applicable when called from within a cell_handler() callback. Furthermore, this
Expand Down
9 changes: 8 additions & 1 deletion src/zsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,14 @@ size_t zsv_scanned_length(zsv_parser parser) {

ZSV_EXPORT
size_t zsv_cum_scanned_length(zsv_parser parser) {
return parser->cum_scanned_length + parser->scanned_length + (parser->had_bom ? strlen(ZSV_BOM) : 0);
return parser->cum_scanned_length +
(parser->finished ? 0 : parser->scanned_length) +
(parser->had_bom ? strlen(ZSV_BOM) : 0);
}

ZSV_EXPORT
size_t zsv_row_length_raw_bytes(zsv_parser parser) {
return parser->scanned_length - parser->row_start;
}

/**
Expand Down
Loading