[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone: a97adfb356cbb187d309c44963
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone: a97adfb356cbb187d309c4496385a38b02fb6f94 |
Date: |
Fri, 18 Feb 2011 20:54:18 +0100 (CET) |
revision: a97adfb356cbb187d309c4496385a38b02fb6f94
date: 2011-02-08T08:27:40
author: Richard Levitte <address@hidden>
branch: net.venge.monotone
changelog:
* cmd.cc (man_hyphens): New function that escapes all dashes (- -> \-)
The reason is that newer versions of groff will interpret the "-"
character as hyphens (U+2010), not as minus signs (U+002D), and that
might lead to problems for those that want to copy and paste
options, or search for them.
(man_definition): Send all input strings through man_hyphens.
manifest:
format_version "1"
new_manifest [b25021d5131c3592b42a3cef924ead4fe28ffed9]
old_revision [04a73419093a975b742bd0664da0079b7001436f]
patch "src/cmd.cc"
from [738af533e09611f04b922b5e9ab5f6eae894b918]
to [a30ab07e170d4057669ae434735272338667915d]
============================================================
--- src/cmd.cc 738af533e09611f04b922b5e9ab5f6eae894b918
+++ src/cmd.cc a30ab07e170d4057669ae434735272338667915d
@@ -41,6 +41,9 @@ using boost::lexical_cast;
using std::cout;
using boost::lexical_cast;
+using std::cerr;
+using std::endl;
+
//
// Definition of top-level commands, used to classify the real commands
// in logical groups.
@@ -630,10 +633,36 @@ static string
}
static string
+man_hyphens(string const s)
+{
+ string out;
+ size_t p1 = 0;
+ size_t p2 = s.find("-", p1);
+ while (p2 != s.npos)
+ {
+ // Sometimes, this function gets called again with the result of a
+ // previous call, so watch out for hyphens that are already preceeded
+ // with a backslash
+ if (p2 > 0 && s[p2 - 1] == '\\')
+ {
+ p2 = s.find("-", p2 + 1);
+ continue;
+ }
+
+ out += s.substr(p1, p2 - p1);
+ out += "\\-";
+ p1 = p2 + 1;
+ p2 = s.find("-", p1);
+ }
+ out += s.substr(p1, s.npos);
+ return out;
+}
+
+static string
man_definition(vector<string> const & labels, string const & content, int width = -1)
{
string out;
- out += ".IP \"" + (*labels.begin()) + "\"";
+ out += ".IP \"" + man_hyphens(*labels.begin()) + "\"";
if (width != -1)
out += " " + lexical_cast<string>(width);
@@ -645,13 +674,14 @@ man_definition(vector<string> const & la
for (vector<string>::const_iterator i = labels.begin() + 1;
i < labels.end(); ++i)
{
- out += ".IP \"" + (*i) + "\"\n";
+ out += ".IP \"" + man_hyphens(*i) + "\"\n";
}
out += ".PD\n";
}
- out += content;
+ out += man_hyphens(content);
if (content.rfind('\n') != (content.size() - 1))
out += "\n";
+
return out;
}
@@ -881,7 +911,7 @@ CMD_NO_WORKSPACE(manpage, "manpage", "",
ss << man_title("monotone");
ss << man_section(_("Name"));
- ss << _("monotone - a distributed version control system") << "\n";
+ ss << _("monotone \\- a distributed version control system") << "\n";
ss << man_section(_("Synopsis"));
ss << man_bold(prog_name) << " "
<< man_italic(_("[options...] command [arguments...]"))
@@ -925,7 +955,7 @@ CMD_NO_WORKSPACE(manpage, "manpage", "",
"programmers, known as the monotone development team.") << "\n";
ss << man_section("Copyright");
- ss << (F("monotone and this man page is Copyright (c) 2004 - %s by "
+ ss << (F("monotone and this man page is Copyright (c) 2004 \\- %s by "
"the monotone development team.")
% date_t::now().as_formatted_localtime("%Y")).str() << "\n";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone: a97adfb356cbb187d309c4496385a38b02fb6f94,
code <=