projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
[mmh]
/
uip
/
pick.c
diff --git
a/uip/pick.c
b/uip/pick.c
index
afbcf88
..
fb63111
100644
(file)
--- a/
uip/pick.c
+++ b/
uip/pick.c
@@
-2,9
+2,7
@@
/*
* pick.c -- search for messages by content
*
/*
* 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.
*/
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
*/
@@
-68,12
+66,13
@@
static struct swit switches[] = {
static int listsw = -1;
static int listsw = -1;
-static int putzero_done (int);
+static void putzero_done (int) NORETURN;
int
main (int argc, char **argv)
{
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;
int lo, hi, msgnum;
char *maildir, *folder = NULL, buf[100];
char *cp, **argp, **arguments;
@@
-114,11
+113,11
@@
main (int argc, char **argv)
invo_name);
print_help (buf, switches, 1);
listsw = 0; /* HACK */
invo_name);
print_help (buf, switches, 1);
listsw = 0; /* HACK */
- done (1);
+ done (0);
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
- done (1);
+ done (0);
case CCSW:
case DATESW:
case CCSW:
case DATESW:
@@
-153,6
+152,10
@@
main (int argc, char **argv)
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
/* 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 PUBLSW:
seqs[seqp++] = cp;
continue;
case PUBLSW:
@@
-233,6
+236,11
@@
main (int argc, char **argv)
lo = mp->lowsel;
hi = mp->hghsel;
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.
/*
* Scan through all the SELECTED messages and check for a
* match. If the message does not match, then unselect it.
@@
-246,6
+254,9
@@
main (int argc, char **argv)
lo = msgnum;
if (msgnum > hi)
hi = msgnum;
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);
} else {
/* if it doesn't match, then unselect it */
unset_selected (mp, msgnum);
@@
-272,13
+283,9
@@
main (int argc, char **argv)
done (1);
/*
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");
}
printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s");
}
@@
-286,15
+293,15
@@
main (int argc, char **argv)
seq_save (mp); /* synchronize message sequences */
context_save (); /* save the context file */
folder_free (mp); /* free folder/message structure */
seq_save (mp); /* synchronize message sequences */
context_save (); /* save the context file */
folder_free (mp); /* free folder/message structure */
- return done (0);
+ done (0);
+ return 1;
}
}
-static int
+static void
putzero_done (int status)
{
if (listsw && status && !isatty (fileno (stdout)))
printf ("0\n");
exit (status);
putzero_done (int status)
{
if (listsw && status && !isatty (fileno (stdout)))
printf ("0\n");
exit (status);
- return 1; /* dead code to satisfy the compiler */
}
}