bind_textdomain_codeset: fix return value

this function is documented as returning a null pointer on failure and
the current textdomain encoding, which is always UTF-8 in our
implementation, on success. there was some confusion over whether it's
expected to also return a null pointer in the case where it's using
the locale's encoding by default, rather than an explicitly bound one,
but it does not seem like that behavior would match applications'
expectations, and it would require gratuitously storing a meaningless
1-bit state for the textdomain.
This commit is contained in:
Rich Felker committed 2025-02-21 19:42:38 -05:00
1 parent 00fb7107ca
commit cabbd8697d
1 file changed
+4 -2
+4 -2
View File
@@ -5,7 +5,9 @@
char *bind_textdomain_codeset(const char *domainname, const char *codeset)
{
if (codeset && strcasecmp(codeset, "UTF-8"))
if (codeset && strcasecmp(codeset, "UTF-8")) {
errno = EINVAL;
return NULL;
return 0;
}
return "UTF-8";
}