]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR 63589 Fix splitting of PATH in find_addr2line.
authorJanne Blomqvist <jb@gcc.gnu.org>
Mon, 20 Oct 2014 08:16:06 +0000 (11:16 +0300)
committerJanne Blomqvist <jb@gcc.gnu.org>
Mon, 20 Oct 2014 08:16:06 +0000 (11:16 +0300)
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.

From-SVN: r216451

libgfortran/ChangeLog
libgfortran/config.h.in
libgfortran/configure
libgfortran/configure.ac
libgfortran/runtime/main.c

index 06d9da20d48329c09d21c175be72f123d6e4c1a0..97a4fb1b199ef4f7745c5ed43bff912d793d7f6a 100644 (file)
@@ -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-08-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR libgfortran/62188
index fb5026fc0da37b334728d9e21eebf12d593e188c..a391e95b0e1ae5ac9315c022351bf6932db315a8 100644 (file)
 /* 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
 
index ee99e6c89a5635b8e86f9b85aa3471eb8cdac919..d26b379db8a8c25a7c0fb8645feb9d45ff4a87fd 100755 (executable)
@@ -2595,6 +2595,7 @@ as_fn_append ac_func_list " umask"
 as_fn_append ac_func_list " getegid"
 as_fn_append ac_func_list " secure_getenv"
 as_fn_append ac_func_list " __secure_getenv"
+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.
@@ -12339,7 +12340,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12342 "configure"
+#line 12343 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12445,7 +12446,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12448 "configure"
+#line 12449 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16558,6 +16559,8 @@ done
 
 
 
+
+
 
 
 
index 7d97fed1b0bdf80a6cd95f121bedba62549449b3..bdb71ff3d20e86031d8e9dd62cc78cb121e7a256 100644 (file)
@@ -267,7 +267,7 @@ alarm access fork execl wait setmode execve pipe dup2 close \
 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)
+secure_getenv __secure_getenv strtok_r)
 
 # Check strerror_r, cannot be above as versions with two and three arguments exist
 LIBGFOR_CHECK_STRERROR_R
index d774cfb8ae1d1c10c446a65a9c43fc5559dc5bb6..32033ba3e900969f0d1f2941887533e8fdf3ef3e 100644 (file)
@@ -153,6 +153,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.  */
@@ -161,30 +171,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
 }