Revision 12455,
716 bytes
checked in by danw, 26 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r12454,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
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: r1bindex.c,v 1.1.1.1 1999-02-07 18:14:09 danw Exp $ |
---|
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 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.