#
# patch "ChangeLog"
# from [d365571f6f5f41f1207361b820240e68e390f89d]
# to [ffc48858dcc7e11b6d8089bddbb054bf460feadc]
#
# patch "commands.cc"
# from [12f20a9dce89088ee2089c495cd56a0adde51af7]
# to [23c6d804719fb4b56aa09287320f4cf7cc1a5150]
#
# patch "monotone.cc"
# from [ac2727c294f77b9bf31b64aef134e3f71ed012c0]
# to [b14c80b029c2e415ac088c5375a4fd9f079579d3]
#
# patch "mt_version.cc"
# from [b563e566e66b78fcf5f5f580b1a957addfb05fe9]
# to [1d7116834788d09633b8fbd7af172a61b64ffec2]
#
# patch "transforms.cc"
# from [4a53f37a0a51f1477b8b339b6e5737c1323f3c02]
# to [28c538ce02fb3550ea695f4745feb560ee3d4176]
#
# patch "transforms.hh"
# from [813cc89384622e19a6edd396141a380844b5e133]
# to [6fe1d145188c2c348e519926c5f3a999f237abda]
#
# patch "ui.cc"
# from [b299e2428530c816ad7bc8e3cf1728f40b7cf5b3]
# to [f8f131c37b162261d410b8dc8ef8d121c5a2fcab]
#
========================================================================
--- ChangeLog d365571f6f5f41f1207361b820240e68e390f89d
+++ ChangeLog ffc48858dcc7e11b6d8089bddbb054bf460feadc
@@ -1,5 +1,13 @@
2005-08-23 Nathaniel Smith
+ * transforms.cc (outprep): New function.
+ * ui.cc (inform): Use it.
+ * monotone.cc (cpp_main): Use it.
+ Everything that writes user-intended output directly (i.e., via
+ cout) must call outprep() on that data before printing it.
+
+2005-08-23 Nathaniel Smith
+
* monotone.cc (cpp_main): Trick popt into converting its generated
help messages into the current locale's charset.
========================================================================
--- commands.cc 12f20a9dce89088ee2089c495cd56a0adde51af7
+++ commands.cc 23c6d804719fb4b56aa09287320f4cf7cc1a5150
@@ -167,6 +167,8 @@
return cmd;
}
+ // this writes utf-8 to its ostream; if the caller doesn't like that, they
+ // get to fix it.
void explain_usage(string const & cmd, ostream & out)
{
map::const_iterator i;
@@ -564,7 +566,7 @@
string washed;
if (guess_binary(tv()))
{
- washed = "";
+ washed = _("");
}
else
{
========================================================================
--- monotone.cc ac2727c294f77b9bf31b64aef134e3f71ed012c0
+++ monotone.cc b14c80b029c2e415ac088c5375a4fd9f079579d3
@@ -522,7 +522,7 @@
if (count != 0)
{
ostringstream sstr;
- sstr << F("Options specific to 'monotone %s':") % u.which;
+ sstr << outprep(F("Options specific to 'monotone %s':") % u.which);
options[0].descrip = strdup(sstr.str().c_str());
options[0].argInfo |= POPT_ARGFLAG_DOC_HIDDEN;
@@ -535,8 +535,10 @@
poptPrintHelp(ctx(), stdout, 0);
bind_textdomain_codeset(PACKAGE, "UTF-8");
- cout << endl;
- commands::explain_usage(u.which, cout);
+ std::ostringstream usage_stream;
+ usage_stream << std::endl;
+ commands::explain_usage(u.which, usage_stream);
+ std::cout << outprep(usage_stream.str());
clean_shutdown = true;
return 0;
}
========================================================================
--- mt_version.cc b563e566e66b78fcf5f5f580b1a957addfb05fe9
+++ mt_version.cc 1d7116834788d09633b8fbd7af172a61b64ffec2
@@ -16,12 +16,13 @@
#include "package_revision.h"
#include "package_full_revision.h"
#include "sanity.hh"
+#include "transforms.hh"
void
print_version()
{
- std::cout << (F("%s (base revision: %s)")
- % PACKAGE_STRING % package_revision_constant)
+ std::cout << outprep(F("%s (base revision: %s)")
+ % PACKAGE_STRING % package_revision_constant)
<< std::endl;
}
========================================================================
--- transforms.cc 4a53f37a0a51f1477b8b339b6e5737c1323f3c02
+++ transforms.cc 28c538ce02fb3550ea695f4745feb560ee3d4176
@@ -599,6 +599,36 @@
free(out);
}
+static inline string
+sanitize(string const & line)
+{
+ // UTF-8 does not have safe values in the sub-0x20 range.
+ string tmp;
+ tmp.reserve(line.size());
+ for (size_t i = 0; i < line.size(); ++i)
+ {
+ if ((line[i] == '\n')
+ || (line[i] >= static_cast(0x20)
+ && line[i] != static_cast(0x7F)))
+ tmp += line[i];
+ else
+ tmp += ' ';
+ }
+ return tmp;
+}
+external
+outprep(std::string const & msg)
+{
+ external localized_msg;
+ utf8_to_system(utf8(sanitize(msg)), localized_msg);
+ return localized_msg;
+}
+external
+outprep(boost::format const & format)
+{
+ return outprep(format.str());
+}
+
// hack: this is an unexposed function in libidna
extern "C" long g_utf8_strlen(const char * p, size_t max);
========================================================================
--- transforms.hh 813cc89384622e19a6edd396141a380844b5e133
+++ transforms.hh 6fe1d145188c2c348e519926c5f3a999f237abda
@@ -6,6 +6,8 @@
// licensed to the public under the terms of the GNU GPL (>= 2)
// see the file COPYING for details
+#include "boost/format.hpp"
+
#include "revision.hh"
#include "lua.hh"
#include "manifest.hh"
@@ -176,6 +178,9 @@
void utf8_to_system(utf8 const & utf, external & system);
void ace_to_utf8(ace const & ac, utf8 & utf);
void utf8_to_ace(utf8 const & utf, ace & a);
+// all messages printed to the user should go through this function
+external outprep(std::string const & msg);
+external outprep(boost::format const & format);
// returns length in characters (not bytes)
size_t length(utf8 const & utf);
========================================================================
--- ui.cc b299e2428530c816ad7bc8e3cf1728f40b7cf5b3
+++ ui.cc f8f131c37b162261d410b8dc8ef8d121c5a2fcab
@@ -327,25 +327,6 @@
% fatal % PACKAGE_BUGREPORT);
}
-
-static inline string
-sanitize(string const & line)
-{
- // UTF-8 does not have safe values in the sub-0x20 range.
- string tmp;
- tmp.reserve(line.size());
- for (size_t i = 0; i < line.size(); ++i)
- {
- if ((line[i] == '\n')
- || (line[i] >= static_cast(0x20)
- && line[i] != static_cast(0x7F)))
- tmp += line[i];
- else
- tmp += ' ';
- }
- return tmp;
-}
-
void
user_interface::ensure_clean_line()
{
@@ -363,9 +344,7 @@
string prefixedLine;
prefix_lines_with(_("monotone: "), line, prefixedLine);
ensure_clean_line();
- external localized_text;
- utf8_to_system(utf8(sanitize(prefixedLine)), localized_text);
- clog << localized_text << endl;
+ clog << outprep(prefixedLine) << endl;
clog.flush();
}