# newlocale() failed with "No such file or directory"



## Masahiko Sawada (Apr 12, 2022)

Hi,

While testing newlocale(3) function with all locales listed by `locale -a` on my machine, the function failed with "be_BY.ISO8859-5" and "ca_IT.ISO8859-15" with "No such file or directory":

```
$ ls /usr/share/locale/ca_IT.ISO8859-15
LC_CTYPE        LC_MESSAGES     LC_MONETARY     LC_NUMERIC      LC_TIME
$ ls /usr/share/locale/be_BY.ISO8859-5
LC_CTYPE        LC_MESSAGES     LC_MONETARY     LC_NUMERIC      LC_TIME

$ uname -KvU
FreeBSD 14.0-CURRENT #0 main-n254105-d53927b0bae: Thu Mar 31 05:47:31 UTC 2022     [email]root@releng1.nyi.freebsd.org[/email]:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC 1400055 1400055
```
How can I install or define LC_COLLATE of these two locales?

FYI, the program I used to test is:

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

int main() {
  locale_t loc;
  FILE *fp;
  char *locname;
  char buf[1024];

  if ((fp = popen("locale -a", "r")) == NULL)
    return 1;

  while ((locname = fgets(buf, 1024, fp)) != NULL) {
    locname[strlen(locname) - 1] = '\0';
    loc = newlocale(LC_COLLATE_MASK, locname, NULL);
    if (loc) {
      // ok
      freelocale(loc);
    } else {
      printf("%s: NG (%m)\n", locname);
    }
  }

  pclose(fp);
  return 0;
}
```
Regards,


----------



## SirDice (Apr 12, 2022)

Masahiko Sawada said:


> ```
> $ uname -KvU
> FreeBSD 14.0-CURRENT #0 main-n254105-d53927b0bae: Thu Mar 31 05:47:31 UTC 2022 [email]root@releng1.nyi.freebsd.org[/email]:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC 1400055 1400055
> ```


Topics about unsupported FreeBSD versions

Also note that RISC-V is a Tier 2 platform.


----------



## mark_j (Apr 13, 2022)

It's built via colldef, msgdef, timedef, monetdef etc in */usr/src/share *using the `localedef` command.
As has been stated, this is probably missed due to some failure in the builds and you're using a bleeding-edge FreeBSD build.

You can just resolve it by copying from FreeBSD 13, if necessary.


----------



## Masahiko Sawada (Apr 18, 2022)

Thanks for your reply.

I'll try to use `localdef` to build them.


----------

