summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/markdown.cpp3
-rw-r--r--src/portable.cpp15
-rw-r--r--src/portable.h1
3 files changed, 18 insertions, 1 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 0a71aae..8594a15 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -51,6 +51,7 @@
#include "config.h"
#include "section.h"
#include "message.h"
+#include "portable.h"
//-----------
@@ -1031,7 +1032,7 @@ static int processCodeSpan(GrowBuf &out, const char *data, int /*offset*/, int s
static void addStrEscapeUtf8Nbsp(GrowBuf &out,const char *s,int len)
{
- if (strnstr(s,g_doxy_nsbp,len)==0) // no escape needed -> fast
+ if (Portable::strnstr(s,g_doxy_nsbp,len)==0) // no escape needed -> fast
{
out.addStr(s,len);
}
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;
+}
diff --git a/src/portable.h b/src/portable.h
index 27b7052..be73435 100644
--- a/src/portable.h
+++ b/src/portable.h
@@ -42,6 +42,7 @@ namespace Portable
bool isAbsolutePath(const char *fileName);
void correct_path(void);
void setShortDir(void);
+ char * strnstr(const char *haystack, const char *needle, size_t haystack_len);
}