Skip to content

Commit

Permalink
fix paste bug if fewer rows in subsequent input. to do: add tests (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty authored Oct 1, 2023
1 parent a7e59bb commit 05b9429
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/paste.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ static int zsv_paste_load_row(struct zsv_paste_input_file *inputs) {
static void zsv_paste_print_row(zsv_csv_writer w, struct zsv_paste_input_file *inputs) {
char first = 1;
for(struct zsv_paste_input_file *pf = inputs; pf; pf = pf->next) {
unsigned int j = zsv_cell_count(pf->parser);
unsigned int j = pf->zsv_status == zsv_status_row ? zsv_cell_count(pf->parser) : 0;
unsigned int k = pf->col_count;

for(unsigned int i = 0; i < j && i < k; i++) {
struct zsv_cell cell = zsv_get_cell(pf->parser, i);
zsv_writer_cell(w, first, cell.str, cell.len, cell.quoted);
first = 0;
}
for(unsigned int i = j; i < k; i++)
for(unsigned int i = j; i < k; i++) {
zsv_writer_cell(w, first, (const unsigned char *)"", 0, 0);
first = 0;
}
}
}

Expand Down

0 comments on commit 05b9429

Please sign in to comment.