]> diplodocus.org Git - nmh/blob - sbr/r1bindex.c
56f8c6a18d8072fe12722eca445cffd33ed5cadd
[nmh] / 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 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 }