1
0
mirror of https://repo.or.cz/libtar.git synced 2025-04-19 16:02:14 +03:00
libtar/compat/strrstr.c
Chris Frey 1fc76aab90 libtar-1.2.11 tarball sources, taken from Debian's orig tar
The main site, feep.net, has a broken ftp link, so can't download
tarball from there.
2009-04-28 16:35:00 -04:00

41 lines
771 B
C

/*
** Copyright 1998-2002 University of Illinois Board of Trustees
** Copyright 1998-2002 Mark D. Roth
** All rights reserved.
**
** strrstr.c - strrstr() function for compatibility library
**
** Mark D. Roth <roth@uiuc.edu>
** Campus Information Technologies and Educational Services
** University of Illinois at Urbana-Champaign
*/
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
/*
** find the last occurrance of find in string
*/
char *
strrstr(char *string, char *find)
{
size_t stringlen, findlen;
char *cp;
findlen = strlen(find);
stringlen = strlen(string);
if (findlen > stringlen)
return NULL;
for (cp = string + stringlen - findlen; cp >= string; cp--)
if (strncmp(cp, find, findlen) == 0)
return cp;
return NULL;
}