/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <stdio_ext.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include "bus-util.h"
+#include "bus-polkit.h"
#include "env-file-label.h"
#include "env-file.h"
#include "env-util.h"
return IN_SET(*s, ',', '\0');
}
-static const char* strnulldash(const char *s) {
- return isempty(s) || streq(s, "-") ? NULL : s;
-}
-
static const char* systemd_kbd_model_map(void) {
const char* s;
if (in_section && first_word(l, "Option")) {
_cleanup_strv_free_ char **a = NULL;
- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return r;
} else if (!in_section && first_word(l, "Section")) {
_cleanup_strv_free_ char **a = NULL;
- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return -ENOMEM;
_cleanup_free_ char *s = NULL;
char **u;
- s = strappend("KEYMAP=", c->vc_keymap);
+ s = strjoin("KEYMAP=", c->vc_keymap);
if (!s)
return -ENOMEM;
_cleanup_free_ char *s = NULL;
char **u;
- s = strappend("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
+ s = strjoin("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
if (!s)
return -ENOMEM;
if (r < 0)
return r;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
(void) fchmod(fileno(f), 0644);
fputs("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
if (IN_SET(l[0], 0, '#'))
continue;
- r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_QUOTES);
+ r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_UNQUOTE);
if (r < 0)
return r;
if (!streq(c->vc_keymap, a[0]))
continue;
- if (!streq_ptr(c->x11_layout, strnulldash(a[1])) ||
- !streq_ptr(c->x11_model, strnulldash(a[2])) ||
- !streq_ptr(c->x11_variant, strnulldash(a[3])) ||
- !streq_ptr(c->x11_options, strnulldash(a[4]))) {
+ if (!streq_ptr(c->x11_layout, empty_or_dash_to_null(a[1])) ||
+ !streq_ptr(c->x11_model, empty_or_dash_to_null(a[2])) ||
+ !streq_ptr(c->x11_variant, empty_or_dash_to_null(a[3])) ||
+ !streq_ptr(c->x11_options, empty_or_dash_to_null(a[4]))) {
- if (free_and_strdup(&c->x11_layout, strnulldash(a[1])) < 0 ||
- free_and_strdup(&c->x11_model, strnulldash(a[2])) < 0 ||
- free_and_strdup(&c->x11_variant, strnulldash(a[3])) < 0 ||
- free_and_strdup(&c->x11_options, strnulldash(a[4])) < 0)
+ if (free_and_strdup(&c->x11_layout, empty_or_dash_to_null(a[1])) < 0 ||
+ free_and_strdup(&c->x11_model, empty_or_dash_to_null(a[2])) < 0 ||
+ free_and_strdup(&c->x11_variant, empty_or_dash_to_null(a[3])) < 0 ||
+ free_and_strdup(&c->x11_options, empty_or_dash_to_null(a[4])) < 0)
return -ENOMEM;
modified = true;
if (startswith_comma(c->x11_layout, a[1]))
matching = 5;
else {
- char *x;
+ _cleanup_free_ char *x = NULL;
/* If that didn't work, strip off the
* other layouts from the entry, too */
- x = strndupa(a[1], strcspn(a[1], ","));
+ x = strndup(a[1], strcspn(a[1], ","));
if (startswith_comma(c->x11_layout, x))
matching = 1;
}