find_legacy_keymap: extend variant match bonus again

If the column is "-" and the X context variant specifer only
contains commas, we should also give the match bonus. The variant
string is supposed to be a comma-separated list as long as the
list of layouts, so it's quite natural for consumers to be written
in such a way that they pass a string only containing commas if
there are multiple layouts and no variants. anaconda is a real
world case that does this.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson
2023-09-22 08:07:12 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent c650d4cdef
commit 537c00c984
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -839,7 +839,7 @@ int find_legacy_keymap(const X11Context *xc, char **ret) {
if (isempty(xc->model) || streq_ptr(xc->model, a[2])) {
matching++;
if (streq_ptr(xc->variant, a[3]) || (isempty(xc->variant) && streq(a[3], "-"))) {
if (streq_ptr(xc->variant, a[3]) || ((isempty(xc->variant) || streq_skip_trailing_chars(xc->variant, "", ",")) && streq(a[3], "-"))) {
matching++;
if (streq_ptr(xc->options, a[4]))
+7
View File
@@ -185,6 +185,13 @@ TEST(x11_convert_to_vconsole) {
assert_se(streq(vc.keymap, "bg_bds-utf8"));
vc_context_clear(&vc);
/* same, but with variant specified as "," */
log_info("/* test with variant as ',', desired match second (bg,us:) */");
assert_se(free_and_strdup(&xc.variant, ",") >= 0);
assert_se(x11_convert_to_vconsole(&xc, &vc) >= 0);
assert_se(streq(vc.keymap, "bg_bds-utf8"));
vc_context_clear(&vc);
log_info("/* test with old mapping (fr:latin9) */");
assert_se(free_and_strdup(&xc.layout, "fr") >= 0);
assert_se(free_and_strdup(&xc.variant, "latin9") >= 0);