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 option to cancel overwrites #245

Merged
merged 1 commit into from
Oct 28, 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
1 change: 1 addition & 0 deletions include/zsv/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ struct zsv_opt_overwrite {
enum zsv_status (*open)(void *ctx);
enum zsv_status (*next)(void *ctx, struct zsv_overwrite_data *odata);
enum zsv_status (*close)(void *ctx);
char cancel; // explicitly cancel application of overwrites
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/zsv_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ static int zsv_scanner_init(struct zsv_scanner *scanner, struct zsv_opts *opts)
(scanner->row.cells = calloc(scanner->row.allocated, sizeof(*scanner->row.cells)))) {
#ifdef ZSV_EXTRAS
// initialize overwrites
if (scanner->opts.overwrite.open) {
if (scanner->opts.overwrite.open && !scanner->opts.overwrite.cancel) {
if (scanner->opts.overwrite.open(scanner->opts.overwrite.ctx) == zsv_status_ok) {
scanner->overwrite.odata.have = 1;
scanner->overwrite.next = scanner->opts.overwrite.next;
Expand Down