Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000582 [1003.1(2008)/Issue 7] System Interfaces Editorial Clarification Requested 2012-06-15 22:06 2019-06-10 08:55
Reporter mdempsky View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Matthew Dempsky
Organization OpenBSD
User Reference
Section uselocale()
Page Number http://pubs.opengroup.org/onlinepubs/9699919799/functions/uselocale.html [^]
Line Number N/A
Interp Status Approved
Final Accepted Text See Note: 0001273
Summary 0000582: uselocale(0) is poorly specified
Description I believe uselocale(0) is poorly specified in a number of ways:

1. uselocale() says it fails with EINVAL if "locale is not a valid locale object". First, there's no 'locale' variable in the text (the parameter is named 'newloc'), and second (locale_t)0 is a valid argument but not a valid [pointer to a] locale object so the current text suggests it might fail with EINVAL.

  1b. Also, uselocale() and duplocale() have may-fail EINVAL case for invalid locale_t parameters, but newlocale() and freelocale() do not. That seems inconsistent to me.

2. There's no explanation about what happens to the thread's current installed locale by a call to uselocale(0). The text only says "The uselocale() function shall set the current locale for the current thread to the locale represented by newloc." and there's no explanation as to what locale is represented by (locale_t)0. I believe the intent is that (locale_t)0 represents either the current locale or LC_GLOBAL_LOCALE if there has been no previous call to uselocale(), but the text only explains what is returned by uselocale(0).

3. The return value text is poorly specified for "uselocale(0), uselocale(0)". The second call should return "the locale handle from the previous call", which seems to indicate it should return (locale_t)0 (except that duplocale() and newlocale()'s return value text implies (locale_t)0 is not a valid locale handle).


Also, there seems to be a lot of typographic inconsistencies in the online HTML for the new locale.h functions. E.g., they always use "( locale_t)0" which seems inconsistent with other text that omits the space; e.g., mbsnrtowcs()'s description uses "(size_t)-1".
Desired Action Change:

    If the newloc argument is a null pointer, the object returned is the current locale or LC_GLOBAL_LOCALE if there has been no previous call to uselocale() for the current thread.

to:

    If the newloc argument is a null pointer, the thread shall either continue using the current locale set by the last call to uselocale() or shall use the global locale if there was no such last call.


Change the RETURN VALUE section text to:

    Upon successful completion, the uselocale() function shall return a handle for the last set current locale for the current thread or LC_GLOBAL_LOCALE if there was no such current locale. Otherwise, uselocale() shall return (locale_t)0 and set errno to indicate the error.
Tags tc2-2008
Attached Files

- Relationships
related to 0000302Closedajosey Changes needed to account for uselocale() 
related to 0000301Closedajosey Specify the behaviour of duplocale(LC_GLOBAL_LOCALE) 
related to 0000290Closedajosey Reference to "null pointer" on uselocale() page 
related to 0000334Closedajosey uselocale() error handling 

-  Notes
(0001265)
geoffclare (manager)
2012-06-18 11:36
edited on: 2012-08-08 15:09

There are changes being made to uselocale() by TC1 that need to be taken
into account here. Also, I don't think the proposed changes go far
enough to solve all the problems with the way the handling of special
arguments by uselocale() is specified.

Replace the DESCRIPTION, RETURN VALUE, and ERRORS sections with:

DESCRIPTION
    The uselocale() function shall set or query the current locale for
    the calling thread.

    The value for the newloc argument shall be one of the following:

        1. A value returned by the newlocale() or duplocale() functions
        2. The special locale object descriptor LC_GLOBAL_LOCALE
        3. (locale_t)0

    If the newloc argument is (locale_t)0, the current locale shall
    not be changed; this value can be used to query the current locale
    setting. If the newloc argument is LC_GLOBAL_LOCALE, any thread-
    local locale for the calling thread shall be uninstalled; the
    thread shall again use the global locale as the current
    locale, and changes to the global locale shall affect the thread.
    Otherwise, the locale represented by newloc shall be installed as
    a thread-local locale to be used as the current locale for the
    calling thread.

    Once the uselocale() function has been called to install a
    thread-local locale, the behavior of every interface using data
    from the current locale shall be affected for the calling thread.
    The current locale for other threads shall remain unchanged.

RETURN VALUE
    Upon successful completion, the uselocale() function shall return
    a handle for the thread-local locale that was in use as the current
    locale for the calling thread on entry to the function, or
    LC_GLOBAL_LOCALE if no thread-local locale was in use. Otherwise,
    uselocale() shall return (locale_t)0 and set errno to indicate the
    error.

ERRORS
    The uselocale() function may fail if:

    [EINVAL] newloc is not a valid locale object and is not (locale_t)0.

(0001266)
mdempsky (reporter)
2012-06-18 16:20

That wording looks good to me!

(There's a typo in the ERRORS section though: "(locale)t)0" should be "(locale_t)0".)
(0001273)
Don Cragun (manager)
2012-06-28 16:08

Interpretation response
------------------------
The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.

Rationale:
-------------
The changes are needed to make uselocale(0) useful.

Notes to the Editor (not part of this interpretation):
Make the changes listed in Note: 0001265
(0001283)
ajosey (manager)
2012-06-29 16:14

Interpretation proposed 29 June 2012 for final 45 day review
(0001346)
ajosey (manager)
2012-08-30 09:12

Interpretation approved 30 Aug 2012

- Issue History
Date Modified Username Field Change
2012-06-15 22:06 mdempsky New Issue
2012-06-15 22:06 mdempsky Status New => Under Review
2012-06-15 22:06 mdempsky Assigned To => ajosey
2012-06-15 22:06 mdempsky Name => Matthew Dempsky
2012-06-15 22:06 mdempsky Organization => OpenBSD
2012-06-15 22:06 mdempsky Section => uselocale()
2012-06-15 22:06 mdempsky Page Number => http://pubs.opengroup.org/onlinepubs/9699919799/functions/uselocale.html [^]
2012-06-15 22:06 mdempsky Line Number => N/A
2012-06-18 11:36 geoffclare Note Added: 0001265
2012-06-18 16:20 mdempsky Note Added: 0001266
2012-06-18 16:29 geoffclare Note Edited: 0001265
2012-06-28 16:08 Don Cragun Interp Status => ---
2012-06-28 16:08 Don Cragun Note Added: 0001273
2012-06-28 16:08 Don Cragun Status Under Review => Interpretation Required
2012-06-28 16:08 Don Cragun Resolution Open => Accepted As Marked
2012-06-28 16:09 Don Cragun Final Accepted Text => See Note: 0001273
2012-06-28 16:09 Don Cragun Interp Status --- => Pending
2012-06-28 16:10 Don Cragun Tag Attached: issue8
2012-06-28 16:10 Don Cragun Tag Attached: tc2-2008
2012-06-28 16:11 Don Cragun Tag Detached: issue8
2012-06-28 20:03 eblake Relationship added related to 0000302
2012-06-28 20:06 eblake Relationship added related to 0000301
2012-06-28 20:07 eblake Relationship added related to 0000290
2012-06-28 20:08 eblake Relationship added related to 0000334
2012-06-29 16:14 ajosey Interp Status Pending => Proposed
2012-06-29 16:14 ajosey Note Added: 0001283
2012-08-08 15:09 geoffclare Note Edited: 0001265
2012-08-30 09:12 ajosey Interp Status Proposed => Approved
2012-08-30 09:12 ajosey Note Added: 0001346
2019-06-10 08:55 agadmin Status Interpretation Required => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker