mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 77d0498b6c7c52772dbcc3ce53edadf5b9505430
parent d6815bf78f37500bc378fdd406387ee6ef869d46
Author: Christian Neukirchen <chneukirchen@gmail.com>
Date:   Thu,  4 Aug 2016 20:20:15 +0200

seq: fix message number reporting when using iterdir

Diffstat:
seq.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/seq.c b/seq.c @@ -315,17 +315,19 @@ blaze822_seq_next(char *map, char *range, struct blaze822_seq_iter *iter) return r; } -static void +static long iterdir(char *dir, void (*cb)(char *)) { DIR *fd, *fd2; struct dirent *d; + long i = 0; + fd = opendir(dir); if (!fd) { if (errno == ENOTDIR) cb(dir); - return; + return 1; } char sub[PATH_MAX]; @@ -348,8 +350,11 @@ iterdir(char *dir, void (*cb)(char *)) else snprintf(sub, sizeof sub, "%s/%s", dir, d->d_name); cb(sub); + i++; } closedir(fd); + + return i; } int @@ -376,8 +381,7 @@ blaze822_loop(int argc, char *argv[], void (*cb)(char *)) int j = 0; for (i = 0; i < argc; i++) { if (strchr(argv[i], '/')) { // a file name - iterdir(argv[i], cb); - j++; + j += iterdir(argv[i], cb); } else { while ((line = blaze822_seq_next(map, argv[i], &iter))) { cb(line);