Renamed ssequal() to isprefix(), because that's what it checks.
[mmh] / sbr / r1bindex.c
1 /*
2 ** r1bindex.c -- Given a string and a character, return a pointer
3 **            -- to the right of the rightmost occurrence of the
4 **            -- character.  If the character doesn't occur, the
5 **            -- pointer will be at the beginning of the string.
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 char *
16 r1bindex(char *str, int chr)
17 {
18         char *cp;
19
20         /* find null at the end of the string */
21         for (cp = str; *cp; cp++)
22                 continue;
23
24         /* backup to the rightmost character */
25         --cp;
26
27         /* now search for the rightmost occurrence of the character */
28         while (cp >= str && *cp != chr)
29                 --cp;
30
31         /* now move one to the right */
32         return (++cp);
33 }