aboutsummaryrefslogtreecommitdiffstats
path: root/ui/language.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-04-28 12:33:28 -0700
committerGuy Harris <guy@alum.mit.edu>2016-04-28 19:34:02 +0000
commit232b2de7bb008a2bc7c3e5eece04aab16215d24c (patch)
tree488390f23d6b9c2d18068889b716425466879c88 /ui/language.c
parent7150588d23d5ab844dd99507ec94831375a07b67 (diff)
Use "system" for "use system language", and don't try to print a null string.
Add a #define USE_SYSTEM_LANGUAGE for the language string meaning "use the system setting", and use that instead of hardcoding "system" in various places. If "language" is null, don't try to write it to the file with fprintf() - on *most* systems, that prints "(null)", but on some systems, such as Solaris, it *crashes*. Write USE_SYSTEM_LANGUAGE instead. Check for "(null)" and treat it as meaning "use the system language". Map "auto" to "use the system language" as well, for backwards compatibility. Change-Id: Iba9be540a5139e9cca8bddd0761ee4cbf0f79a49 Reviewed-on: https://code.wireshark.org/review/15147 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/language.c')
-rw-r--r--ui/language.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/language.c b/ui/language.c
index 65a338011e..2bc721aafa 100644
--- a/ui/language.c
+++ b/ui/language.c
@@ -48,8 +48,19 @@ read_language_pref(gchar *key, const gchar *value,
if (strcmp(key, LANGUAGE_PREF_LANGUAGE) == 0) {
if (language)
g_free(language);
- if (!value || !*value)
- language = g_strdup("auto");
+ /*
+ * For backwards compatibility, treat "auto" as meaning "use the
+ * system language".
+ *
+ * To handle the old buggy code that didn't check whether "language"
+ * was null before trying to print it, treat "(null)" - which many,
+ * but *NOT* all, system printfs print for a null pointer (some
+ * printfs, such as the one in Solaris, *crash* with %s and a null
+ * pointer) - as meaning "use the system language".
+ */
+ if (!value || !*value || strcmp(value, "auto") == 0 ||
+ strcmp(value, "(null)") == 0)
+ language = g_strdup(USE_SYSTEM_LANGUAGE);
else
language = g_strdup(value);
}
@@ -113,7 +124,7 @@ write_language_prefs(void)
"# So be careful, if you want to make manual changes here.\n"
"\n", rf);
- fprintf(rf, LANGUAGE_PREF_LANGUAGE ": %s\n", language);
+ fprintf(rf, LANGUAGE_PREF_LANGUAGE ": %s\n", language ? language : USE_SYSTEM_LANGUAGE);
fclose(rf);