This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix libstdc++/7811


Roland McGrath wrote:

I'm unsure about the following points: in case LC_ALL is not set is the fallback to LANG really needed (PR submitter implicitly expected this to be the case)? Also, if neither are set is always correct that "" -> "C"?

The standards specify looking at LC_ALL, then at the variable for the particular category if setting just one, then at LANG.

I see. However, do you mean the C standards or the C++ standard?
I cannot find in the latter (more relevant here) a detailed discussion of this point (well, the existing code just considers LC_ALL in the setlocale...)

Note that a variable
that is present but empty (e.g. getenv("LC_ALL") => "") is treated as not
present.

This is an interesting technical point, thanks. However, once more, I'm not sure if the C++ standard (vs C) actually prescribes something in detail about this. Can you possibly help?

Off hand I am not sure if the behavior when none are set is
specified or is implementation-defined.  Defaulting to "C" is safe and
consistent.

Good.

Another thing to note if you want to match the selection behavior of
setlocale is that if the name contains a slash and the program is setuid
then the name will be ignored and "C" used instead.  (It doesn't check
this on each variable, just on the name chosen from any.)

Another interesting technical point. As you say, however, it looks like the real point is: "Must we really match the detailed selection behavior of setlocale?" I don't believe that for the implementation of the locale functionality at issue this is mandated anywhere in the C++ standard.

Benjamin, what do you think?

My personal opinion is that my proposal is a definite improvement on the current situation but I'm not sure how many additional details we must consider to agree with the C++ standard.

Ciao, Paolo.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]