summaryrefslogtreecommitdiff
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/string.c b/src/string.c
index e9c162d..445b466 100644
--- a/src/string.c
+++ b/src/string.c
@@ -7,6 +7,9 @@
* General Public License as published by the Free Software Foundation;
* either version 2.1 or (at your option) any later version.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <errno.h>
#include <limits.h>
#include <math.h> /* nextafter */
@@ -16,6 +19,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
#include <libHX/ctype_helper.h>
#include <libHX/string.h>
#include "internal.h"
@@ -176,7 +182,6 @@ EXPORT_SYMBOL void *HX_memmem(const void *vspace, size_t spacesize,
const char *space = vspace, *point = vpoint;
const char *head, *end;
size_t tailsize;
- char *tail;
if (pointsize == 0)
return const_cast1(void *, vspace);
@@ -185,9 +190,9 @@ EXPORT_SYMBOL void *HX_memmem(const void *vspace, size_t spacesize,
/* Do a BM-style trailer search and reduce calls to memcmp */
head = space + (pointsize - 1);
- tail = memchr(head, point[pointsize-1], spacesize - (pointsize - 1));
+ const char *tail = memchr(head, point[pointsize-1], spacesize - (pointsize - 1));
if (tail == NULL || pointsize == 1)
- return tail;
+ return const_cast1(char *, tail);
end = space + spacesize;
do {
head = tail - pointsize + 1;