This is the mail archive of the glibc-bugs@sourceware.org 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]
Other format: [Raw text]

[Bug localedata/10503] New: setlocale returns a valid locale and sets errno to ENOENT


If $LANG is any available locale other than C or POSIX,

If /usr/lib/locale/locale-archive does not exist setlocale is setting errno to
ENOENT.

If locale data are stored in /usr/lib/locale/<locale_name>/LC_* files, then
/usr/lib/locale/locale-archive is not needed and errno must not be set.

Try to compile and run the code below:

// slt.c

#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main ()
{
  char *c = setlocale (LC_NUMERIC, "");
  fprintf (stderr, "errno = %s\n", strerror (errno));
  fprintf (stderr, "setlocale (LC_NUMERIC, \"\") returned %s\n", c);
  return 0;
}

// The C code ended.

Example:

pedro@ubuntu:~/programming/c/setlocale problem$ ./slt.Ubuntu64
errno = Success
setlocale (LC_NUMERIC, "") returned pt_BR.utf8
pedro@ubuntu:~/programming/c/setlocale problem$ sudo mv
/usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.valid
[sudo] password for pedro: 
pedro@ubuntu:~/programming/c/setlocale problem$ ./slt.Ubuntu64
errno = No such file or directory
setlocale (LC_NUMERIC, "") returned pt_BR.utf8

-- 
           Summary: setlocale returns a valid locale and sets errno to
                    ENOENT
           Product: glibc
           Version: 2.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: localedata
        AssignedTo: libc-locales at sources dot redhat dot com
        ReportedBy: Pedro dot Izecksohn at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10503

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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