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