diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-23 13:03:44 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-23 13:03:44 (GMT) |
commit | 54ec927d886b895b1ec7bbe62c143b052970fdf6 (patch) | |
tree | 3cc9a9a066c237cf46cf107e48afa8f7a0e20aab /src/portable.cpp | |
parent | 38337d6d42a0630b988728b89fd016bec5b46c1c (diff) | |
download | Doxygen-54ec927d886b895b1ec7bbe62c143b052970fdf6.zip Doxygen-54ec927d886b895b1ec7bbe62c143b052970fdf6.tar.gz Doxygen-54ec927d886b895b1ec7bbe62c143b052970fdf6.tar.bz2 |
Fix for use of non portable strnstr function
Diffstat (limited to 'src/portable.cpp')
-rw-r--r-- | src/portable.cpp | 15 |
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; +} |