From 92912abb162c809019c1c1d0f16c01be2d8be533 Mon Sep 17 00:00:00 2001 From: mikeh Date: Tue, 25 Jun 2002 05:24:30 +0000 Subject: Make the 'searchheaders' option behave how it was supposed to. If enabled, the string '/to:y' will match strings in the To, Cc, and Bcc header fields. Whereas, '/To:y' will match only the To field. Edit the manpage and a code comment to indicate the correct behavior. --- usr.bin/mail/extern.h | 2 +- usr.bin/mail/list.c | 23 ++++++++++++++--------- usr.bin/mail/mail.1 | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'usr.bin/mail') diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h index 7385abc..9c3c7ad 100644 --- a/usr.bin/mail/extern.h +++ b/usr.bin/mail/extern.h @@ -169,7 +169,7 @@ void makemessage(FILE *, int); void mark(int); int markall(char [], int); int matchsender(char *, int); -int matchsubj(char *, int); +int matchfield(char *, int); int mboxit(int []); int member(char *, struct ignoretab *); void mesedit(FILE *, int); diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c index be5df83..cfe493e 100644 --- a/usr.bin/mail/list.c +++ b/usr.bin/mail/list.c @@ -273,7 +273,7 @@ number: for (i = 1; i <= msgCount; i++) { for (mc = 0, np = &namelist[0]; *np != NULL; np++) if (**np == '/') { - if (matchsubj(*np, i)) { + if (matchfield(*np, i)) { mc++; break; } @@ -730,16 +730,21 @@ matchto(str, mesg) } /* - * 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 it does, return true. The string search argument is assumed to - * have the form "/search-string." If it is of the form "/," we use the - * previous search string. + * See if the given substring is contained within the specified field. If + * 'searchheaders' is set, then the form '/x:y' will be accepted and matches + * any message with the substring 'y' in field 'x'. If 'x' is omitted or + * 'searchheaders' is not set, then the search matches any messages + * with the substring 'y' in the 'Subject'. The search is case insensitive. + * + * The form '/to:y' is a special case, and will match all messages + * containing the substring 'y' in the 'To', 'Cc', or 'Bcc' header + * fields. The search for 'to' is case sensitive, so that '/To:y' can + * be used to limit the search to just the 'To' field. */ char lastscan[STRINGLEN]; int -matchsubj(str, mesg) +matchfield(str, mesg) char *str; int mesg; { @@ -758,8 +763,8 @@ matchsubj(str, mesg) */ if (value("searchheaders") && (cp = strchr(str, ':')) != NULL) { - /* Check for special case "/To:" */ - if (strncasecmp(str, "To:", 3) == 0) + /* Check for special case "/to:" */ + if (strncmp(str, "to:", 3) == 0) return (matchto(cp, mesg)); *cp++ = '\0'; cp2 = hfield(*str != '\0' ? str : "subject", mp); diff --git a/usr.bin/mail/mail.1 b/usr.bin/mail/mail.1 index 3457ee1..bc865b3 100644 --- a/usr.bin/mail/mail.1 +++ b/usr.bin/mail/mail.1 @@ -1076,7 +1076,7 @@ header fields. The check for .Qq Li "to" is case sensitive, so that -.Dq Li /to: Ns Ar y +.Dq Li /To: Ns Ar y can be used to limit the search for .Ar y to just the -- cgit v1.1