]> diplodocus.org Git - nmh/blob - sbr/r1bindex.c
forwsbr.c: Move interface declaration to own forwsbr.h.
[nmh] / sbr / r1bindex.c
1 /* r1bindex.c -- Given a string and a character, return a pointer
2 * -- to the right of the rightmost occurrence of the
3 * -- character. If the character doesn't occur, the
4 * -- pointer will be at the beginning of the string.
5 *
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
9 */
10
11 #include <h/mh.h>
12
13 /* Does not return NULL. */
14 char *
15 r1bindex(char *str, int chr)
16 {
17 char *r;
18
19 if (!chr)
20 return str; /* Match old behaviour, don't know if it's used. */
21
22 r = strrchr(str, chr);
23 if (r)
24 return r + 1;
25
26 return str;
27 }