aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2016-07-23 01:16:24 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-28 17:32:24 +0200
commiteaa661050603a25f2b1a4de24c0c44ed0fb93de7 (patch)
tree70ea6736a32275c94d13a51e0802acdf2dd7f4ea
parentab75d14d62a5d57b104ae8f77a489a74025c797f (diff)
downloadmblaze-eaa661050603a25f2b1a4de24c0c44ed0fb93de7.tar.gz
mpick: use blaze822_loop{,1}
-rw-r--r--mpick.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/mpick.c b/mpick.c
index e3197d2..752e980 100644
--- a/mpick.c
+++ b/mpick.c
@@ -100,6 +100,7 @@ struct mailinfo {
static char *argv0;
static long kept;
+static long num;
static struct expr *expr;
static char *cur;
@@ -759,7 +760,7 @@ eval(struct expr *e, struct mailinfo *m)
}
void
-oneline(char *line, long idx)
+oneline(char *line)
{
static int init;
if (!init) {
@@ -775,7 +776,7 @@ oneline(char *line, long idx)
memset(m.subject, 0, sizeof m.subject);
m.fpath = line;
- m.index = idx;
+ m.index = num++;
m.flags = 0;
m.depth = 0;
m.sb = 0;
@@ -832,7 +833,6 @@ main(int argc, char *argv[])
{
long i;
int c;
- char *f, *a;
argv0 = argv[0];
@@ -845,20 +845,10 @@ main(int argc, char *argv[])
for (c = optind; c < argc; c++)
expr = chain(expr, EXPR_AND, parse_msglist(argv[c]));
- struct blaze822_seq_iter iter = { 0 };
-
- char *map = blaze822_seq_open(0);
- if (!map)
- return 1;
-
- a = ":";
- i = 0;
-
- while ((f = blaze822_seq_next(map, a, &iter))) {
- i = iter.line - 1;
- oneline(f, i);
- free(f);
- }
+ if (isatty(0)) {
+ i = blaze822_loop1(":", oneline);
+ } else
+ i = blaze822_loop(0, NULL, oneline);
fprintf(stderr, "%ld mails tested, %ld picked.\n", i, kept);
return 0;