Skip to content

Commit

Permalink
Correct splitting document paths
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Jun 3, 2018
1 parent f53850a commit ea5a3f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ cmake_policy(SET CMP0048 NEW)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)

project(asdf-cxx VERSION 2.3.0 LANGUAGES CXX)
project(asdf-cxx VERSION 2.3.1 LANGUAGES CXX)
set(PROJECT_DESCRIPTION
"asdf-cxx (Advanced Scientific Data Format), C++ implementation")
set(PROJECT_URL "https://github.com/eschnett/asdf-cxx")
Expand Down
12 changes: 5 additions & 7 deletions reference.cpp
Expand Up @@ -37,10 +37,9 @@ reference::reference(const string &base_target,

pair<string, vector<string>> reference::get_split_target() const {
auto hashpos = target.find('#');
if (hashpos == string::npos) {
if (hashpos == string::npos)
return {target, {}};
}
auto base_target = target.substr(0, hashpos - 1);
auto base_target = target.substr(0, hashpos);
auto fragment = target.substr(hashpos + 1);
vector<string> doc_path;
for (;;) {
Expand All @@ -49,12 +48,11 @@ pair<string, vector<string>> reference::get_split_target() const {
doc_path.push_back(fragment);
break;
}
doc_path.push_back(fragment.substr(0, slashpos - 1));
doc_path.push_back(fragment.substr(0, slashpos));
fragment = fragment.substr(slashpos + 1);
}
// The fragment should either be empty, or should begin with a
// slash. In both cases, the first element of doc_path should have
// length zero.
// The fragment should either be empty, or should begin with a slash. In both
// cases, the first element of doc_path should have length zero.
assert(doc_path.size() > 0);
assert(doc_path.at(0).size() == 0);
doc_path.erase(doc_path.begin());
Expand Down

0 comments on commit ea5a3f1

Please sign in to comment.