aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-03-12 15:59:10 +0000
committerAnders Broman <a.broman58@gmail.com>2016-03-17 14:59:27 +0000
commitc18736c2e7f9e56fa61658d6b4f8c172fc53f2bd (patch)
tree111e877c1ffa0a91380f743d3dce43e2534ece99 /wsutil
parent8def5c40ded9e31cda4cdd897dd19537fe8fe5d9 (diff)
wsutil: Split locale information into tokens and format it
The locale information returned by setlocale() can be a very long unbroken string. This makes the text dialog too wide without line wrapping and in some cases it spans outside the screen border. Add some commas to improve readability and help GTK+ render it properly. Change-Id: Ia7913550ada3ebaac9c783e9ac1b202dbe1563fc Reviewed-on: https://code.wireshark.org/review/11961 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/ws_version_info.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/wsutil/ws_version_info.c b/wsutil/ws_version_info.c
index b1df7aa383..9029598892 100644
--- a/wsutil/ws_version_info.c
+++ b/wsutil/ws_version_info.c
@@ -268,6 +268,24 @@ get_compiler_info(GString *str)
#endif
}
+/* XXX - is the setlocale() return string opaque? For glibc the separator is ';' */
+static gchar *
+get_locale(void)
+{
+ const gchar *lang;
+ gchar **locv, *loc;
+
+ lang = setlocale(LC_ALL, NULL);
+ if (lang == NULL) {
+ return NULL;
+ }
+
+ locv = g_strsplit(lang, ";", -1);
+ loc = g_strjoinv(", ", locv);
+ g_strfreev(locv);
+ return loc;
+}
+
/*
* Get various library run-time versions, and the OS version, and append
* them to the specified GString.
@@ -303,10 +321,14 @@ get_runtime_version_info(void (*additional_info)(GString *))
* 65001, i.e. UTF-8, as your system code page probably
* works best with Wireshark.)
*/
- if ((lang = setlocale(LC_ALL, NULL)) != NULL)
+ if ((lang = get_locale()) != NULL) {
g_string_append_printf(str, ", with locale %s", lang);
- else
+ g_free(lang);
+ }
+ else {
g_string_append(str, ", with default locale");
+ }
+
/* Additional application-dependent information */
if (additional_info)