aboutsummaryrefslogtreecommitdiff
path: root/paludis/args/man.cc
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-01-10 00:24:30 +0100
committerAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-01-10 18:16:03 +0100
commitdc97ba191931066c497508d5b672d9a1f9f9962a (patch)
tree6e0ae736080ea13ff8cc386f48fb984a321a948c /paludis/args/man.cc
parent4e477826aeb03ea54321269e12541dc76d859bb8 (diff)
downloadpaludis-dc97ba191931066c497508d5b672d9a1f9f9962a.tar.gz
paludis-dc97ba191931066c497508d5b672d9a1f9f9962a.tar.xz
Double up backslashes when writing manual pages, so \t, \n etc show up properly. fixes:688.
Based on an initial patch by Daniel Mierswa <impulze@impulze.org>.
Diffstat (limited to 'paludis/args/man.cc')
-rw-r--r--paludis/args/man.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index 76a6f9df2..152297b88 100644
--- a/paludis/args/man.cc
+++ b/paludis/args/man.cc
@@ -380,6 +380,19 @@ ManWriter::start_arg_group(const std::string & name, const std::string & descrip
_os << description << endl;
}
+namespace
+{
+ void escape(std::ostream & stream, const std::string & s)
+ {
+ for (std::string::const_iterator t(s.begin()), t_end(s.end()); t != t_end; ++t)
+ {
+ if ('\\' == *t)
+ stream << '\\';
+ stream << *t;
+ }
+ }
+}
+
void
ManWriter::arg_group_item(const char & short_name, const std::string & long_name,
const std::string & negated_long_name, const std::string & description)
@@ -392,7 +405,8 @@ ManWriter::arg_group_item(const char & short_name, const std::string & long_name
if (! negated_long_name.empty())
_os << " (\\-\\-" << negated_long_name << ")\"";
_os << endl;
- _os << description << endl;
+ escape(_os, description);
+ _os << endl;
}
void
@@ -479,7 +493,8 @@ void
ManWriter::example(const std::string & first, const std::string & second)
{
_os << ".TP" << endl;
- _os << first << endl;
+ escape(_os, first);
+ _os << endl;
_os << ungroff(second) << endl << endl;
}