]> git.ozlabs.org Git - petitboot/commitdiff
discover: Set default language
authorJeremy Kerr <jk@ozlabs.org>
Thu, 24 Sep 2015 04:38:47 +0000 (14:38 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 24 Sep 2015 04:57:40 +0000 (14:57 +1000)
Rather than setting NULL, do a setlocale(LC_ALL, NULL) to query the
system locale value as our default.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/platform.c

index a6bd74c7a0757b0a2f2de8da38eac4c5e9ce8e81..5f448f1a4a1ba92c9111b7826b074f4da3186f74 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <fcntl.h>
 #include <string.h>
 
 #include <fcntl.h>
 #include <string.h>
+#include <locale.h>
 
 #include <log/log.h>
 #include <file/file.h>
 
 #include <log/log.h>
 #include <file/file.h>
@@ -102,6 +103,8 @@ static bool config_debug_on_cmdline(void)
 
 void config_set_defaults(struct config *config)
 {
 
 void config_set_defaults(struct config *config)
 {
+       const char *lang;
+
        config->autoboot_enabled = true;
        config->autoboot_timeout_sec = 10;
        config->autoboot_enabled = true;
        config->autoboot_enabled = true;
        config->autoboot_timeout_sec = 10;
        config->autoboot_enabled = true;
@@ -110,7 +113,6 @@ void config_set_defaults(struct config *config)
        config->network.dns_servers = NULL;
        config->network.n_dns_servers = 0;
        config->safe_mode = false;
        config->network.dns_servers = NULL;
        config->network.n_dns_servers = 0;
        config->safe_mode = false;
-       config->lang = NULL;
        config->allow_writes = true;
        config->disable_snapshots = false;
 
        config->allow_writes = true;
        config->disable_snapshots = false;
 
@@ -126,6 +128,14 @@ void config_set_defaults(struct config *config)
        config->ipmi_bootdev_persistent = false;
 
        config->debug = config_debug_on_cmdline();
        config->ipmi_bootdev_persistent = false;
 
        config->debug = config_debug_on_cmdline();
+
+       lang = setlocale(LC_ALL, NULL);
+       pb_log("lang: %s\n", lang);
+       if (lang && strlen(lang))
+               config->lang = talloc_strdup(config, lang);
+       else
+               config->lang = NULL;
+
 }
 
 int platform_init(void *ctx)
 }
 
 int platform_init(void *ctx)