# # patch "ChangeLog" # from [6b139b6baa2f9a343d3798585b9b988a5d096f2a] # to [0d5fa026a495aeb4563f214e9cb19de559c05de6] # # patch "sanity.cc" # from [6206133e98da6643d056aef8f051fc3ae0046eed] # to [b5ff54ddccac3f72354629d63131addb9335c9d3] # # patch "sanity.hh" # from [0567ddf986544c0644f863b24f6906ad05bea555] # to [7c8979cb2ebf1f53c4379d62a4ac84ab0cd63d5d] # ======================================================================== --- ChangeLog 6b139b6baa2f9a343d3798585b9b988a5d096f2a +++ ChangeLog 0d5fa026a495aeb4563f214e9cb19de559c05de6 @@ -1,5 +1,11 @@ 2005-08-25 Benoît Dejean + * sanity.{cc,hh} (sanity::do_format): Merged code from + sanity::{log, warning, progress} in order to merge + strings. Fixed exception rethrowing. + +2005-08-25 Benoît Dejean + * commands.cc (CMD(lca)): One more string for i18n. (CMD(trusted)): Merged all strings. ======================================================================== --- sanity.cc 6206133e98da6643d056aef8f051fc3ae0046eed +++ sanity.cc b5ff54ddccac3f72354629d63131addb9335c9d3 @@ -95,23 +95,29 @@ relaxed = rel; } -void -sanity::log(format const & fmt, - char const * file, int line) +string +sanity::do_format(format const & fmt, char const * file, int line) { - string str; - try + try { - str = fmt.str(); + return fmt.str(); } catch (std::exception & e) { - ui.inform("fatal: formatter failed on " - + string(file) - + ":" + boost::lexical_cast(line) - + ": " + e.what()); - throw e; + ui.inform(F("fatal: formatter failed on %s:%d: %s") + % file + % line + % e.what()); + throw; } +} + + +void +sanity::log(format const & fmt, + char const * file, int line) +{ + string str = do_format(fmt, file, line); if (str.size() > constants::log_line_sz) { @@ -130,19 +136,8 @@ sanity::progress(format const & fmt, char const * file, int line) { - string str; - try - { - str = fmt.str(); - } - catch (std::exception & e) - { - ui.inform("fatal: formatter failed on " - + string(file) - + ":" + boost::lexical_cast(line) - + ": " + e.what()); - throw e; - } + string str = do_format(fmt, file, line); + if (str.size() > constants::log_line_sz) { str.resize(constants::log_line_sz); @@ -160,19 +155,8 @@ sanity::warning(format const & fmt, char const * file, int line) { - string str; - try - { - str = fmt.str(); - } - catch (std::exception & e) - { - ui.inform("fatal: formatter failed on " - + string(file) - + ":" + boost::lexical_cast(line) - + ": " + e.what()); - throw e; - } + string str = do_format(fmt, file, line); + if (str.size() > constants::log_line_sz) { str.resize(constants::log_line_sz); ======================================================================== --- sanity.hh 0567ddf986544c0644f863b24f6906ad05bea555 +++ sanity.hh 7c8979cb2ebf1f53c4379d62a4ac84ab0cd63d5d @@ -78,6 +78,10 @@ unsigned long idx, std::string const & file, int line) NORETURN; void gasp(); + +private: + std::string do_format(boost::format const & fmt, + char const * file, int line); }; typedef std::runtime_error oops;