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