Skip to content

Commit 0f532b6

Browse files
committed
Check for functions instead of OS
1 parent 42466e2 commit 0f532b6

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ AC_PROG_CXX
55
AC_PROG_LN_S
66
AC_PROG_RANLIB
77
AC_CHECK_HEADER_STDBOOL
8-
AC_CHECK_FUNCS([inet_ntoa memmove strchr strdup strstr strtoul])
8+
AC_CHECK_FUNCS([inet_ntoa memmove strnchr strdup strnstr strtoul])
99
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
1010
AC_FUNC_MALLOC
1111
AC_FUNC_REALLOC

src/util.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "util.h"
22

3-
#ifndef __APPLE__
4-
53
#include <string.h>
64

5+
#ifndef HAVE_STRNCHR
6+
77
const char* strnchr(const char* str, size_t len, int character) {
88
const char* end = str + len;
99
char c = (char) character;
@@ -17,6 +17,10 @@ const char* strnchr(const char* str, size_t len, int character) {
1717
return NULL;
1818
}
1919

20+
#endif /* HAVE_STRNCHR */
21+
22+
#ifndef HAVE_STRNSTR
23+
2024
const char* strnstr(const char* str, const char* find, size_t len)
2125
{
2226
char c, sc;
@@ -43,4 +47,4 @@ const char* strnstr(const char* str, const char* find, size_t len)
4347
return ((char*) str);
4448
}
4549

46-
#endif /* __APPLE__ */
50+
#endif /* HAVE_STRNSTR */

src/util.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#ifndef __UTIL_H__
22
#define __UTIL_H__
33

4-
#ifndef __APPLE__
5-
64
#include <stdlib.h>
75

6+
#ifndef HAVE_STRNCHR
87
const char* strnchr(const char* str, size_t len, int character);
9-
const char* strnstr(const char* str, const char* find, size_t len);
8+
#endif /* HAVE_STRNCHR */
109

11-
#endif /* __APPLE__ */
10+
#ifndef HAVE_STRNSTR
11+
const char* strnstr(const char* str, const char* find, size_t len);
12+
#endif /* HAVE_STRNSTR */
1213

1314
#endif /* __UTIL_H__ */

0 commit comments

Comments
 (0)