aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libgfortran/ChangeLog10
-rw-r--r--libgfortran/config.h.in3
-rwxr-xr-xlibgfortran/configure10
-rw-r--r--libgfortran/configure.ac3
-rw-r--r--libgfortran/runtime/main.c44
5 files changed, 51 insertions, 19 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index cf04401..e226002 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,13 @@
+2014-10-20 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/63589
+ * configure.ac: Check for strtok_r.
+ * runtime/main.c (gfstrtok_r): Fallback implementation of
+ strtok_r.
+ (find_addr2line): Use strtok_r to split PATH.
+ * config.h.in: Regenerated.
+ * configure: Regenerated.
+
2014-10-09 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* ieee/ieee_helper.c (ieee_is_finite_*, ieee_is_nan_*,
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index de7937f..b69e5b7 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -744,6 +744,9 @@
/* Define to 1 if you have the `strtof' function. */
#undef HAVE_STRTOF
+/* Define to 1 if you have the `strtok_r' function. */
+#undef HAVE_STRTOK_R
+
/* Define to 1 if you have the `strtold' function. */
#undef HAVE_STRTOLD
diff --git a/libgfortran/configure b/libgfortran/configure
index a4951bf..df17829 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -2604,6 +2604,7 @@ as_fn_append ac_func_list " __secure_getenv"
as_fn_append ac_func_list " mkostemp"
as_fn_append ac_func_list " strnlen"
as_fn_append ac_func_list " strndup"
+as_fn_append ac_func_list " strtok_r"
as_fn_append ac_header_list " math.h"
# Check that the precious variables saved in the cache have kept the same
# value.
@@ -12349,7 +12350,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12352 "configure"
+#line 12353 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12455,7 +12456,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12458 "configure"
+#line 12459 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16485,6 +16486,9 @@ $as_echo "#define HAVE_STRNLEN 1" >>confdefs.h
$as_echo "#define HAVE_STRNDUP 1" >>confdefs.h
+$as_echo "#define HAVE_STRTOK_R 1" >>confdefs.h
+
+
# At some point, we should differentiate between architectures
# like x86, which have long double versions, and alpha/powerpc/etc.,
# which don't. For the time being, punt.
@@ -16621,6 +16625,8 @@ done
+
+
fi
# Check strerror_r, cannot be above as versions with two and three arguments exist
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 9d8e05c..b3150f4 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -275,6 +275,7 @@ if test "x${with_newlib}" = "xyes"; then
AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have gmtime_r.])
AC_DEFINE(HAVE_STRNLEN, 1, [Define if you have strnlen.])
AC_DEFINE(HAVE_STRNDUP, 1, [Define if you have strndup.])
+ AC_DEFINE(HAVE_STRTOK_R, 1, [Define if you have strtok_r.])
# At some point, we should differentiate between architectures
# like x86, which have long double versions, and alpha/powerpc/etc.,
@@ -289,7 +290,7 @@ else
strcasestr getrlimit gettimeofday stat fstat lstat getpwuid vsnprintf dup \
getcwd localtime_r gmtime_r getpwuid_r ttyname_r clock_gettime \
readlink getgid getpid getppid getuid geteuid umask getegid \
- secure_getenv __secure_getenv mkostemp strnlen strndup)
+ secure_getenv __secure_getenv mkostemp strnlen strndup strtok_r)
fi
# Check strerror_r, cannot be above as versions with two and three arguments exist
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c
index 8a572ec..448dfee 100644
--- a/libgfortran/runtime/main.c
+++ b/libgfortran/runtime/main.c
@@ -181,6 +181,16 @@ full_exe_path (void)
}
+#ifndef HAVE_STRTOK_R
+static char*
+gfstrtok_r (char *str, const char *delim,
+ char **saveptr __attribute__ ((unused)))
+{
+ return strtok (str, delim);
+}
+#define strtok_r gfstrtok_r
+#endif
+
char *addr2line_path;
/* Find addr2line and store the path. */
@@ -189,30 +199,32 @@ void
find_addr2line (void)
{
#ifdef HAVE_ACCESS
-#define A2L_LEN 10
+#define A2L_LEN 11
char *path = secure_getenv ("PATH");
if (!path)
return;
+ char *tp = strdup (path);
+ if (!tp)
+ return;
size_t n = strlen (path);
- char ap[n + 1 + A2L_LEN];
- size_t ai = 0;
- for (size_t i = 0; i < n; i++)
+ char *ap = xmalloc (n + A2L_LEN);
+ char *saveptr;
+ for (char *str = tp;; str = NULL)
{
- if (path[i] != ':')
- ap[ai++] = path[i];
- else
+ char *token = strtok_r (str, ":", &saveptr);
+ if (!token)
+ break;
+ size_t toklen = strlen (token);
+ memcpy (ap, token, toklen);
+ memcpy (ap + toklen, "/addr2line", A2L_LEN);
+ if (access (ap, R_OK|X_OK) == 0)
{
- ap[ai++] = '/';
- memcpy (ap + ai, "addr2line", A2L_LEN);
- if (access (ap, R_OK|X_OK) == 0)
- {
- addr2line_path = strdup (ap);
- return;
- }
- else
- ai = 0;
+ addr2line_path = strdup (ap);
+ break;
}
}
+ free (tp);
+ free (ap);
#endif
}