aboutsummaryrefslogtreecommitdiff
path: root/djb/str_rchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'djb/str_rchr.c')
-rw-r--r--djb/str_rchr.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/djb/str_rchr.c b/djb/str_rchr.c
new file mode 100644
index 0000000..ce7ab37
--- /dev/null
+++ b/djb/str_rchr.c
@@ -0,0 +1,9 @@
+unsigned int str_rchr(const char *in, char needle) /*EXTRACT_INCL*/ {
+ char ch;
+ unsigned int u=0, found = (unsigned int)-1;
+ for (;; u++) {
+ if ((ch=in[u])==0) break;
+ if (ch==needle) found=u;
+ }
+ return (found != (unsigned int)-1) ? found : u;
+}