From b69338f9f8ae2ae957949a0f4af9749ebb4adc3f Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Thu, 30 May 2002 21:03:17 +0000 Subject: Added code from libc instead of requiring newlib git-svn-id: svn://svn.rockbox.org/rockbox/trunk@835 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/strrchr.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 firmware/common/strrchr.c (limited to 'firmware/common/strrchr.c') diff --git a/firmware/common/strrchr.c b/firmware/common/strrchr.c new file mode 100644 index 0000000000..4f903afe2b --- /dev/null +++ b/firmware/common/strrchr.c @@ -0,0 +1,59 @@ +/* +FUNCTION + <>---reverse search for character in string + +INDEX + strrchr + +ANSI_SYNOPSIS + #include + char * strrchr(const char *<[string]>, int <[c]>); + +TRAD_SYNOPSIS + #include + char * strrchr(<[string]>, <[c]>); + char *<[string]>; + int *<[c]>; + +DESCRIPTION + This function finds the last occurence of <[c]> (converted to + a char) in the string pointed to by <[string]> (including the + terminating null character). + +RETURNS + Returns a pointer to the located character, or a null pointer + if <[c]> does not occur in <[string]>. + +PORTABILITY +<> is ANSI C. + +<> requires no supporting OS subroutines. + +QUICKREF + strrchr ansi pure +*/ + +#include + +char * +_DEFUN (strrchr, (s, i), + _CONST char *s _AND + int i) +{ + _CONST char *last = NULL; + + if (i) + { + while ((s=strchr(s, i))) + { + last = s; + s++; + } + } + else + { + last = strchr(s, i); + } + + return (char *) last; +} -- cgit v1.2.3