Adding generic check against the function in addition to check for a problematic compiler.
Fixes: r1878: Make strnlen() visible in old versions of glibc.
Signed-off-by: Andrey Korolyov andrey@xdel.ru --- flash.h | 2 +- helpers.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/flash.h b/flash.h index 24861ba..3af4c43 100644 --- a/flash.h +++ b/flash.h @@ -260,7 +260,7 @@ void tolower_string(char *str); #ifdef __MINGW32__ char* strtok_r(char *str, const char *delim, char **nextp); #endif -#if defined(__DJGPP__) +#if defined(__DJGPP__) || ! defined(HAVE_STRNLEN) size_t strnlen(const char *str, size_t n); #endif
diff --git a/helpers.c b/helpers.c index 7a146c3..cdc87e0 100644 --- a/helpers.c +++ b/helpers.c @@ -92,7 +92,7 @@ char* strtok_r(char *str, const char *delim, char **nextp) #endif
/* There is no strnlen in DJGPP */ -#if defined(__DJGPP__) +#if defined(__DJGPP__) || ! defined(HAVE_STRNLEN) size_t strnlen(const char *str, size_t n) { size_t i;
On Sun, 3 Jan 2016 22:22:19 +0300 Andrey Korolyov andrey@xdel.ru wrote:
Adding generic check against the function in addition to check for a problematic compiler.
Hi Andrey,
thanks for the patch. Did you notice any breakage in the wild? I hesitate to include your change because that could actually break some configurations: in case HAVE_STRNLEN is not defined but strnlen is provided nonetheless linking would fail. Actually I'd be surprised if it would not make problems with other libc implementations.
thanks for the patch. Did you notice any breakage in the wild? I hesitate to include your change because that could actually break some configurations: in case HAVE_STRNLEN is not defined but strnlen is provided nonetheless linking would fail. Actually I'd be surprised if it would not make problems with other libc implementations.
--
Hi Stefan,
NetBSD before 6.0 is definitely the one which breaks here, as well as other late adopters of srtnlen(), like FreeBSD before 8.0. Please feel free to NAK the patch if you think that the support of ancient libcs is not something to worry about (and old BSDs are definitely not LTS distros with ten-year support span).