Skip to content

Commit

Permalink
Cleanup the listing of installable themes for issue ice-wm/icewm#179.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Nov 12, 2024
1 parent af29b75 commit be06f91
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/theminst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,25 @@ static void install_extra(const char* name, bool* result) {
int k = 0;
char line[1234];
while (fgets(line, sizeof line, fp)) {
char* a = strchr(line, '/');
if (a) {
char* b = strchr(++a, '/');
char* c = strchr(a, '.');
if (b ? (b[1] == '\n') :
(a[1] && (c == nullptr || ASCII::isDigit(c[1])))) {
if (++k > 1)
putchar(' ');
fwrite(a, 1, b ? (b - a) : strlen(a), stdout);
char* nl = strchr(line, '\n');
if (nl) {
*nl = '\0';
} else {
nl = line + strlen(line);
}
if (nl > line && nl[-1] == '/') {
*--nl = '\0';
}
char* sl = strchr(line, '/');
if (sl && *++sl && strchr(sl, '/') == nullptr) {
char* dot = strchr(sl, '.');
if (dot == nullptr || ASCII::isDigit(dot[1])) {
if (strncmp(sl, "README", 6) &&
strncmp(sl, "LICENS", 6)) {
if (++k > 1)
putchar(' ');
fwrite(sl, 1, nl - sl, stdout);
}
}
}
}
Expand Down

0 comments on commit be06f91

Please sign in to comment.