]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
keymap-util: also "convert" 'ru' to 'ru'
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 30 May 2016 02:02:57 +0000 (22:02 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 6 Jun 2016 13:22:33 +0000 (09:22 -0400)
As discovered by Adam Williamson in
https://bugzilla.redhat.com/show_bug.cgi?id=1333998#c32, after the changes in
81fd105a5f9 we would only match compound layouts, i.e. a comma would be
required after 'ru' to match. This seems wrong, and we should match single
layouts like too. So 'ru', 'ru,us' now both match.

startswith_comma is changed to not require a comma, i.e. check that the prefix
matches until a comma or the end of the string. Note that startswith_comma is
called twice. At the first site, we check that strings are not equal
beforehand, so this change to startswith_comma has no effect. At the second
site, it does have an effect, as described above.

src/locale/keymap-util.c
src/locale/test-keymap-util.c

index fe29594ccc9ca29296ed03a36237b0e2a1b7e0ca..17bef9e481d856784a360c47fc7f5fcfc97aee75 100644 (file)
@@ -39,7 +39,7 @@ static bool startswith_comma(const char *s, const char *prefix) {
         if (!s)
                 return false;
 
-        return *s == ',';
+        return *s == ',' || *s == '\0';
 }
 
 static const char* strnulldash(const char *s) {
index 8dde764a50eb28c8e5cbaa43725c25b854cdecd7..1e30fa4cb0566fa75d7924c3191e998a3eb83e69 100644 (file)
@@ -199,6 +199,14 @@ static void test_x11_convert_to_vconsole(void) {
 
         assert_se(x11_convert_to_vconsole(&c) == 1);
         assert_se(streq(c.vc_keymap, "ru"));
+
+        /* https://bugzilla.redhat.com/show_bug.cgi?id=1333998 */
+        log_info("/* test with a simple new mapping (ru:) */");
+        assert_se(free_and_strdup(&c.x11_layout, "ru") >= 0);
+        assert_se(free_and_strdup(&c.x11_variant, NULL) >= 0);
+
+        assert_se(x11_convert_to_vconsole(&c) == 0);
+        assert_se(streq(c.vc_keymap, "ru"));
 }
 
 int main(int argc, char **argv) {