handling of empty dirs & refactoring

This commit is contained in:
nova
2025-07-08 20:51:25 +02:00
parent 7fcd148dfe
commit b6f9633677
6 changed files with 98 additions and 41 deletions

View File

@@ -50,15 +50,14 @@ void colors_init() {
FILE *dircolors = fopen("/etc/DIR_COLORS", "r");
if (dircolors) {
char *line;
char *line = NULL;
char *token;
char *extension;
int tmp = 0;
size_t size = 0;
short fg;
short bg;
while ((tmp = getline(&line, &size, dircolors)) != -1) {
while (getline(&line, &size, dircolors) != -1) {
fg = 7;
bg = 0;
token = strtok(line, " ");
@@ -101,7 +100,7 @@ void colors_init() {
colors = malloc(sizeof(color) * color_count);
unsigned int i = 0;
/* proper pass, reads all defined extensions within /etc/DIR_COLORS */
while ((tmp = getline(&line, &size, dircolors)) != -1) {
while (getline(&line, &size, dircolors) != -1) {
fg = 7;
bg = 0;
if (line[0] == '.') {