blob: 097ef9182dd1aba993b21310f48c96ed653a419e [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001/*
2** Copyright 1998-2002 University of Illinois Board of Trustees
3** Copyright 1998-2002 Mark D. Roth
4** All rights reserved.
5**
6** strrstr.c - strrstr() function for compatibility library
7**
8** Mark D. Roth <roth@uiuc.edu>
9** Campus Information Technologies and Educational Services
10** University of Illinois at Urbana-Champaign
11*/
12
13#include <stdio.h>
14#include <sys/types.h>
15
16#include <string.h>
17
18
19/*
20** find the last occurrance of find in string
21*/
22char *
23strrstr(char *string, char *find)
24{
25 size_t stringlen, findlen;
26 char *cp;
27
28 findlen = strlen(find);
29 stringlen = strlen(string);
30 if (findlen > stringlen)
31 return NULL;
32
33 for (cp = string + stringlen - findlen; cp >= string; cp--)
34 if (strncmp(cp, find, findlen) == 0)
35 return cp;
36
37 return NULL;
38}
39
40