diff options
author | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2017-12-20 16:34:35 -0500 |
---|---|---|
committer | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2017-12-20 16:34:35 -0500 |
commit | 48ef7704c03e7e554c05de01bf8d1d70c16cb6f4 (patch) | |
tree | 34d52513de6c903b4f52ef87d885c73472daf469 /libc/string/strrchr.c | |
parent | f49e7cbb33e6e27b0ce5eb35244d7241c800a7c1 (diff) |
add libc building to agbcc.
Diffstat (limited to 'libc/string/strrchr.c')
-rw-r--r-- | libc/string/strrchr.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c new file mode 100644 index 0000000..65160f5 --- /dev/null +++ b/libc/string/strrchr.c @@ -0,0 +1,61 @@ +/* +FUNCTION + <<strrchr>>---reverse search for character in string + +INDEX + strrchr + +ANSI_SYNOPSIS + #include <string.h> + char * strrchr(const char *<[string]>, int <[c]>); + +TRAD_SYNOPSIS + #include <string.h> + 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 +<<strrchr>> is ANSI C. + +<<strrchr>> requires no supporting OS subroutines. + +QUICKREF + strrchr ansi pure +*/ + +#include <string.h> + +char * +_DEFUN (strrchr, (s, i), + _CONST char *s _AND + int i) +{ + _CONST char *last = NULL; + char c = i; + + while (*s) + { + if (*s == c) + { + last = s; + } + s++; + } + + if (*s == c) + { + last = s; + } + + return (char *) last; +} |