[Bug 6356] New: Unicode support logic badly broken

bugzilla at busybox.net bugzilla at busybox.net
Sat Jun 29 19:40:04 UTC 2013


https://bugs.busybox.net/show_bug.cgi?id=6356

           Summary: Unicode support logic badly broken
           Product: Busybox
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: bugdal at aerifal.cx
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


The unicode detection logic in Busybox is presently broken; rather than letting
setlocale() determine the correct locale via the various LC_* environment
variables and the implementation-defined default if none of them are set, it
looks for the LANG variable itself and uses the C locale if LANG is not set.

My best guess is that the motivation for this elaborate-but-incorrect approach
was to allow changes in the LANG variable in shells to take place immediately,
even if they're not added to the environment in the shell process. However, the
logic is not correct, so it's hardly usable.

To fix the issue, simply change the setlocale line in libbb/unicode.c from:

setlocale(LC_ALL, (LANG && LANG[0]) ? LANG : "C");

to:

setlocale(LC_ALL, "");

However, this does not address runtime changes to locale in shells. The only
way I know to achieve the latter without setenv/putenv in the shell process
whenever an environment variable is changed (which would be a bad idea) is to
run the external "locale" utility (which could be a busybox internal if someone
implements it) in a separate process, with all the locale-related variables
exported to it. It can then determine the resulting LC_CTYPE and return it to
the parent for the parent to pass to setlocale.

Personally, I think it would be acceptable for the shell to only honor the
locale setting when it's started, and not to attempt to handle changes while
it's running.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list