On 01/24/2014 10:20 PM, Craig A. Berry wrote: > > On Jan 24, 2014, at 11:08 PM, karl williamson via RT <perlbug-followup@perl.org> wrote: > >> On 01/24/2014 08:58 PM, Craig A. Berry (via RT) wrote: >>> I question the expectation of locale.t that setlocale(LC_NUMERIC, NULL) will return the value of LC_NUMERIC from the environment. >> >> You're right. The value setlocale returns is opaque, and can't be >> parsed like that test expects. All that is supposedly guaranteed is >> that if you pass a value returned from a setlocale() to a later >> setlocale(), it will understand the opaque value correctly. >> >> I'll have to come up with a better test. > > The standard at: > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/setlocale.html > > says, regarding the locale argument to setlocale, > > "A null pointer -- Directs setlocale() to query the current global locale setting and return the name of the locale if category is not LC_ALL, or a string which encodes the locale name(s) for all of the individual categories ifcategory is LC_ALL." > > So are you saying that the implementations don't really do what the standard says or are you saying the "name of the locale" might not be a human-recognizable locale name but is just a key in the internal locale database or something? > ________________________________________ I'm saying the latter. I do not remember where I've read explicitly that the value is opaque, but further down in the document you linked to, it says "Upon successful completion, setlocale() shall return the string associated with the specified category for the new locale. Otherwise, setlocale() shall return a null pointer and the global locale shall not be changed. "A null pointer for locale shall cause setlocale() to return a pointer to the string associated with the specified category for the current global locale. The global locale shall not be changed. "The string returned by setlocale() is such that a subsequent call with that string and its associated category shall restore that part of the global locale. The application shall not modify the string returned. The returned string pointer might be invalidated or the string content might be overwritten by a subsequent call to setlocale()." Notice that they use the term "associated" instead of "name" here. obal locale shall not be changed. "A null pointer for locale shall cause setlocale() to return a pointer to the string associated with the specified category for the current global locale. The global locale shall not be changed. "The string returned by setlocale() is such that a subsequent call with that string and its associated category shall restore that part of the global locale. The application shall not modify the string returned. The returned string pointer might be invalidated or the string content might be overwritten by a subsequent call to setlocale()." Notice that they use the term "associated" instead of "name" here.Thread Previous