+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
if (!s)
return false;
- return *s == ',' || *s == '\0';
+ return IN_SET(*s, ',', '\0');
}
static const char* strnulldash(const char *s) {
char_array_0(line);
l = strstrip(line);
- if (l[0] == 0 || l[0] == '#')
+ if (IN_SET(l[0], 0, '#'))
continue;
if (in_section && first_word(l, "Option")) {
fchmod(fileno(f), 0644);
- fputs("# Read and parsed by systemd-localed. It's probably wise not to edit this file\n"
- "# manually too freely.\n"
- "Section \"InputClass\"\n"
- " Identifier \"system-keyboard\"\n"
- " MatchIsKeyboard \"on\"\n", f);
+ fputs_unlocked("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
+ "# probably wise not to edit this file manually. Use localectl(1) to\n"
+ "# instruct systemd-localed to update it.\n"
+ "Section \"InputClass\"\n"
+ " Identifier \"system-keyboard\"\n"
+ " MatchIsKeyboard \"on\"\n", f);
if (!isempty(c->x11_layout))
fprintf(f, " Option \"XkbLayout\" \"%s\"\n", c->x11_layout);
if (!isempty(c->x11_options))
fprintf(f, " Option \"XkbOptions\" \"%s\"\n", c->x11_options);
- fputs("EndSection\n", f);
+ fputs_unlocked("EndSection\n", f);
- r = fflush_and_check(f);
+ r = fflush_sync_and_check(f);
if (r < 0)
goto fail;
return 0;
fail:
- (void) unlink("/etc/X11/xorg.conf.d/00-keyboard.conf");
-
if (temp_path)
(void) unlink(temp_path);
(*n)++;
l = strstrip(line);
- if (l[0] == 0 || l[0] == '#')
+ if (IN_SET(l[0], 0, '#'))
continue;
r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_QUOTES);
_cleanup_free_ char *n;
if (x11_variant)
- n = strjoin(x11_layout, "-", x11_variant, NULL);
+ n = strjoin(x11_layout, "-", x11_variant);
else
n = strdup(x11_layout);
if (!n)
_cleanup_free_ char *p = NULL, *pz = NULL;
bool uncompressed;
- p = strjoin(dir, "xkb/", n, ".map", NULL);
- pz = strjoin(dir, "xkb/", n, ".map.gz", NULL);
+ p = strjoin(dir, "xkb/", n, ".map");
+ pz = strjoin(dir, "xkb/", n, ".map.gz");
if (!p || !pz)
return -ENOMEM;