This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

normalize_codeset


What's the purpose of the normalize_codeset done by localedef?
Is it to permit that users enter the locale in lowercase and possibly
without dashes?

Then why is it *not* done if a full pathname for the locale is given?
This has the consequence that the ru_RU.KOI8-R locale (installed by
"make localedata/install-locales") is really called ru_RU.KOI8-R.

I noticed that it causes unnecessary system calls when a program calls
setlocale(LC_ALL,""). For each of the LC_CTYPE, LC_COLLATE etc. facets
strace shows three system calls

   open ("/usr/lib/locale/de_DE.UTF-8/<facet>") -> -1 / ENOENT
   open ("/usr/lib/locale/de_DE.UTF-8/<facet>") -> -1 / ENOENT
   open ("/usr/lib/locale/de_DE.utf8/<facet>") -> fd, success

Without normalize_codeset, only one system call would be needed.

Ulrich Drepper wrote on linux-utf8:

> >   - Recommend to call localedef with a full pathname argument, otherwise
> >     it creates a locale which doesn't work with XFree86 4.0.1.
> 
> This is wrong from the libc side.  When not called with a complete
> path the names are normalized which is essential to allow all the
> different spellings of the locale names people are using.  It's none
> of XFree's business to look at these files.

XFree86 doesn't look at these files. It looks at the return value of
setlocale(LC_CTYPE,NULL) and uses the resulting string
1) as an index in its own database of XLC_LOCALE files,
2) to determine whether it's an UTF-8 locale.

For 2) there is a better way: nl_langinfo(CODESET). I'll implement it
in XFree86 when I find time.

But 1) is a legitimate use. The normalize_codeset done by localedef
will force me to duplicate all the UTF-8 entries in X11's
locale.alias file.

Bruno

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]