# # patch "ChangeLog" # from [ffc48858dcc7e11b6d8089bddbb054bf460feadc] # to [1989d47b96862cf9c79fd28f4b9b013b94cec334] # # patch "transforms.cc" # from [28c538ce02fb3550ea695f4745feb560ee3d4176] # to [8d8fc2f4a1ea1d8f9c27470b71d171255a9c6f20] # # patch "ui.cc" # from [f8f131c37b162261d410b8dc8ef8d121c5a2fcab] # to [f3e72d0c125a2ca9dddbe998f1d9f15d12d54199] # ======================================================================== --- ChangeLog ffc48858dcc7e11b6d8089bddbb054bf460feadc +++ ChangeLog 1989d47b96862cf9c79fd28f4b9b013b94cec334 @@ -1,5 +1,12 @@ 2005-08-23 Nathaniel Smith + * transforms.cc (outprep): Don't sanitize all output; removes too + many valid characters (\r, \t, etc.). + * ui.cc: Call outprep on ticker output. + (inform): Do still sanitize ui.inform() output. + +2005-08-23 Nathaniel Smith + * transforms.cc (outprep): New function. * ui.cc (inform): Use it. * monotone.cc (cpp_main): Use it. ======================================================================== --- transforms.cc 28c538ce02fb3550ea695f4745feb560ee3d4176 +++ transforms.cc 8d8fc2f4a1ea1d8f9c27470b71d171255a9c6f20 @@ -599,28 +599,11 @@ 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); + utf8_to_system(utf8(msg), localized_msg); return localized_msg; } external ======================================================================== --- ui.cc f8f131c37b162261d410b8dc8ef8d121c5a2fcab +++ ui.cc f3e72d0c125a2ca9dddbe998f1d9f15d12d54199 @@ -167,7 +167,7 @@ // bytes, not by characters) tickline1.resize(tw); } - clog << tickline1 << "\n"; + clog << outprep(tickline1) << outprep("\n"); } if (tw && length(utf8(tickline2)) > tw) { @@ -177,13 +177,13 @@ // bytes, not by characters) tickline2.resize(tw + 1); } - clog << tickline2; + clog << outprep(tickline2); clog.flush(); } void tick_write_count::clear_line() { - clog << endl; + clog << outprep("\n"); } @@ -248,13 +248,13 @@ } } - clog << tickline1 << tickline2; + clog << outprep(tickline1) << outprep(tickline2); clog.flush(); } void tick_write_dot::clear_line() { - clog << endl; + clog << outprep("\n"); } @@ -338,13 +338,31 @@ 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. + 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::inform(string const & line) { string prefixedLine; prefix_lines_with(_("monotone: "), line, prefixedLine); ensure_clean_line(); - clog << outprep(prefixedLine) << endl; + clog << outprep(sanitize(prefixedLine)) << endl; clog.flush(); }