Skip to content

Commit

Permalink
Merge pull request #248 from gorcha/strl-fix
Browse files Browse the repository at this point in the history
Fix incorrect ordering in StrL comparison functions
  • Loading branch information
evanmiller authored Jul 25, 2021
2 parents da4d2e5 + 778b6f2 commit 9348374
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/readstat_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ static int readstat_compare_string_refs(const void *elem1, const void *elem2) {
readstat_string_ref_t *ref1 = *(readstat_string_ref_t **)elem1;
readstat_string_ref_t *ref2 = *(readstat_string_ref_t **)elem2;

if (ref1->first_v == ref2->first_v)
return ref1->first_o - ref2->first_o;
if (ref1->first_o == ref2->first_o)
return ref1->first_v - ref2->first_v;

return ref1->first_v - ref2->first_v;
return ref1->first_o - ref2->first_o;
}

readstat_string_ref_t *readstat_string_ref_init(const char *string) {
Expand Down
6 changes: 3 additions & 3 deletions src/stata/readstat_dta_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ static readstat_error_t dta_read_tag(dta_ctx_t *ctx, const char *tag) {
static int dta_compare_strls(const void *elem1, const void *elem2) {
const dta_strl_t *key = (const dta_strl_t *)elem1;
const dta_strl_t *target = *(const dta_strl_t **)elem2;
if (key->v == target->v)
return key->o - target->o;
if (key->o == target->o)
return key->v - target->v;

return key->v - target->v;
return key->o - target->o;
}

static dta_strl_t dta_interpret_strl_vo_bytes(dta_ctx_t *ctx, const unsigned char *vo_bytes) {
Expand Down

0 comments on commit 9348374

Please sign in to comment.