diff --git a/src/readstat/stata/readstat_dta_read.c b/src/readstat/stata/readstat_dta_read.c index 8dc4ace5..becdb4dc 100644 --- a/src/readstat/stata/readstat_dta_read.c +++ b/src/readstat/stata/readstat_dta_read.c @@ -1,6 +1,3 @@ - -#define _XOPEN_SOURCE 700 /* for strnlen */ - #include #include #include @@ -9,6 +6,16 @@ #include #include +#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L +size_t strnlen(const char* s, size_t maxlen) { + const char* end; + end = memchr(s, '\0', maxlen); + if (end == NULL) + return maxlen; + return end - s; +} +#endif + #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h"