From: Martin Vidner Date: Mon, 14 Oct 2019 12:35:32 +0000 (+0200) Subject: Fix the test case X-Git-Tag: v0.8.5^2~10 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=d2baba547372a84fcdf980d976e1ac3dd955441e;p=thirdparty%2Fsnapper.git Fix the test case --- diff --git a/snapper/AsciiFile.cc b/snapper/AsciiFile.cc index 04714ab9..f86a7a7d 100644 --- a/snapper/AsciiFile.cc +++ b/snapper/AsciiFile.cc @@ -226,7 +226,9 @@ AsciiFile::save() bool SysconfigFile::getValue(const string& key, string& value) const { - Regex rx('^' + Regex::ws + key + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$'); + Regex rx('^' + Regex::ws + + key + '=' + "(['\"]?)([^'\"]*)\\1" + + Regex::ws + Regex::trailing_comment + '$'); if (find_if(lines(), regex_matches(rx)) == lines().end()) return false; diff --git a/snapper/Regex.cc b/snapper/Regex.cc index 6f078a9f..1a33acc7 100644 --- a/snapper/Regex.cc +++ b/snapper/Regex.cc @@ -97,5 +97,6 @@ Regex::cap (unsigned int i) const const string Regex::ws = "[ \t]*"; const string Regex::number = "[0123456789]+"; +const string Regex::trailing_comment = "(#.*)?"; } diff --git a/snapper/Regex.h b/snapper/Regex.h index 8dd5aa9f..00ff1db8 100644 --- a/snapper/Regex.h +++ b/snapper/Regex.h @@ -54,6 +54,7 @@ public: static const string ws; static const string number; + static const string trailing_comment; private: