summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2002-06-25 05:28:32 +0000
committermikeh <mikeh@FreeBSD.org>2002-06-25 05:28:32 +0000
commit94e2e299e42e15276cab292210f3ecf041a3e28b (patch)
tree0a4568460101b434b7ba283450e76624c5b40be7 /usr.bin
parent92912abb162c809019c1c1d0f16c01be2d8be533 (diff)
downloadFreeBSD-src-94e2e299e42e15276cab292210f3ecf041a3e28b.zip
FreeBSD-src-94e2e299e42e15276cab292210f3ecf041a3e28b.tar.gz
Use strcasestr() instead of reimplementing it.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/list.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c
index cfe493e..5eacfb5 100644
--- a/usr.bin/mail/list.c
+++ b/usr.bin/mail/list.c
@@ -669,21 +669,14 @@ matchsender(str, mesg)
char *str;
int mesg;
{
- char *cp, *cp2, *backup;
+ char *cp;
- if (*str == '\0') /* null string matches nothing instead of everything */
+ /* null string matches nothing instead of everything */
+ if (*str == '\0')
return (0);
- backup = cp2 = nameof(&message[mesg - 1], 0);
- cp = str;
- while (*cp2 != '\0') {
- if (*cp == '\0')
- return (1);
- if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- return (*cp == '\0');
+
+ cp = nameof(&message[mesg - 1], 0);
+ return (strcasestr(cp, str) != NULL);
}
/*
@@ -699,7 +692,7 @@ matchto(str, mesg)
int mesg;
{
struct message *mp;
- char *cp, *cp2, *backup, **to;
+ char *cp, **to;
str++;
@@ -710,21 +703,9 @@ matchto(str, mesg)
mp = &message[mesg - 1];
for (to = to_fields; *to != NULL; to++) {
- cp = str;
- cp2 = hfield(*to, mp);
- if (cp2 != NULL) {
- backup = cp2;
- while (*cp2 != '\0') {
- if (*cp == '\0')
- return (1);
- if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- if (*cp == '\0')
- return (1);
- }
+ cp = hfield(*to, mp);
+ if (cp != NULL && strcasestr(cp, str) != NULL)
+ return (1);
}
return (0);
}
@@ -749,7 +730,7 @@ matchfield(str, mesg)
int mesg;
{
struct message *mp;
- char *cp, *cp2, *backup;
+ char *cp, *cp2;
str++;
if (*str == '\0')
@@ -770,22 +751,14 @@ matchfield(str, mesg)
cp2 = hfield(*str != '\0' ? str : "subject", mp);
cp[-1] = ':';
str = cp;
- } else {
- cp = str;
- cp2 = hfield("subject", mp);
- }
- if (cp2 == NULL)
+ cp = cp2;
+ } else
+ cp = hfield("subject", mp);
+
+ if (cp == NULL)
return (0);
- backup = cp2;
- while (*cp2 != '\0') {
- if (*cp == '\0')
- return (1);
- if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- return (*cp == 0);
+
+ return (strcasestr(cp, str) != NULL);
}
/*
OpenPOWER on IntegriCloud