Koka / gettext-rs

GNU Gettext FFI binding for Rust
51 stars 25 forks source link

CI: use system gettext on x86_64-unknown-linux-musl #101

Open Minoru opened 1 year ago

Minoru commented 1 year ago

This works around a segfault in tests: https://github.com/Koka/gettext-rs/issues/99

Minoru commented 1 year ago

Wow, so gettext-rs is broken for musl's built-in implementation of gettext, because:

  1. bind_textdomain_codeset() only supports UTF-8 in musl (returns EINVAL for all other codesets);
  2. bind_textdomain_codeset() always returns NULL, which we treat as an error.

The first one is our problem; we should adjust gettext-rs/tests/integration.rs to handle this.

The second one, I'm not sure. My local manpage for bind_textdomain_codeset() says:

If no codeset has been set for domain domainname, it returns NULL.

And also:

If codeset is NULL, the function returns the previously set codeset for domain domainname. The default is NULL, denoting the locale's character encoding.

I think musl stretches the definitions here, always returning NULL to indicate that it uses locale's charset, which in musl is always UTF-8.

OTOH, regardless of how valid musl's choice is, that's the reality and we should support it. In that case, it's our fault that we assume that NULL return value means failure.

I'll let this sit for a few days while I think how to proceed.