[hackers] [scc] [libc] Add strrchr() || Roberto E. Vargas Caballero
commit 008332b425b189c60ecff4e8a2d9096e3b7aa62b
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 16 21:24:06 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 16 21:24:06 2017 +0100
[libc] Add strrchr()
diff --git a/libc/src/Makefile b/libc/src/Makefile
index 22d2301..43228ab 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -1,7 +1,8 @@
# See LICENSE file for copyright and license details.
.POSIX:
-LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o
+LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
+ strrchr.o
all: libc.a
diff --git a/libc/src/strrchr.c b/libc/src/strrchr.c
new file mode 100644
index 0000000..2f246d1
--- /dev/null
+++ b/libc/src/strrchr.c
_AT_@ -0,0 +1,15 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+char *
+strrchr(const char *s, int c)
+{
+ char *t;
+
+ for (t = (char *) s; *t; ++t)
+ /* nothing */;
+ while (t > s && *t != c)
+ --t;
+ return (*t == c) ? t : NULL;
+}
Received on Thu Feb 16 2017 - 21:24:56 CET
This archive was generated by hypermail 2.3.0
: Thu Feb 16 2017 - 21:36:52 CET