* docs/MAIL.FILTERING: added note on removing procmail -f or
[mmh] / sbr / ssequal.c
1
2 /*
3  * ssequal.c -- check if a string is a substring of another
4  *
5  * $Id$
6  *
7  * This code is Copyright (c) 2002, by the authors of nmh.  See the
8  * COPYRIGHT file in the root directory of the nmh distribution for
9  * complete copyright information.
10  */
11
12 #include <h/mh.h>
13
14 /*
15  * THIS CODE DOES NOT WORK AS ADVERTISED.
16  * It is actually checking if s1 is a PREFIX of s2.
17  * All calls to this function need to be checked to see
18  * if that needs to be changed. Prefix checking is cheaper, so
19  * should be kept if it's sufficient.
20  */
21
22 /*
23  * Check if s1 is a substring of s2.
24  * If yes, then return 1, else return 0.
25  */
26
27 int
28 ssequal (char *s1, char *s2)
29 {
30     if (!s1)
31         s1 = "";
32     if (!s2)
33         s2 = "";
34
35     while (*s1)
36         if (*s1++ != *s2++)
37             return 0;
38     return 1;
39 }