diff options
Diffstat (limited to 'gdbsupport/pathstuff.cc')
-rw-r--r-- | gdbsupport/pathstuff.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc index 9c3816c..029e3c9 100644 --- a/gdbsupport/pathstuff.cc +++ b/gdbsupport/pathstuff.cc @@ -198,11 +198,17 @@ path_join (gdb::array_view<const char *> paths) { const char *path = paths[i]; - if (i > 0) - gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path)); - - if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ())) - ret += '/'; + if (!ret.empty ()) + { + /* If RET doesn't already end with a separator then add one. */ + if (!IS_DIR_SEPARATOR (ret.back ())) + ret += '/'; + + /* Now that RET ends with a separator, ignore any at the start of + PATH. */ + while (IS_DIR_SEPARATOR (path[0])) + ++path; + } ret.append (path); } |