aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-15 14:13:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-15 14:13:54 +0100
commit883e9c3ca406a8707f9540c86c4e79d18283c68b (patch)
treeec35f0f58b7cc25928d25ccab74e1b895fe11aab /paludis
parent66db4266279cebda911423d15ab31f8f0174a0fc (diff)
downloadpaludis-883e9c3ca406a8707f9540c86c4e79d18283c68b.tar.gz
paludis-883e9c3ca406a8707f9540c86c4e79d18283c68b.tar.xz
Better man page escaping
Diffstat (limited to 'paludis')
-rw-r--r--paludis/args/man.cc26
1 files changed, 3 insertions, 23 deletions
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index 421655ef0..7cd0fa4b0 100644
--- a/paludis/args/man.cc
+++ b/paludis/args/man.cc
@@ -208,40 +208,20 @@ namespace
{
void escape_asciidoc(std::ostream & stream, const std::string & s)
{
- // escape the n-th char unless n = 0 (start of string) or if n-1 = \s \t or \n
- auto t(s.begin()), t_end(s.end());
char previous('\0');
-
- if (t != t_end)
- {
- switch (*t)
- {
- case '\'':
- stream << "\\'";
- ++t;
- break;
- case '*':
- stream << "\\*";
- ++t;
- break;
- }
- }
-
- for ( ; t != t_end ; ++t)
+ for (auto t(s.begin()), t_end(s.end()) ; t != t_end ; ++t)
{
switch (previous)
{
+ case '\0':
case ' ':
case '\n':
case '\t':
- if ('\'' == *t or '*' == *t)
- stream << '\\';
- break;
- // Escape '*/*' -> \'\*/*'
case '\'':
if ('*' == *t)
stream << '\\';
break;
+ // Escape '*/*' -> '\*/*'
}
stream << *t;
previous = *t;