summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2010-03-21 12:32:51 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2010-03-21 12:32:51 +0000
commit216502ddea2127a385be2b14ee46d504540b92c5 (patch)
treeb95866677166f59861eb2dd7f61711b142b75362
parentSet a+rx permissions on /usr/bin/python-config to work around systems with br... (diff)
downloadeselect-python-216502ddea2127a385be2b14ee46d504540b92c5.tar.gz
eselect-python-216502ddea2127a385be2b14ee46d504540b92c5.tar.bz2
eselect-python-216502ddea2127a385be2b14ee46d504540b92c5.zip
Fix building on systems without strtok_r() (bug #299152).
-rw-r--r--configure.ac3
-rw-r--r--python-wrapper.c8
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;
}