From a1ad812fa4fdd0dafa60e63c194ebd2cddc4d64a Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 29 Oct 2024 14:44:55 +0100 Subject: [PATCH] Fix slice2js write doc lines implementation - #2994 (#2995) --- cpp/src/slice2js/Gen.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 48f6432f985..1a6cfc4b601 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -144,18 +144,21 @@ namespace void writeDocLines(Output& out, const StringList& lines, bool commentFirst, const string& space = " ") { - StringList l = lines; - if (!commentFirst) + if (lines.size() > 0) { - out << l.front(); - l.pop_front(); - } - for (StringList::const_iterator i = l.begin(); i != l.end(); ++i) - { - out << nl << " *"; - if (!i->empty()) + StringList l = lines; + if (!commentFirst) { - out << space << *i; + out << l.front(); + l.pop_front(); + } + for (StringList::const_iterator i = l.begin(); i != l.end(); ++i) + { + out << nl << " *"; + if (!i->empty()) + { + out << space << *i; + } } } }