aboutsummaryrefslogtreecommitdiff
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
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>.
-rw-r--r--paludis/args/man.cc19
-rw-r--r--src/clients/cave/cmd_print_id_metadata.cc4
2 files changed, 21 insertions, 2 deletions
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index 76a6f9d..152297b 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;
}
diff --git a/src/clients/cave/cmd_print_id_metadata.cc b/src/clients/cave/cmd_print_id_metadata.cc
index a6e8226..9909566 100644
--- a/src/clients/cave/cmd_print_id_metadata.cc
+++ b/src/clients/cave/cmd_print_id_metadata.cc
@@ -91,6 +91,10 @@ namespace
{
a_format.set_argument("%i%i%r=%v\\n");
add_usage_line("[ --raw-name key ] [ --human-name key ] [ --format format ] spec");
+
+ add_example(
+ "cave print-id-metadata --format \"%r\\n\" sys-apps/paludis::installed",
+ "Print the raw names for all keys a given ID has.");
}
};