#include "strv.h"
static bool startswith_comma(const char *s, const char *prefix) {
- const char *t;
+ s = startswith(s, prefix);
+ if (!s)
+ return false;
- return s && (t = startswith(s, prefix)) && (*t == ',');
+ return *s == ',';
}
static const char* strnulldash(const char *s) {
unsigned best_matching = 0;
int r;
+ assert(!isempty(c->x11_layout));
+
f = fopen(SYSTEMD_KBD_MODEL_MAP, "re");
if (!f)
return -errno;
break;
/* Determine how well matching this entry is */
- if (streq_ptr(c->x11_layout, a[1]))
+ if (streq(c->x11_layout, a[1]))
/* If we got an exact match, this is best */
matching = 10;
else {
}
}
- return 0;
+ return (bool) *new_keymap;
}
int find_language_fallback(const char *lang, char **language) {
bool modified = false;
if (isempty(c->x11_layout)) {
-
modified =
!isempty(c->vc_keymap) ||
!isempty(c->vc_keymap_toggle);
if (r < 0)
return r;
}
+ if (r == 0)
+ /* We search for layout-variant match first, but then we also look
+ * for anything which matches just the layout. So it's accurate to say
+ * that we couldn't find anything which matches the layout. */
+ log_notice("No conversion to virtual console map found for \"%s\".",
+ c->x11_layout);
if (!streq_ptr(c->vc_keymap, new_keymap)) {
free(c->vc_keymap);
assert_se(ans == NULL);
c.x11_layout = (char*) "pl";
- assert_se(find_legacy_keymap(&c, &ans) == 0); /* should this be 1? */
+ assert_se(find_legacy_keymap(&c, &ans) == 1);
assert_se(streq(ans, "pl2"));
c.x11_layout = (char*) "pl,ru";
- assert_se(find_legacy_keymap(&c, &ans2) == 0); /* should this be 1? */
+ assert_se(find_legacy_keymap(&c, &ans2) == 1);
assert_se(streq(ans, "pl2"));
}