summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-04-18 15:43:06 +0200
committer couriersud <couriersud@gmx.org>2020-04-18 15:43:06 +0200
commitd8fbec6ab434ecd3ffd98c3b455979b056e18374 (patch)
tree09ce24d1dd692473adbd23b3c17ba28c0d257ac2
parent855c37d58a2bb3f4f88b61e40c7fae1845ecbec5 (diff)
netlist: add parameter to split_paragraphs ... (nw)
to allow passing in a custom line end string.
-rw-r--r--src/lib/netlist/plib/poptions.cpp21
-rw-r--r--src/lib/netlist/plib/poptions.h2
2 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp
index 6f23cb2d934..b0bade9ada6 100644
--- a/src/lib/netlist/plib/poptions.cpp
+++ b/src/lib/netlist/plib/poptions.cpp
@@ -169,7 +169,7 @@ namespace plib {
}
pstring options::split_paragraphs(const pstring &text, unsigned width, unsigned indent,
- unsigned firstline_indent)
+ unsigned firstline_indent, const pstring &line_end)
{
auto paragraphs = psplit(text,"\n");
pstring ret("");
@@ -181,12 +181,14 @@ namespace plib {
{
if (line.length() + s.length() > width)
{
- ret += line + "\n";
+ ret += line + line_end;
line = plib::rpad(pstring(""), pstring(" "), indent);
}
line += s + " ";
}
- ret += line + "\n";
+ ret += line;
+ if (p != paragraphs.back())
+ ret += line_end;
}
return ret;
}
@@ -196,7 +198,7 @@ namespace plib {
{
pstring ret;
- ret = split_paragraphs(description, width, 0, 0) + "\n";
+ ret = split_paragraphs(description, width, 0, 0) + "\n\n";
ret += "Usage:\t" + usage + "\n\nOptions:\n\n";
for (const auto & optbase : m_opts )
@@ -238,15 +240,15 @@ namespace plib {
{
//ret += "TestGroup abc\n def gef\nxyz\n\n" ;
ret += line + "\n";
- ret += split_paragraphs(opt->help(), width, indent, indent);
+ ret += split_paragraphs(opt->help(), width, indent, indent) + "\n";
}
else
- ret += split_paragraphs(line + opt->help(), width, indent, 0);
+ ret += split_paragraphs(line + opt->help(), width, indent, 0) + "\n";
}
else if (auto *grp = dynamic_cast<option_group *>(optbase))
{
ret += "\n" + grp->group() + ":\n";
- if (grp->help() != "") ret += split_paragraphs(grp->help(), width, 4, 4) + "\n";
+ if (grp->help() != "") ret += split_paragraphs(grp->help(), width, 4, 4) + "\n\n";
}
}
// FIXME: other help ...
@@ -255,8 +257,9 @@ namespace plib {
{
if (auto *example = dynamic_cast<option_example *>(optbase))
{
- ex += "> " + example->example()+"\n\n";
- ex += split_paragraphs(example->help(), width, 4, 4) + "\n";
+ // help2man doesn't like \\ line continuation in output
+ ex += split_paragraphs(example->example(), width, 8, 0, "\n") + "\n\n";
+ ex += split_paragraphs(example->help(), width, 4, 4) + "\n\n";
}
}
if (ex.length() > 0)
diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h
index f247be5a42d..fa85edc4d5a 100644
--- a/src/lib/netlist/plib/poptions.h
+++ b/src/lib/netlist/plib/poptions.h
@@ -234,7 +234,7 @@ namespace plib {
private:
static pstring split_paragraphs(const pstring &text, unsigned width, unsigned indent,
- unsigned firstline_indent);
+ unsigned firstline_indent, const pstring &line_end = "\n");
void check_consistency() noexcept(false);