mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
cursor: refactor xcursor_theme_inherits
Use early returns and breaks to avoid dealing with very long indentation lines. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
963014459c
commit
245d30ecb8
1 changed files with 33 additions and 29 deletions
|
|
@ -755,39 +755,43 @@ xcursor_theme_inherits(const char *full)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
f = fopen(full, "r");
|
f = fopen(full, "r");
|
||||||
if (f) {
|
if (!f)
|
||||||
while (fgets(line, sizeof(line), f)) {
|
return NULL;
|
||||||
if (!strncmp(line, "Inherits", 8)) {
|
|
||||||
char *l = line + 8;
|
while (fgets(line, sizeof(line), f)) {
|
||||||
char *r;
|
if (strncmp(line, "Inherits", 8))
|
||||||
while (*l == ' ')
|
continue;
|
||||||
l++;
|
|
||||||
if (*l != '=')
|
char *l = line + 8;
|
||||||
continue;
|
char *r;
|
||||||
|
while (*l == ' ')
|
||||||
|
l++;
|
||||||
|
if (*l != '=')
|
||||||
|
continue;
|
||||||
|
l++;
|
||||||
|
while (*l == ' ')
|
||||||
|
l++;
|
||||||
|
result = malloc(strlen(l) + 1);
|
||||||
|
if (!result)
|
||||||
|
break;
|
||||||
|
|
||||||
|
r = result;
|
||||||
|
while (*l) {
|
||||||
|
while (xcursor_sep(*l) || xcursor_white(*l))
|
||||||
l++;
|
l++;
|
||||||
while (*l == ' ')
|
if (!*l)
|
||||||
l++;
|
|
||||||
result = malloc(strlen(l) + 1);
|
|
||||||
if (result) {
|
|
||||||
r = result;
|
|
||||||
while (*l) {
|
|
||||||
while (xcursor_sep(*l) || xcursor_white(*l))
|
|
||||||
l++;
|
|
||||||
if (!*l)
|
|
||||||
break;
|
|
||||||
if (r != result)
|
|
||||||
*r++ = ':';
|
|
||||||
while (*l && !xcursor_white(*l) &&
|
|
||||||
!xcursor_sep(*l))
|
|
||||||
*r++ = *l++;
|
|
||||||
}
|
|
||||||
*r++ = '\0';
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
if (r != result)
|
||||||
|
*r++ = ':';
|
||||||
|
while (*l && !xcursor_white(*l) && !xcursor_sep(*l))
|
||||||
|
*r++ = *l++;
|
||||||
}
|
}
|
||||||
fclose(f);
|
*r++ = '\0';
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue