Skip to content

Commit

Permalink
fix 139: compare files if input has duplicate column names (#165)
Browse files Browse the repository at this point in the history
fix bug in colname comparison
  • Loading branch information
liquidaty authored Apr 12, 2024
1 parent af4979b commit a084e8e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/compare_unique_colname.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
static int zsv_compare_unique_colname_cmp(zsv_compare_unique_colname *x, zsv_compare_unique_colname *y) {
return x->instance_num == y->instance_num ?
zsv_stricmp(x->name, y->name) : x->instance_num > y->instance_num ? 1 : 0;
zsv_stricmp(x->name, y->name) : x->instance_num > y->instance_num ? 1 : x->instance_num < y->instance_num ? -1 : 0;
}

SGLIB_DEFINE_RBTREE_FUNCTIONS(zsv_compare_unique_colname, left, right, color, zsv_compare_unique_colname_cmp);
Expand Down Expand Up @@ -75,8 +75,12 @@ zsv_compare_unique_colname_add(zsv_compare_unique_colname **tree,
_new_col =
zsv_compare_unique_colname_add_if_not_found(tree, s, len,
instance_num, &added);
if(!added) // should not happen
if(!added) { // should not happen
#ifndef NDEBUG
fprintf(stderr, "Unexpected error! %s: %i\n", __FILE__, __LINE__);
#endif
return zsv_compare_status_error;
}
}
*new_col = _new_col;
return zsv_compare_status_ok;
Expand Down

0 comments on commit a084e8e

Please sign in to comment.