# # patch "ChangeLog" # from [5152387c28788af27464f5c07c9c66655fcdc5a7] # to [ed4b3b3c1194479a7c7b4767a0f32f3b5ffb5971] # # patch "sanity.hh" # from [4b60e04581e65bb1426c17f8807b37ec0e7775d8] # to [2c8cee0f678668a356de29a5c61fb3eed8c87b74] # # patch "ui.cc" # from [77a48bddc373a115f5ec6cc0077afa17a2a762d0] # to [2c9b65e320b66d6b104bee5885723c4f97f36e8b] # # patch "ui.hh" # from [d5866bba3cc59b130fb56ba40e0780801d4314f9] # to [13817f413857ee072ca9ed1aa5dc90e51aaa0069] # ======================================================================== --- ChangeLog 5152387c28788af27464f5c07c9c66655fcdc5a7 +++ ChangeLog ed4b3b3c1194479a7c7b4767a0f32f3b5ffb5971 @@ -1,3 +1,10 @@ +2005-09-20 Matt Johnston + + * ui.cc, ui.hh, sanity.hh: replace ui.user_locale with + get_user_locale(), so that we can guarantee that it will be + initialised when the global_sanity object (and probably other things) + are instantiated. + 2005-09-20 Matthew Gregan * tests/t_restriction_with_exclude_iprint.at: New test, variant of ======================================================================== --- sanity.hh 4b60e04581e65bb1426c17f8807b37ec0e7775d8 +++ sanity.hh 2c8cee0f678668a356de29a5c61fb3eed8c87b74 @@ -92,10 +92,10 @@ extern sanity global_sanity; // F is for when you want to build a boost formatter for display -#define F(str) boost::format(gettext(str), ui.user_locale) +#define F(str) boost::format(gettext(str), get_user_locale()) // FP is for when you want to build a boost formatter for displaying a plural -#define FP(str1, strn, count) boost::format(ngettext(str1, strn, count), ui.user_locale) +#define FP(str1, strn, count) boost::format(ngettext(str1, strn, count), get_user_locale()) // L is for logging, you can log all you want #define L(fmt) global_sanity.log(fmt, __FILE__, __LINE__) ======================================================================== --- ui.cc 77a48bddc373a115f5ec6cc0077afa17a2a762d0 +++ ui.cc 2c9b65e320b66d6b104bee5885723c4f97f36e8b @@ -259,7 +259,6 @@ user_interface::user_interface() : - user_locale(""), last_write_was_a_tick(false), t_writer(0) { @@ -381,3 +380,10 @@ return w; } +// a cache used to avoid initialising locale("") on every call to boost::format +const locale +get_user_locale() +{ + static const locale user_locale(""); + return user_locale; +} ======================================================================== --- ui.hh d5866bba3cc59b130fb56ba40e0780801d4314f9 +++ ui.hh 13817f413857ee072ca9ed1aa5dc90e51aaa0069 @@ -85,8 +85,6 @@ void set_tick_writer(tick_writer * t_writer); void ensure_clean_line(); - const std::locale user_locale; - private: std::set issued_warnings; @@ -109,4 +107,7 @@ // (even if there is no terminal) unsigned int guess_terminal_width(); +// returns the a default user locale value +const std::locale get_user_locale(); + #endif // __UI_HH__