so that ``/To:y'' will search for the field ``y'' in not
just the ``To'' field, but also in the ``Cc'' and ``Bcc'' fields.
SCCS-vsn: usr.bin/mail/list.c 8.3
SCCS-vsn: usr.bin/mail/mail.1 8.6
-static char sccsid[] = "@(#)list.c 8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)list.c 8.3 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
+/*
+ * See if the passed name received the passed message number. Return true
+ * if so.
+ */
+
+static char *to_fields[] = { "to", "cc", "bcc", 0 };
+
+matchto(str, mesg)
+ char *str;
+{
+ register struct message *mp;
+ register char *cp, *cp2, *backup, **to;
+
+ str++;
+
+ if (*str == 0) /* null string matches nothing instead of everything */
+ return(0);
+
+ mp = &message[mesg-1];
+
+ for (to = to_fields; *to; to++) {
+ cp = str;
+ cp2 = hfield(*to, mp);
+ if (cp2 != NOSTR) {
+ backup = cp2;
+ while (*cp2) {
+ if (*cp == 0)
+ return(1);
+ if (raise(*cp++) != raise(*cp2++)) {
+ cp2 = ++backup;
+ cp = str;
+ }
+ }
+ if (*cp == 0)
+ return(1);
+ }
+ }
+ return(0);
+}
+
/*
* See if the given string matches inside the subject field of the
* given message. For the purpose of the scan, we ignore case differences.
/*
* See if the given string matches inside the subject field of the
* given message. For the purpose of the scan, we ignore case differences.
*/
if (value("searchheaders") && (cp = index(str, ':'))) {
*/
if (value("searchheaders") && (cp = index(str, ':'))) {
+ /* Check for special case "/To:" */
+ if (raise(str[0]) == 'T' && raise(str[1]) == 'O' &&
+ str[2] == ':')
+ return(matchto(cp, mesg));
*cp++ = '\0';
cp2 = hfield(str, mp);
cp[-1] = ':';
*cp++ = '\0';
cp2 = hfield(str, mp);
cp[-1] = ':';
.\"
.\" %sccs.include.redist.roff%
.\"
.\"
.\" %sccs.include.redist.roff%
.\"
-.\" @(#)mail.1 8.5 (Berkeley) %G%
+.\" @(#)mail.1 8.6 (Berkeley) %G%
If this option is set, then a message-list specifier in the form ``/x:y''
will expand to all messages containing the substring ``y'' in the header
field ``x''. The string search is case insensitive.
If this option is set, then a message-list specifier in the form ``/x:y''
will expand to all messages containing the substring ``y'' in the header
field ``x''. The string search is case insensitive.
+The form ``/To:y'' is a special case, and will expand
+to all messages containing the substring ``y'' in the ``To'', ``Cc''
+or ``Bcc'' header fields.
.It Ar verbose
Setting the option
.Ar verbose
.It Ar verbose
Setting the option
.Ar verbose