xref: /original-bsd/usr.bin/f77/libF77/rindex_.c (revision 5fb3de76)
1 /*
2 char id_rindex[] = "@(#)rindex_.c	1.2";
3  *
4  * find last occurrence of substring in string
5  *
6  * calling sequence:
7  *	character*(*) substr, string
8  *	indx = rindex (string, substr)
9  * where:
10  *	indx will be the index of the first character of the last occurence
11  *	of substr in string, or zero if not found.
12  */
13 
14 long rindex_(str, substr, slen, sublen)
15 char *str, *substr; long slen, sublen;
16 {
17 	register char *p = str + (slen - sublen);
18 
19 	while (p >= str)
20 		if (s_cmp(substr, p, sublen, slen) == 0)
21 			return((long)(++p - str));
22 		else
23 			p--;
24 	return(0L);
25 }
26