FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Server Development

 
 
LinkBack Thread Tools
 
Old 03-31-2010, 03:14 PM
David Cantrell
 
Default 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("33%%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+oQOmic OdBmGPj9p9tICd
wrsAoKAweAi0C4WKSx9oDuKhniqCb4f0
=3sZN
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-31-2010, 04:30 PM
David Cantrell
 
Default 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:


On 03/31/2010 05:14 PM, David Cantrell wrote:

+ /*
+ * 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.



Thanks for that catch. Is this better?

char *lang = getenv("LANG");
if (lang) {
lang = strdup(lang);
}
setenv("LANG", LANG_DEFAULT, 1);
newtInit();
unsetenv("LANG");
/* restore the original LANG value */
if (lang) {
setenv("LANG", lang, 1);
free(lang);
}



Looks better. Ack.

- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

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

iEYEARECAAYFAkuzeK0ACgkQ5hsjjIy1Vkl2ZgCgtHdjxW+iEG SSPukvogw49T7r
f8IAnicGBsNiyUawz4oAyAEcUBXfVNZZ
=H3R0
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-31-2010, 04:38 PM
David Cantrell
 
Default loader: con Newt into thinking LANG is always en_US.UTF-8 (#576541).

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

On Wed, 31 Mar 2010, David Cantrell wrote:


On Wed, 31 Mar 2010, Ales Kozumplik wrote:


On 03/31/2010 05:14 PM, David Cantrell wrote:

+ /*
+ * 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.



Thanks for that catch. Is this better?

char *lang = getenv("LANG");
if (lang) {
lang = strdup(lang);
}
setenv("LANG", LANG_DEFAULT, 1);
newtInit();
unsetenv("LANG");
/* restore the original LANG value */
if (lang) {
setenv("LANG", lang, 1);
free(lang);
}



Looks better. Ack.




Also, make sure you apply this to master and not just f13-branch.

- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

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

iEYEARECAAYFAkuzenYACgkQ5hsjjIy1VkmdiQCdEAbciM5FhZ F08meSyZwqJyZc
iIwAnRK9JvbSZz67Li2JdV9bMt8bNrVT
=+2UZ
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 03:08 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org