# # # patch "monotone.cc" # from [4c3b7c12860268b0b01e39faeab5f95cbbe300b8] # to [4fcc4fca87bd7f74669d3b6cb4f86645066fdcec] # # patch "option.cc" # from [97d9423e3b676464b075d7309e045bcd8391c9fb] # to [6697c789f4b6dd082bbab6c2c7bea70dc549b308] # # patch "option.hh" # from [e0dfcbf481d579f5602aea5203f49bd4836d715f] # to [a120f75cc822a8ff7a0e0602d2385f3d730f2588] # # patch "options.cc" # from [7a2689cbb0597dced4933dce0464157c52cbefe1] # to [ba83b047efc456f0c45b6bcb9662634c1aaa3ac9] # # patch "sanity.hh" # from [c0f57fa10025bd057f6d0992483d5de05f075ea1] # to [5d3ced86455ffad98885fa705c0f3f8c2bcd3227] # # patch "unit_tester.cc" # from [ee385ca238b903be23ddbaeef78d2ee78f474e8b] # to [28af6bab67aa693109a382dcd1eb35628030fb13] # ============================================================ --- monotone.cc 4c3b7c12860268b0b01e39faeab5f95cbbe300b8 +++ monotone.cc 4fcc4fca87bd7f74669d3b6cb4f86645066fdcec @@ -83,21 +83,6 @@ struct ui_library ~ui_library() { ui.deinitialize(); } }; -// This is in a separate procedure so it can be called from code that's called -// before cpp_main(), such as program option object creation code. It's made -// so it can be called multiple times as well. -void localize_monotone() -{ - static int init = 0; - if (!init) - { - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, get_locale_dir().c_str()); - textdomain(PACKAGE); - init = 1; - } -} - // define the global objects needed by botan_pipe_cache.hh pipe_cache_cleanup * global_pipe_cleanup_object; Botan::Pipe * unfiltered_pipe; @@ -161,7 +146,9 @@ cpp_main(int argc, char ** argv) cpp_main(int argc, char ** argv) { // go-go gadget i18n - localize_monotone(); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, get_locale_dir().c_str()); + textdomain(PACKAGE); // set up global ui object - must occur before anything that might try to // issue a diagnostic ============================================================ --- option.cc 97d9423e3b676464b075d7309e045bcd8391c9fb +++ option.cc 6697c789f4b6dd082bbab6c2c7bea70dc549b308 @@ -53,8 +53,9 @@ bad_arg_internal::bad_arg_internal(strin -void splitname(string const & from, string & name, string & n) +void splitname(char const * f, string & name, string & n) { + string from(f); // from looks like "foo" or "foo,f" string::size_type comma = from.find(','); name = from.substr(0, comma); @@ -78,15 +79,15 @@ concrete_option::concrete_option() : has_arg(false) {} -concrete_option::concrete_option(std::string const & names, - std::string const & desc, +concrete_option::concrete_option(char const * names, + char const * desc, bool arg, boost::function set, boost::function reset) { description = desc; splitname(names, longname, shortname); - I(!description.empty() || !longname.empty() || !shortname.empty()); + I((desc && desc[0]) || !longname.empty() || !shortname.empty()); // If an option has a name (ie, can be set), it must have a setter function I(set || (longname.empty() && shortname.empty())); has_arg = arg; @@ -134,8 +135,8 @@ concrete_option_set & }; concrete_option_set & -concrete_option_set::operator()(string const & names, - string const & desc, +concrete_option_set::operator()(char const * names, + char const * desc, boost::function set, boost::function reset) { @@ -144,8 +145,8 @@ concrete_option_set & } concrete_option_set & -concrete_option_set::operator()(string const & names, - string const & desc, +concrete_option_set::operator()(char const * names, + char const * desc, boost::function set, boost::function reset) { @@ -457,7 +458,7 @@ concrete_option_set::get_usage_strings(v if (name.size() > namelen) namelen = name.size(); names.push_back(name); - descriptions.push_back(i->description); + descriptions.push_back(gettext(i->description)); } maxnamelen = namelen; } ============================================================ --- option.hh e0dfcbf481d579f5602aea5203f49bd4836d715f +++ option.hh a120f75cc822a8ff7a0e0602d2385f3d730f2588 @@ -78,12 +78,12 @@ namespace option { }; // Split a "long,s" option name into long and short names. - void splitname(std::string const & from, std::string & name, std::string & n); + void splitname(char const * from, std::string & name, std::string & n); // An option that can be set and reset. struct concrete_option { - std::string description; + char const * description; std::string longname; std::string shortname; bool has_arg; @@ -91,8 +91,8 @@ namespace option { boost::function resetter; concrete_option(); - concrete_option(std::string const & names, - std::string const & desc, + concrete_option(char const * names, + char const * desc, bool arg, boost::function set, boost::function reset); @@ -109,16 +109,16 @@ namespace option { concrete_option_set(std::set const & other); concrete_option_set(concrete_option const & opt); - // for building a concret_option_set directly (as done in unit_tests.cc), + // for building a concrete_option_set directly (as done in unit_tests.cc), // rather than using intermediate machinery like in options* concrete_option_set & - operator()(std::string const & names, - std::string const & desc, + operator()(char const * names, + char const * desc, boost::function set, boost::function reset = 0); concrete_option_set & - operator()(std::string const & names, - std::string const & desc, + operator()(char const * names, + char const * desc, boost::function set, boost::function reset = 0); @@ -222,19 +222,19 @@ namespace option { template struct option { - std::string description; - std::string names; + char const * description; + char const * names; bool has_arg; boost::function setter; boost::function resetter; - option(std::string const & name, - std::string const & desc, + option(char const * name, + char const * desc, bool arg, void(T::*set)(std::string), void(T::*reset)()) { - I(!name.empty() || !desc.empty()); + I((name && name[0]) || (desc && desc[0])); description = desc; names = name; has_arg = arg; @@ -279,8 +279,8 @@ namespace option { options.insert(opt); } - option_set(std::string const & name, - std::string const & desc, + option_set(char const * name, + char const * desc, bool arg, void(T::*set)(std::string), void(T::*reset)()) ============================================================ --- options.cc 7a2689cbb0597dced4933dce0464157c52cbefe1 +++ options.cc ba83b047efc456f0c45b6bcb9662634c1aaa3ac9 @@ -160,10 +160,8 @@ options::options_type const & options::o # define OPTION(optset, name, hasarg, optstring, description) \ options::options_type const & options::opts::name() \ { \ - localize_monotone(); \ - \ static options::options_type val(optstring, \ - gettext(description), hasarg, \ + description, hasarg, \ &options::set_ ## name , \ &options::reset_opt_ ## name ); \ return val; \ ============================================================ --- sanity.hh c0f57fa10025bd057f6d0992483d5de05f075ea1 +++ sanity.hh 5d3ced86455ffad98885fa705c0f3f8c2bcd3227 @@ -482,8 +482,6 @@ dump(T const & t, char const *var, #define DUMP(foo) dump(foo, #foo, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) -extern void localize_monotone(); - #endif // __SANITY_HH__ // Local Variables: ============================================================ --- unit_tester.cc ee385ca238b903be23ddbaeef78d2ee78f474e8b +++ unit_tester.cc 28af6bab67aa693109a382dcd1eb35628030fb13 @@ -293,12 +293,6 @@ int main(int argc, char * argv[]) } } -// Stub for options.cc's sake. -void -localize_monotone() -{ -} - // Global sanity object. We don't want to depend on ui. struct unit_tester_sanity : public sanity {