View Issue Details

IDProjectCategoryView StatusLast Update
00007021003.1(2013)/Issue7+TC1System Interfacespublic2013-05-23 16:01
Reportermdempsky Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status ClosedResolutionWithdrawn 
NameMatthew Dempsky
OrganizationOpenBSD
User Reference
Sectionnewlocale
Page Number
Line Number
Interp Status---
Final Accepted Text
Summary0000702: Clarify newlocale(LC_CTYPE_MASK, "loc1", 0)
DescriptionIn the informative examples section for newlocale(), there's an example invocation of newlocale(LC_CTYPE_MASK, "loc1", 0). POSIX says that newlocale(LC_CTYPE_MASK, "loc1", 0) should allocate a new locale object because the base argument is (locale_t)0, but it doesn't indicate what should be done about the resulting locale_t's non-LC_CTYPE locale categories.

E.g., what's the behavior of strcoll_l(s1, s2, newlocale(LC_CTYPE_MASK, "loc1", 0)) since the returned locale_t doesn't appear to have a specified collation locale?

I see a few possible solutions:

  1. Don't specify anything; it's implicitly undefined behavior if anything subsequently depends on the returned locale_t's non-LC_CTYPE categories.

  2. Specify that when (locale_t)0 is used, the newly allocated locale object defaults to the C/POSIX locale.

  3. Specify that when (locale_t)0 is used, the newly allocated locale object defaults to the calling thread's thread-local locale or the global locale if the calling thread doesn't have a thread-local locale.


I think eglibc uses option #2, while FreeBSD and NetBSD appear to use option #3. (However, neither of FreeBSD/NetBSD's newlocale()s are POSIX compliant anyway because they allocate and return a new locale_t object but then don't free the base locale_t.)

http://www.eglibc.org/cgi-bin/viewvc.cgi/trunk/libc/locale/newlocale.c?revision=22177&view=markup
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/locale/newlocale.c?rev=1.2&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/locale/xlocale.c?rev=1.6
Desired ActionSpecify the default locale category properties for a locale_t allocated with newlocale(LC_CTYPE_MASK, "loc1", 0) and generically for all other possible mask values.
TagsNo tags attached.

Activities

mdempsky

2013-05-22 06:28

reporter   bugnote:0001620

Actually, upon further review, I think FreeBSD also follows option #2.

geoffclare

2013-05-22 08:23

manager   bugnote:0001621

The end of the third paragraph of the description states:

"If a completely new locale object is created, the data for all sections not requested by category_mask shall be taken from the default locale."

mdempsky

2013-05-22 17:18

reporter   bugnote:0001622

D'oh, thanks Geoff, I missed that somehow.

No further action needed then.

Issue History

Date Modified Username Field Change
2013-05-22 06:01 mdempsky New Issue
2013-05-22 06:01 mdempsky Name => Matthew Dempsky
2013-05-22 06:01 mdempsky Organization => OpenBSD
2013-05-22 06:01 mdempsky Section => newlocale
2013-05-22 06:28 mdempsky Note Added: 0001620
2013-05-22 08:23 geoffclare Note Added: 0001621
2013-05-22 17:18 mdempsky Note Added: 0001622
2013-05-23 16:01 msbrown Interp Status => ---
2013-05-23 16:01 msbrown Status New => Closed
2013-05-23 16:01 msbrown Resolution Open => Withdrawn