summaryrefslogtreecommitdiff
path: root/src/locale
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2025-02-21 19:42:38 -0500
committerRich Felker <dalias@aerifal.cx>2025-02-21 19:42:38 -0500
commitcabbd8697d39c09ca37fb3d63b86b42526b81fda (patch)
tree03091917f3a2b8ea71ff08122b5eda35f9cce930 /src/locale
parent00fb7107cafc9cd7316f85ae2d8b61e478caaa7f (diff)
downloadmusl-cabbd8697d39c09ca37fb3d63b86b42526b81fda.tar.gz
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.
Diffstat (limited to 'src/locale')
-rw-r--r--src/locale/bind_textdomain_codeset.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/locale/bind_textdomain_codeset.c b/src/locale/bind_textdomain_codeset.c
index 5ebfd5e8..240e83ed 100644
--- a/src/locale/bind_textdomain_codeset.c
+++ b/src/locale/bind_textdomain_codeset.c
@@ -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";
}