# # patch "ChangeLog" # from [5e984256d8f460f3b81f6ec914dcdc6a03411985] # to [67898178362cbf8c5617781a5d79c9a508d2e1a8] # # patch "commands.cc" # from [8ee3d05b9392b95d007cc12d4a0addc3a0dc049f] # to [e8e0216c1ff7403a3e9b5b81469a84504f784695] # ======================================================================== --- ChangeLog 5e984256d8f460f3b81f6ec914dcdc6a03411985 +++ ChangeLog 67898178362cbf8c5617781a5d79c9a508d2e1a8 @@ -1,5 +1,9 @@ 2005-10-11 Matthew Gregan + * commands.cc (message_width, explain_usage): New function to + calculate display width of translated strings. Use it in + explain_usage. + Patch from Thomas Moschny * certs.cc (get_user_key): Correct logic in N() test for multiple keys. Resolves bug reported by Malte Thoma. ======================================================================== --- commands.cc 8ee3d05b9392b95d007cc12d4a0addc3a0dc049f +++ commands.cc e8e0216c1ff7403a3e9b5b81469a84504f784695 @@ -181,18 +181,17 @@ // convert from multi-byte to wide-char string size_t wchars = mbstowcs(NULL, msg, 0) + 1; if (wchars == (size_t)-1) - return 0; - wchar_t * wmsg = new wchar_t[wchars]; - mbstowcs(wmsg, msg, wchars); + return std::strlen(msgid); // conversion failed; punt and return original length + boost::scoped_array wmsg(new wchar_t[wchars]); + mbstowcs(wmsg.get(), msg, wchars); // and get printed width - size_t width = wcswidth(wmsg, wchars); - - delete[] wmsg; + size_t width = wcswidth(wmsg.get(), wchars); + return width; } - + void explain_usage(string const & cmd, ostream & out) { map::const_iterator i;