From ccd09baedd01fa2c5a07f2665e8630378b53b246 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 7 Apr 2015 14:58:45 +0200 Subject: [PATCH] Fix about text encoding (partial revert of dc96cb4d) It was actually a feature to translate the about string multiple times as we may need different character encodings for it. We still want a better approach that allows the compiler to analyse the format string though so it isn't just a simple revert. --- vncviewer/vncviewer.cxx | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 09d07150..09c8b2fe 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -82,8 +82,6 @@ using namespace network; using namespace rfb; using namespace std; -static char aboutText[1024]; - char vncServerName[VNCSERVERNAMELEN] = { '\0' }; static const char *argv0 = NULL; @@ -91,6 +89,24 @@ static const char *argv0 = NULL; static bool exitMainloop = false; static const char *exitError = NULL; +static const char *about_text() +{ + static char buffer[1024]; + + // This is used in multiple places with potentially different + // encodings, so we need to make sure we get a fresh string every + // time. + snprintf(buffer, sizeof(buffer), + _("TigerVNC Viewer %d-bit v%s\n" + "Built on: %s\n" + "Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n" + "See http://www.tigervnc.org for information on TigerVNC."), + (int)sizeof(size_t)*8, PACKAGE_VERSION, + BUILD_TIMESTAMP, 2015); + + return buffer; +} + void exit_vncviewer(const char *error) { // Prioritise the first error we get as that is probably the most @@ -104,7 +120,7 @@ void exit_vncviewer(const char *error) void about_vncviewer() { fl_message_title(_("About TigerVNC Viewer")); - fl_message("%s", aboutText); + fl_message("%s", about_text()); } #ifdef __APPLE__ @@ -417,19 +433,10 @@ int main(int argc, char** argv) bindtextdomain(PACKAGE_NAME, LOCALE_DIR); textdomain(PACKAGE_NAME); - // Generate the about string now that we get the proper translation - snprintf(aboutText, sizeof(aboutText), - _("TigerVNC Viewer %d-bit v%s\n" - "Built on: %s\n" - "Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n" - "See http://www.tigervnc.org for information on TigerVNC."), - (int)sizeof(size_t)*8, PACKAGE_VERSION, - BUILD_TIMESTAMP, 2015); - rfb::SecurityClient::setDefaults(); // Write about text to console, still using normal locale codeset - fprintf(stderr,"\n%s\n", aboutText); + fprintf(stderr,"\n%s\n", about_text()); // Set gettext codeset to what our GUI toolkit uses. Since we are // passing strings from strerror/gai_strerror to the GUI, these must -- 2.39.5