From d3375746658b2fa5fd85717a1d336ed301d2ba8d Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 11 Feb 2021 19:22:17 -0500 Subject: [PATCH] fix parsing of relative branch paths --- src/branches.cpp | 4 +++- tests/tests.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/branches.cpp b/src/branches.cpp index b8ca5ebb..99a0eaf8 100644 --- a/src/branches.cpp +++ b/src/branches.cpp @@ -79,7 +79,9 @@ namespace l { uint64_t offset; - offset = s_.find_first_of('/'); + offset = s_.find_first_not_of("+<>-="); + if(offset > 1) + offset = 2; *instr_ = s_.substr(0,offset); if(offset != std::string::npos) *values_ = s_.substr(offset); diff --git a/tests/tests.cpp b/tests/tests.cpp index 98f7ee83..3c971676 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -109,6 +109,10 @@ test_config_branches() TEST_MSG("minfreespace: expected = %lu; produced = %lu", 4321, (*bcp0)[1].minfreespace()); + + TEST_CHECK(b.from_string("foo/bar") == 0); + TEST_CHECK(b.from_string("./foo/bar") == 0); + TEST_CHECK(b.from_string("./foo/bar:/bar/baz:blah/asdf") == 0); } void