if (match != NULL) {
if (match == addr->name)
n_weight = -4;
- else if (*(match - 1) == ' ')
+ else if (match > addr->name && *(match - 1) == ' ')
n_weight = -3;
else
n_weight = match - addr->name;
else
a_weight = match - addr->address;
- if (*(match + strlen(g_completion_prefix)) == '@')
+ if (strlen(match) < strlen(g_completion_prefix)
+ && *(match + strlen(g_completion_prefix)) == '@')
a_weight--;
}
}
if (n_weight == -4 && a_weight < 0)
n_weight = -5;
- return a_weight < n_weight ? a_weight : n_weight;
+ return MIN(a_weight, n_weight);
}
static gint addr_comparison_func(gconstpointer a, gconstpointer b)