From 4a8ce049471a53512de524260225ee15c63068e0 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 16:36:42 +0100 Subject: Reformatted t_mft() --- FICS/utils.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'FICS') diff --git a/FICS/utils.c b/FICS/utils.c index aab8ce8..cf6f9b3 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -915,37 +915,42 @@ PRIVATE void t_cft(struct t_tree **t) } } -/* make file tree for dir d */ -PRIVATE void t_mft(struct t_dirs *d) +/* + * Make file tree for dir 'd' + */ +PRIVATE void +t_mft(struct t_dirs *d) { - DIR *dirp; + DIR *dirp; #ifdef USE_DIRENT - struct dirent *dp; + struct dirent *dp; #else - struct direct *dp; + struct direct *dp; #endif - struct t_tree **t; + struct t_tree **t; - if ((dirp = opendir(&(d->name))) == NULL) { - fprintf(stderr, "FICS:mft() couldn't opendir.\n"); - } else { - while ((dp = readdir(dirp))) { - t = &d->files; - if (dp->d_name[0] != '.') { /* skip anything starting with . */ - while (*t) { - if (strcmp(dp->d_name, &(*t)->name) < 0) { - t = &(*t)->left; - } else { - t = &(*t)->right; - } + if ((dirp = opendir(&(d->name))) == NULL) { + fprintf(stderr, "FICS: %s: couldn't opendir\n", __func__); + return; } - *t = rmalloc(sizeof(struct t_tree) + strlen(dp->d_name)); - (*t)->right = (*t)->left = NULL; - strcpy(&(*t)->name, dp->d_name); - } - } - closedir(dirp); - } + while ((dp = readdir(dirp))) { + t = &d->files; + + if (dp->d_name[0] != '.') { // skip anything starting with '.' + while (*t) { + if (strcmp(dp->d_name, &(*t)->name) < 0) + t = &(*t)->left; + else + t = &(*t)->right; + } + + *t = rmalloc(sizeof(struct t_tree) + + strlen(dp->d_name)); + (*t)->right = (*t)->left = NULL; + strcpy(&(*t)->name, dp->d_name); + } + } + closedir(dirp); } /* -- cgit v1.2.3