-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finer-grained return values from bind_textdomain_codeset() #17163
Comments
POSIX is pretty clear here:
and
If musl (or any other implementation) return NULL here, they are not conforming to the specification. And that errno is unchanged, is to be expected. What is PHP supposed to do? Just say "yeah, the call was successful" would be wrong. |
I'm only talking about bind_textdomain_codeset here, not
and
musl is still a little bit weird in that it returns |
Well, seems that #6631 had been done without much thinking; should have returned |
…musl The musl implementation of bind_textdomain_codeset() always returns NULL. The POSIX-correctness of this is debatable, but it is roughly equivalent to correct, because musl only support UTF-8, so the NULL value indicating that the codeset is unchanged from the locale's codeset (UTF-8) is accurate. PHP's bind_textdomain_codeset() function however treats NULL as failure, unconditionally: * php/doc-en#4311 * php#17163 This unfortunately causes false to be returned consistently on musl -- even when nothing unexpected has happened -- and naturally this is affecting several tests. For now we change two tests to accept "false" in addition to "UTF-8" so that they may pass on musl. If PHP's bind_textdomain_codeset() is updated to differentiate between NULL and NULL-with-errno-set, these tests can also be updated once again to reject the NULL-with-errno result. This partially addresses GH php#13696
Description
As mentioned in php/doc-en#4311, the
bind_textdomain_codeset()
function returnsfalse
in some "success" cases because it is only looking at theNULL
returned from the C function. But thatNULL
is not necessarily an error, it just means that the codeset has not changed from the default. In particular, you'll get aNULL
from glibc if you query a codeset that hasn't been set yet, and you'll always getNULL
on musl.According to https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/bind_textdomain_codeset.html, the value of
errno
may be a better indicator:The text was updated successfully, but these errors were encountered: