Commit 2799131d authored by Chip Turner's avatar Chip Turner Committed by Dave Watson

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
parent b4746252
...@@ -257,21 +257,18 @@ size_t Dwarf::Path::toBuffer(char* buf, size_t bufSize) const { ...@@ -257,21 +257,18 @@ size_t Dwarf::Path::toBuffer(char* buf, size_t bufSize) const {
void Dwarf::Path::toString(std::string& dest) const { void Dwarf::Path::toString(std::string& dest) const {
size_t initialSize = dest.size(); size_t initialSize = dest.size();
bool needsSlash = false;
dest.reserve(initialSize + size()); dest.reserve(initialSize + size());
if (!baseDir_.empty()) { if (!baseDir_.empty()) {
dest.append(baseDir_.begin(), baseDir_.end()); dest.append(baseDir_.begin(), baseDir_.end());
needsSlash = baseDir_.endsWith('/');
} }
if (!subDir_.empty()) { if (!subDir_.empty()) {
if (needsSlash) { if (!dest.empty() && dest.back() != '/') {
dest.push_back('/'); dest.push_back('/');
} }
dest.append(subDir_.begin(), subDir_.end()); dest.append(subDir_.begin(), subDir_.end());
needsSlash = subDir_.endsWith('/');
} }
if (!file_.empty()) { if (!file_.empty()) {
if (needsSlash) { if (!dest.empty() && dest.back() != '/') {
dest.push_back('/'); dest.push_back('/');
} }
dest.append(file_.begin(), file_.end()); dest.append(file_.begin(), file_.end());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment