/*
* pick.c -- search for messages by content
*
- * $Id$
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
+ * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
*/
{ "datefield field", 5 },
#define SEQSW 15
{ "sequence name", 0 },
-#define PUBLSW 16
+#define NSEQSW 16
+ { "nosequence", 0 },
+#define PUBLSW 17
{ "public", 0 },
-#define NPUBLSW 17
+#define NPUBLSW 18
{ "nopublic", 0 },
-#define ZEROSW 18
+#define ZEROSW 19
{ "zero", 0 },
-#define NZEROSW 19
+#define NZEROSW 20
{ "nozero", 0 },
-#define LISTSW 20
+#define LISTSW 21
{ "list", 0 },
-#define NLISTSW 21
+#define NLISTSW 22
{ "nolist", 0 },
-#define VERSIONSW 22
+#define VERSIONSW 23
{ "version", 0 },
-#define HELPSW 23
+#define HELPSW 24
{ "help", 0 },
{ NULL, 0 }
};
static int listsw = -1;
-static void putzero_done (int);
+static void putzero_done (int) NORETURN;
int
main (int argc, char **argv)
{
- int publicsw = -1, zerosw = 1, seqp = 0, vecp = 0;
+ int publicsw = -1, zerosw = 1, vecp = 0;
+ size_t seqp = 0;
int lo, hi, msgnum;
char *maildir, *folder = NULL, buf[100];
char *cp, **argp, **arguments;
invo_name);
print_help (buf, switches, 1);
listsw = 0; /* HACK */
- done (1);
+ done (0);
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
- done (1);
+ done (0);
case CCSW:
case DATESW:
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+
+ if (!seq_nameok (cp))
+ done (1);
+
seqs[seqp++] = cp;
continue;
+ case NSEQSW:
+ seqp = 0;
+ continue;
case PUBLSW:
publicsw = 1;
continue;
lo = mp->lowsel;
hi = mp->hghsel;
+ /* If printing message numbers to standard out, force line buffering on.
+ */
+ if (listsw)
+ setvbuf (stdout, NULL, _IOLBF, 0);
+
/*
* Scan through all the SELECTED messages and check for a
* match. If the message does not match, then unselect it.
lo = msgnum;
if (msgnum > hi)
hi = msgnum;
+
+ if (listsw)
+ printf ("%s\n", m_name (msgnum));
} else {
/* if it doesn't match, then unselect it */
unset_selected (mp, msgnum);
done (1);
/*
- * Print the name of all the matches
+ * Print total matched if not printing each matched message number.
*/
- if (listsw) {
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
- if (is_selected (mp, msgnum))
- printf ("%s\n", m_name (msgnum));
- } else {
+ if (!listsw) {
printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s");
}