RSS generator: write_line(): Move endtag detection into lambda.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2020-07-07 06:27:13 +02:00
parent 7518947766
commit 1af807e588
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 12 additions and 11 deletions

View File

@ -45,18 +45,19 @@ using std::chrono::system_clock;
void write_line(ostream &out, const uint8_t spaces, const string_view rsstag,
const string_view value)
{
string endtag;
// If there is a space in the rsstag, use only the part up until the space
// for the ending rsstag.
const size_t pos = rsstag.find(' ');
if (pos == string_view::npos)
// clang-format off
const string endtag{[&rsstag]
{
endtag = rsstag;
}
else
{
endtag = rsstag.substr(0, pos);
}
// If there is a space in the rsstag, use only the part up until the
// space for the ending RSS tag.
const size_t pos = rsstag.find(' ');
if (pos == string_view::npos)
{
return rsstag;
}
return rsstag.substr(0, pos);
}()};
// clang-format off
out << string(spaces, ' ');
out << '<' << rsstag << '>' << value << "</" << endtag << ">\n";