From d04e04e89a08e577387ec5489b7756f768cc63df Mon Sep 17 00:00:00 2001 From: Ilya Taranov Date: Fri, 10 Mar 2023 20:23:55 -0800 Subject: [PATCH] Fix config file parsing --- src/branches.cpp | 7 +++++-- tests/tests.cpp | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/branches.cpp b/src/branches.cpp index e8b2e621..ca087d04 100644 --- a/src/branches.cpp +++ b/src/branches.cpp @@ -80,11 +80,14 @@ namespace l uint64_t offset; offset = s_.find_first_not_of("+<>-="); + if (offset == std::string::npos) { + return; + } + if(offset > 1) offset = 2; *instr_ = s_.substr(0,offset); - if(offset != std::string::npos) - *values_ = s_.substr(offset); + *values_ = s_.substr(offset); } static diff --git a/tests/tests.cpp b/tests/tests.cpp index 3c971676..867f4a6d 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -86,6 +86,9 @@ test_config_branches() TEST_CHECK(b->minfreespace() == 1234); TEST_CHECK(b.to_string() == ""); + // Parse initial value for branch + TEST_CHECK(b.from_string(b.to_string()) == 0); + bcp0 = b; TEST_CHECK(b.from_string("/foo/bar") == 0); TEST_CHECK(b.to_string() == "/foo/bar=RW");