[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [f13-branch] loader: con Newt into thinking LANG is always en_US.UTF-8 (#576541).



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 31 Mar 2010, Ales Kozumplik wrote:

---
loader/loader.c |   15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 2b2094a..8d47f1e 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -125,6 +125,7 @@ int post_link_sleep = 0;

static pid_t init_pid = 1;
static int init_sig = SIGUSR1; /* default to shutdown=halt */
+static const char *LANG_DEFAULT = "en_US.UTF-8";

static struct installMethod installMethods[] = {
    { N_("Local CD/DVD"), 0, DEVICE_CDROM, mountCdromImage },
@@ -220,10 +221,20 @@ void startNewt(void) {
    if (!newtRunning) {
        char *buf;
        char *arch = getProductArch();
-
        checked_asprintf(&buf, _("Welcome to %s for %s"), getProductName(), arch);

+        /*
+         * Because currently initrd.img only has got the default English locale
+         * support, pretend for newtInit() it is actually the used LANG so Newt
+         * knows how to compute character widths etc.
+         **/
+        char *lang = strdup(getenv("LANG"));

getenv() can return NULL here, in which case we don't want to strdup() the
result.

+        setenv("LANG", LANG_DEFAULT, 1);
        newtInit();
+        /* restore the original LANG value */
+        setenv("LANG", lang, 1);
+        free(lang);
+
        newtCls();
        newtDrawRootText(0, 0, buf);
        free(buf);
@@ -319,7 +330,7 @@ char * getProductPath(void) {

void initializeConsole() {
    /* enable UTF-8 console */
-    setenv("LANG","en_US.UTF-8",1);
+    setenv("LANG", LANG_DEFAULT, 1);
    printf("\033%%G");
    fflush(stdout);



The idea looks fine, except we need to handle the case where $LANG does not
exist in the environment table.

- -- David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkuzZuAACgkQ5hsjjIy1VkmsjACg+Wv+oQOmicOdBmGPj9p9tICd
wrsAoKAweAi0C4WKSx9oDuKhniqCb4f0
=3sZN
-----END PGP SIGNATURE-----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]