From: Martin Vidner Date: Tue, 15 Oct 2019 08:51:37 +0000 (+0200) Subject: Fix setValue X-Git-Tag: v0.8.5^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c78e4bc1627506120e436e89a33522d8ee8cd4a3;p=thirdparty%2Fsnapper.git Fix setValue --- diff --git a/snapper/AsciiFile.cc b/snapper/AsciiFile.cc index 31bbfc63..1ee9788c 100644 --- a/snapper/AsciiFile.cc +++ b/snapper/AsciiFile.cc @@ -209,15 +209,21 @@ AsciiFile::save() { checkKey(key); - string line = key + "=\"" + value + "\""; - - Regex rx('^' + Regex::ws + key + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$'); + Regex rx('^' + Regex::ws + + key + '=' + "(['\"]?)([^'\"]*)\\1" + + '(' + Regex::ws + Regex::trailing_comment + ")$"); vector::iterator it = find_if(lines(), regex_matches(rx)); if (it == lines().end()) + { + string line = key + "=\"" + value + "\""; push_back(line); + } else + { + string line = key + "=\"" + value + "\"" + rx.cap(3); *it = line; + } modified = true; }