From 216502ddea2127a385be2b14ee46d504540b92c5 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 21 Mar 2010 12:32:51 +0000 Subject: Fix building on systems without strtok_r() (bug #299152). --- configure.ac | 3 ++- python-wrapper.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 46291cc..9f9d305 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,8 @@ MKDIR="${MKDIR:-${INSTALL} -d}" AC_USE_SYSTEM_EXTENSIONS # setenv() was introduced in POSIX.1-2008. -AC_CHECK_FUNCS([setenv]) +# strtok_r() was introduced in POSIX.1-2001. +AC_CHECK_FUNCS([setenv strtok_r]) # strndup() was introduced in POSIX.1-2008 and is also an implicitly declared built-in function in GCC. AC_MSG_CHECKING([for strndup]) diff --git a/python-wrapper.c b/python-wrapper.c index ecc26bc..0a10bc9 100644 --- a/python-wrapper.c +++ b/python-wrapper.c @@ -50,8 +50,12 @@ const char* find_path(const char* exe) PATH = ":/bin:/usr/bin"; } char* path = strdup(PATH); +#ifdef HAVE_STRTOK_R char* state = NULL; const char* token = strtok_r(path, ":", &state); +#else + const char* token = strtok(path, ":"); +#endif while (token) { /* If an element of PATH is empty ("::"), then it is "." */ @@ -65,7 +69,11 @@ const char* find_path(const char* exe) { return token; } +#ifdef HAVE_STRTOK_R token = strtok_r(NULL, ":", &state); +#else + token = strtok(NULL, ":"); +#endif } return NULL; } -- cgit v1.2.3-65-gdbad