Uniquefy gdb.threads/attach-into-signal.exp
[deliverable/binutils-gdb.git] / gdb / solib.c
index 0010c2fe45c6daf012b721e9515c61f81d270423..eb933c044d55b99f6042ff88ec4eca0ce9d6bf30 100644 (file)
@@ -158,32 +158,27 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib)
   const char *fskind = effective_target_file_system_kind ();
   struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
   char *sysroot = gdb_sysroot;
-
-  if (sysroot != NULL)
-    {
-      /* If the absolute prefix starts with "target:" but the
-        filesystem accessed by the target_fileio_* methods
-        is the local filesystem then we strip the "target:"
-        prefix now and work with the local filesystem.  This
-        ensures that the same search algorithm is used for
-        all local files regardless of whether a "target:"
-        prefix was used.  */
-      if (is_target_filename (sysroot) && target_filesystem_is_local ())
-       sysroot += strlen (TARGET_SYSROOT_PREFIX);
-
-      if (*sysroot == '\0')
-       sysroot = NULL;
-    }
-
-  if (sysroot != NULL)
+  int prefix_len, orig_prefix_len;
+
+  /* If the absolute prefix starts with "target:" but the filesystem
+     accessed by the target_fileio_* methods is the local filesystem
+     then we strip the "target:" prefix now and work with the local
+     filesystem.  This ensures that the same search algorithm is used
+     for all local files regardless of whether a "target:" prefix was
+     used.  */
+  if (is_target_filename (sysroot) && target_filesystem_is_local ())
+    sysroot += strlen (TARGET_SYSROOT_PREFIX);
+
+  /* Strip any trailing slashes from the absolute prefix.  */
+  prefix_len = orig_prefix_len = strlen (sysroot);
+
+  while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
+    prefix_len--;
+
+  if (prefix_len == 0)
+    sysroot = NULL;
+  else if (prefix_len != orig_prefix_len)
     {
-      int prefix_len = strlen (sysroot);
-
-      /* Remove trailing slashes from absolute prefix.  */
-      while (prefix_len > 0
-            && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
-       prefix_len--;
-
       sysroot = savestring (sysroot, prefix_len);
       make_cleanup (xfree, sysroot);
     }
This page took 0.028273 seconds and 4 git commands to generate.