]> diplodocus.org Git - nmh/blob - sbr/r1bindex.c
Added steps to README.developers saying to change the version number to
[nmh] / sbr / r1bindex.c
1
2 /*
3 * r1bindex.c -- Given a string and a character, return a pointer
4 * -- to the right of the rightmost occurrence of the
5 * -- character. If the character doesn't occur, the
6 * -- pointer will be at the beginning of the string.
7 *
8 * $Id$
9 */
10
11 #include <h/mh.h>
12
13
14 char *
15 r1bindex(char *str, int chr)
16 {
17 char *cp;
18
19 /* find null at the end of the string */
20 for (cp = str; *cp; cp++)
21 continue;
22
23 /* backup to the rightmost character */
24 --cp;
25
26 /* now search for the rightmost occurrence of the character */
27 while (cp >= str && *cp != chr)
28 --cp;
29
30 /* now move one to the right */
31 return (++cp);
32 }