[Moved from tuxpaint-i18n to tuxpaint-dev]

On Mon, 12 Jul 2004, Karl Ove Hufthammer wrote:

> I have made the necessary changes. Regarding the 'LC_ALL' bug, was
> this related to stamp descriptions not showing when manually
> selecting a language? The logic for this still doesn't make too
> much sense. :/

Well, yes.  That's the only way I test it.  My system is normally set to
the default locale ("C", I guess, but it's technically blank, "") and I
tell Tuxpaint to run in Korean mode when I want to test Korean...

Anyway, Korean works now, but I looked at the sourcecode and something
doesn't make sense to me.  There are two ways of setting the locale, using
setlocale and using putenv.  Here's their order of execution in Tux Paint:

   setlocale(LC_ALL, NULL)     // main(), line 701
   ...
   if "--locale":
     putenv(LANG=xx_XX)        // setup(), line 4245
     setlocale(LC_ALL, "")     // setup(), line 4247
   ...
   if "--lang":
     putenv(LANGUAGE=xx_XX)    // setup(), lines 4401 to 4652
     putenv(LC_ALL=xx_XX)      // (same)
   ...
   setlocale(LC_ALL, "")       // setup(), line 4667

I have several puzzling thoughts:

   1. Why are we using two different methods of setting the locale,
      setlocale() and putenv()?  Shouldn't we use just one method?
      (I prefer putenv() if there are no objections, because setlocale()
      sometimes rejects a valid locale.)

   2. Shouldn't we use the same method to set the locale when "--locale"
      option is used, as when "--lang" option is used?

   3. Why are we clearing LC_ALL using setlocale() after going through
      all the trouble of setting LC_ALL using putenv()?

   4. Why does this code work, if we're clearing LC_ALL?  Actually, I
      do know the answer to that question.  Please read below.

BTW, the `setlocale(LC_ALL, "")` call doesn't do anything.  setlocale() is
designed to reject any invalid locales.  So when you try to change LC_ALL
using the emptry string, "", setlocale rejects the change (since "" is not
a valid locale) and the LC_ALL environment variable is preserved.

I propose that we change the above to this:

   /* REMOVE: setlocale(LC_ALL, NULL) */ // don't clear existing LC_ALL
   ...
   if "--locale":
     putenv(LANGUAGE=xx_XX)       // LANG to LANGUAGE
     putenv(LC_ALL=xx_XX)         // set LC_ALL, too
   ...
   if "--lang":
     putenv(LANGUAGE=xx_XX)       // keep
     putenv(LC_ALL=xx_XX)         // keep
   ...
   /* REMOVE: setlocale(LC_ALL, "") */    // don't clear LC_ALL

Comments?

-Mark


-- 
Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.php?uid=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E  5167 6822 94F0 F298 5DCE
PGP key available on the homepage
_______________________________________________
Tuxpaint-dev mailing list
[EMAIL PROTECTED]
http://tux4kids.net/mailman/listinfo/tuxpaint-dev

Reply via email to