Skip to content

Commit

Permalink
Fix 2-character prefix search (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
zcsahok authored Nov 4, 2023
1 parent 3e60a4e commit e6e0c48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dxcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,16 @@ int find_best_match(const char *call) {
/* first check if it has a unique 2-char prefix */
if (strlen(call) >= 2) {
int key = prefix_hash_key(call);
if (two_char_prefix_index[key] >= 0) {
return two_char_prefix_index[key];
w = two_char_prefix_index[key];
if (w >= 0) {
bool ok = true;
// for an exact entry require the whole call to match
if (prefix_by_index(w)->exact) {
ok = (strcmp(prefix_by_index(w)->pfx, call) == 0);
}
if (ok) {
return w;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions test/test_getctydata.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void test_best_match(void **state) {
assert_string_equal(best_prefix("EA8XYZ"), "EA8");
assert_string_equal(best_prefix("W3A"), "W");
assert_string_equal(best_prefix("KL7ND"), "KL");
assert_string_equal(best_prefix("G8AAA"), "G");
}

void test_location_known(void **state) {
Expand Down

0 comments on commit e6e0c48

Please sign in to comment.