Commit | Line | Data |
---|---|---|
6d4cbc1e | 1 | /* |
5a178c25 | 2 | char id_rindex[] = "@(#)rindex_.c 1.2"; |
6d4cbc1e DW |
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) | |
5a178c25 | 20 | if (s_cmp(substr, p, sublen, slen) == 0) |
6d4cbc1e DW |
21 | return((long)(++p - str)); |
22 | else | |
23 | p--; | |
24 | return(0L); | |
25 | } |