From 2799131d44876a12fbbc150afa688ad997ffb723 Mon Sep 17 00:00:00 2001 From: Chip Turner Date: Tue, 23 Dec 2014 10:19:39 -0800 Subject: [PATCH] Fix Dwarf path handling to fix broken test Summary: Simplify the logic slightly to better handle joining paths. This makes DwarfTest.cpp pass. Test Plan: runtests Reviewed By: njormrod@fb.com Subscribers: lins, anca, folly-diffs@ FB internal diff: D1756036 Tasks: 5871014 Signature: t1:1756036:1419359254:123cc508b8836ea0b1485abe361b1c158538aa08 --- folly/experimental/symbolizer/Dwarf.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/folly/experimental/symbolizer/Dwarf.cpp b/folly/experimental/symbolizer/Dwarf.cpp index d2385aa5..03c8e447 100644 --- a/folly/experimental/symbolizer/Dwarf.cpp +++ b/folly/experimental/symbolizer/Dwarf.cpp @@ -257,21 +257,18 @@ size_t Dwarf::Path::toBuffer(char* buf, size_t bufSize) const { void Dwarf::Path::toString(std::string& dest) const { size_t initialSize = dest.size(); - bool needsSlash = false; dest.reserve(initialSize + size()); if (!baseDir_.empty()) { dest.append(baseDir_.begin(), baseDir_.end()); - needsSlash = baseDir_.endsWith('/'); } if (!subDir_.empty()) { - if (needsSlash) { + if (!dest.empty() && dest.back() != '/') { dest.push_back('/'); } dest.append(subDir_.begin(), subDir_.end()); - needsSlash = subDir_.endsWith('/'); } if (!file_.empty()) { - if (needsSlash) { + if (!dest.empty() && dest.back() != '/') { dest.push_back('/'); } dest.append(file_.begin(), file_.end()); -- 2.34.1