Skip to content

Commit

Permalink
add option to cancel overwrites (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty authored Oct 28, 2024
1 parent 1b36fcd commit 71b86e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
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

0 comments on commit 71b86e9

Please sign in to comment.