# # delete_file "unix/unix.cc" # # delete_file "unix/unix.hh" # # patch "ChangeLog" # from [d6345c3a518fc9f44c70cbecd393e2901dfbf639] # to [07a3a4cede2b580ac1a42ee7321a17c9a062aefb] # # patch "Makefile.am" # from [1126b74203ca3867564b00caff7177ec8bd08e18] # to [3eea4335169c33a02cb7323f7f333013a21187c0] # # patch "commands.cc" # from [23c6d804719fb4b56aa09287320f4cf7cc1a5150] # to [12f20a9dce89088ee2089c495cd56a0adde51af7] # # patch "monotone.cc" # from [c03090ecc52ded9911f34cb3ea2049abf83bd6f7] # to [622baf2c20a7e9fc1304b3078560e90f9bb58e11] # # patch "mt_version.cc" # from [1d7116834788d09633b8fbd7af172a61b64ffec2] # to [b563e566e66b78fcf5f5f580b1a957addfb05fe9] # # patch "transforms.cc" # from [6d5f7cbd27b7951744515f8d619ab2c6f640f3bc] # to [4a53f37a0a51f1477b8b339b6e5737c1323f3c02] # # patch "transforms.hh" # from [7e826327f16187c5ad1c1c0f8a61be241c85fb34] # to [813cc89384622e19a6edd396141a380844b5e133] # # patch "ui.cc" # from [359384e05f3ce77726285d606854eb967c3f0ff5] # to [403dbf11aebf69618ecbaf53dbb87695a78cb940] # # patch "unix/process.cc" # from [5ebbfabd65a9f4e01a385a9dc991f55660e7e90e] # to [2d952838b067e002206f6a67999534a3e1143218] # ======================================================================== --- ChangeLog d6345c3a518fc9f44c70cbecd393e2901dfbf639 +++ ChangeLog 07a3a4cede2b580ac1a42ee7321a17c9a062aefb @@ -1,3 +1,16 @@ +2005-08-24 Nathaniel Smith + + * Back out most changes since + b580c6ac5bf8eea1f442b8bddc60283b047ade1e. Handling charsets + properly by working in utf8 and then converting sucks. Problems + include + - gettext hates you (wants to return stuff in local charset) + - strerror hates you (same reason, but you can't turn it off) + - can't report charset conversion errors + We thus return to our "sorta-correct, by accident" status quo. + Only change left in is signedness fix in + 5548868ab56d939c1fd8713aa2ac8caacd1184a1. + 2005-08-23 Nathaniel Smith * ui.cc (sanitize): Fix signedness bug in comparison. ======================================================================== --- Makefile.am 1126b74203ca3867564b00caff7177ec8bd08e18 +++ Makefile.am 3eea4335169c33a02cb7323f7f333013a21187c0 @@ -196,7 +196,7 @@ UNIX_PLATFORM_SOURCES = \ unix/read_password.cc unix/get_system_flavour.cc unix/process.cc unix/terminal.cc \ - unix/platform_netsync.cc unix/inodeprint.cc unix/unix.hh unix/unix.cc + unix/platform_netsync.cc unix/inodeprint.cc WIN32_PLATFORM_SOURCES = \ win32/read_password.cc win32/get_system_flavour.cc win32/process.cc win32/terminal.cc \ ======================================================================== --- commands.cc 23c6d804719fb4b56aa09287320f4cf7cc1a5150 +++ commands.cc 12f20a9dce89088ee2089c495cd56a0adde51af7 @@ -167,8 +167,6 @@ 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; @@ -566,7 +564,7 @@ string washed; if (guess_binary(tv())) { - washed = _(""); + washed = ""; } else { ======================================================================== --- monotone.cc c03090ecc52ded9911f34cb3ea2049abf83bd6f7 +++ monotone.cc 622baf2c20a7e9fc1304b3078560e90f9bb58e11 @@ -238,8 +238,8 @@ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - bind_textdomain_codeset(PACKAGE, "UTF-8"); + // we want to catch any early informative_failures due to charset // conversion etc try @@ -521,23 +521,16 @@ if (count != 0) { ostringstream sstr; - sstr << outprep(F("Options specific to 'monotone %s':") % u.which); + sstr << F("Options specific to 'monotone %s':") % u.which; options[0].descrip = strdup(sstr.str().c_str()); options[0].argInfo |= POPT_ARGFLAG_DOC_HIDDEN; L(F("Added 'hidden' to option # %d\n") % options[0].argInfo); } - // switch gettext() back to returning native charset strings, since popt - // will simply dump whatever gettext() returns. - bind_textdomain_codeset(PACKAGE, system_charset().c_str()); poptPrintHelp(ctx(), stdout, 0); - bind_textdomain_codeset(PACKAGE, "UTF-8"); - - std::ostringstream usage_stream; - usage_stream << std::endl; - commands::explain_usage(u.which, usage_stream); - std::cout << outprep(usage_stream.str()); + cout << endl; + commands::explain_usage(u.which, cout); clean_shutdown = true; return 0; } ======================================================================== --- mt_version.cc 1d7116834788d09633b8fbd7af172a61b64ffec2 +++ mt_version.cc b563e566e66b78fcf5f5f580b1a957addfb05fe9 @@ -16,13 +16,12 @@ #include "package_revision.h" #include "package_full_revision.h" #include "sanity.hh" -#include "transforms.hh" void print_version() { - std::cout << outprep(F("%s (base revision: %s)") - % PACKAGE_STRING % package_revision_constant) + std::cout << (F("%s (base revision: %s)") + % PACKAGE_STRING % package_revision_constant) << std::endl; } ======================================================================== --- transforms.cc 6d5f7cbd27b7951744515f8d619ab2c6f640f3bc +++ transforms.cc 4a53f37a0a51f1477b8b339b6e5737c1323f3c02 @@ -502,7 +502,7 @@ // general character code conversion routines -string +static string system_charset() { char const * locale_charset_name = stringprep_locale_charset (); @@ -599,19 +599,6 @@ free(out); } -external -outprep(std::string const & msg) -{ - external localized_msg; - utf8_to_system(utf8(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 7e826327f16187c5ad1c1c0f8a61be241c85fb34 +++ transforms.hh 813cc89384622e19a6edd396141a380844b5e133 @@ -6,8 +6,6 @@ // 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" @@ -174,14 +172,10 @@ // charset conversions void charset_convert(std::string const & src_charset, std::string const & dst_charset, std::string const & src, std::string & dst); -std::string system_charset(); void system_to_utf8(external const & system, utf8 & utf); 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 359384e05f3ce77726285d606854eb967c3f0ff5 +++ ui.cc 403dbf11aebf69618ecbaf53dbb87695a78cb940 @@ -167,7 +167,7 @@ // bytes, not by characters) tickline1.resize(tw); } - clog << outprep(tickline1) << outprep("\n"); + clog << tickline1 << "\n"; } if (tw && length(utf8(tickline2)) > tw) { @@ -177,13 +177,13 @@ // bytes, not by characters) tickline2.resize(tw + 1); } - clog << outprep(tickline2); + clog << tickline2; clog.flush(); } void tick_write_count::clear_line() { - clog << outprep("\n"); + clog << endl; } @@ -248,13 +248,13 @@ } } - clog << outprep(tickline1) << outprep(tickline2); + clog << tickline1 << tickline2; clog.flush(); } void tick_write_dot::clear_line() { - clog << outprep("\n"); + clog << endl; } @@ -327,21 +327,13 @@ % fatal % PACKAGE_BUGREPORT); } -void -user_interface::ensure_clean_line() -{ - if (last_write_was_a_tick) - { - write_ticks(); - t_writer->clear_line(); - } - last_write_was_a_tick = false; -} static inline string sanitize(string const & line) { - // UTF-8 does not have safe values in the sub-0x20 range. + // FIXME: you might want to adjust this if you're using a charset + // which has safe values in the sub-0x20 range. ASCII, UTF-8, + // and most ISO8859-x sets do not. string tmp; tmp.reserve(line.size()); for (size_t i = 0; i < line.size(); ++i) @@ -356,13 +348,24 @@ return tmp; } +void +user_interface::ensure_clean_line() +{ + if (last_write_was_a_tick) + { + write_ticks(); + t_writer->clear_line(); + } + last_write_was_a_tick = false; +} + void user_interface::inform(string const & line) { string prefixedLine; prefix_lines_with(_("monotone: "), line, prefixedLine); ensure_clean_line(); - clog << outprep(sanitize(prefixedLine)) << endl; + clog << sanitize(prefixedLine) << endl; clog.flush(); } ======================================================================== --- unix/process.cc 5ebbfabd65a9f4e01a385a9dc991f55660e7e90e +++ unix/process.cc 2d952838b067e002206f6a67999534a3e1143218 @@ -9,12 +9,13 @@ #include #include #include +#include +#include #include #include "sanity.hh" #include "platform.hh" -#include "unix/unix.hh" int existsonpath(const char *exe) { @@ -49,7 +50,7 @@ struct stat s; int rc = stat(path, &s); - N(rc != -1, F("error getting status of file %s: %s") % path % last_error()); + N(rc != -1, F("error getting status of file %s: %s") % path % strerror(errno)); return s.st_mode & S_IXUSR; } @@ -59,13 +60,13 @@ mode_t mode; struct stat s; int fd = open(path, O_RDONLY); - N(fd != -1, F("error opening file %s: %s") % path % last_error()); + N(fd != -1, F("error opening file %s: %s") % path % strerror(errno)); if (fstat(fd, &s)) return -1; mode = s.st_mode; mode |= S_IXUSR|S_IXGRP|S_IXOTH; int ret = fchmod(fd, mode); - N(close(fd) == 0, F("error closing file %s: %s") % path % last_error()); + N(close(fd) == 0, F("error closing file %s: %s") % path % strerror(errno)); return ret; }