aboutsummaryrefslogtreecommitdiff
path: root/lib/strstr.c
diff options
context:
space:
mode:
authorKlaatu <[email protected]>2015-05-17 15:33:21 +1200
committerKlaatu <[email protected]>2015-05-17 15:33:21 +1200
commitb0de699679e8f1e39af847ed172d1ba605b4370c (patch)
tree01dac00471d61f727394e508c613b29cff0ceae5 /lib/strstr.c
bulk upload of source
Diffstat (limited to 'lib/strstr.c')
-rw-r--r--lib/strstr.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/strstr.c b/lib/strstr.c
new file mode 100644
index 0000000..39e30e5
--- /dev/null
+++ b/lib/strstr.c
@@ -0,0 +1,16 @@
+#include "../ninitfeatures.h"
+
+char *strstr(const char *haystack, const char *needle) /*EXTRACT_INCL*/ {
+ unsigned int nl=str_len(needle);
+ unsigned int hl=str_len(haystack);
+ int i;
+ if (!nl) goto found;
+
+ for (i=hl-nl+1; i>0; --i) {
+ if (*haystack==*needle && !byte_diff(haystack,nl,needle))
+found:
+ return (char*)haystack;
+ ++haystack;
+ }
+ return 0;
+}