diff options
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | python-wrapper.c | 8 |
2 files changed, 10 insertions, 1 deletions
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; } |