aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/rindex.c
blob: 74169120c20559feecdd40977c11e5302e2aa309 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#define	import_libc
#define	import_spp
#include <iraf.h>


/* RINDEX -- Search string STR for char CH, returning a pointer to the last
** occurrence of CH in STR or NULL.
*/
char *
rindex (
  char	*str,			/* string to be searched		*/
  int	ch			/* character we are searching for	*/
)
{
	register char	*ip = str;
	register char	*last = NULL;

	do {
	    if (*ip == ch)
		last = ip;
	} while (*ip++);

	return (last);
}