summaryrefslogtreecommitdiffstats
path: root/src/portable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/portable.cpp')
-rw-r--r--src/portable.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/portable.cpp b/src/portable.cpp
index 1134351..9927c45 100644
--- a/src/portable.cpp
+++ b/src/portable.cpp
@@ -475,3 +475,18 @@ void Portable::setShortDir(void)
delete [] buffer;
#endif
}
+
+
+char *Portable::strnstr(const char *haystack, const char *needle, size_t haystack_len)
+{
+ size_t needle_len = strnlen(needle, haystack_len);
+ if (needle_len < haystack_len || !needle[needle_len])
+ {
+ char *x = static_cast<char*>(memmem(haystack, haystack_len, needle, needle_len));
+ if (x && !memchr(haystack, 0, x - haystack))
+ {
+ return x;
+ }
+ }
+ return 0;
+}