From 0c06f2fab0b95bee81d319883c4fb6e552e32de5 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 14 Apr 2008 12:26:08 +0200 Subject: [PATCH] build system: Check if strtok_r needs _REENTRANT Resolves: #8 --- configure.in | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/configure.in b/configure.in index db344978..d9fc92da 100644 --- a/configure.in +++ b/configure.in @@ -371,6 +371,68 @@ AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr AC_FUNC_STRERROR_R +AC_CACHE_CHECK([for strtok_r], + [have_strtok_r_default], + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[[[ +#include +#include +#include + ]]]], + [[[[ + char buffer[] = "foo,bar,baz"; + char *token; + char *dummy; + char *saveptr; + + dummy = buffer; + saveptr = NULL; + while ((token = strtok_r (dummy, ",", &saveptr)) != NULL) + { + dummy = NULL; + printf ("token = %s;\n", token); + } + ]]]]), + [have_strtok_r_default="yes"], + [have_strtok_r_default="no"] + ) +) + +if test "x$have_strtok_r_default" = "xno" +then + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -D_REENTRANT=1" + + AC_CACHE_CHECK([if strtok_r needs _REENTRANT], + [have_strtok_r_reentrant], + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[[[ +#include +#include +#include + ]]]], + [[[[ + char buffer[] = "foo,bar,baz"; + char *token; + char *dummy; + char *saveptr; + + dummy = buffer; + saveptr = NULL; + while ((token = strtok_r (dummy, ",", &saveptr)) != NULL) + { + dummy = NULL; + printf ("token = %s;\n", token); + } + ]]]]), + [have_strtok_r_reentrant="yes"], + [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])] + ) + ) +fi + AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree) socket_needs_socket="no" -- 2.11.0