Bug 29217 - locale confusion with time/collate categories
Summary: locale confusion with time/collate categories
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: 4.2.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-25 18:54 UTC by Jim Jowdy
Modified: 2006-09-27 07:39 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed: 2006-09-25 19:46:23


Attachments
Test case to reproduce the problem (90.25 KB, text/plain)
2006-09-25 18:55 UTC, Jim Jowdy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Jowdy 2006-09-25 18:54:24 UTC
I'm setting the global locale by taking the current locale (C) and overriding the collate and ctype categories with the en_US.UTF-8 locale:

locale::global(locale(locale(),"en_US.UTF-8",locale::collate|locale::ctype))

When I actually view the resulting locale with locale().name() or setlocale(LC_ALL,0), I see the following:

LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C

Note that LC_TIME reports its locale has been overridden and LC_COLLATE does not.

---------------------

% gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20060525 (Red Hat 4.1.1-1)
Comment 1 Jim Jowdy 2006-09-25 18:55:56 UTC
Created attachment 12324 [details]
Test case to reproduce the problem
Comment 2 Paolo Carlini 2006-09-25 21:58:06 UTC
Working on it.
Comment 3 paolo@gcc.gnu.org 2006-09-27 07:08:36 UTC
Subject: Bug 29217

Author: paolo
Date: Wed Sep 27 07:08:13 2006
New Revision: 117247

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117247
Log:
2006-09-27  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/29217
	* src/localename.cc (locale::_Impl::_M_replace_categories)):
	Compensate for the inconsistent numerical encodings of the
	collate and time categories vs the corresponding names.
	* testsuite/22_locale/locale/cons/29217.cc: New.

	* testsuite/22_locale/locale/cons/2.cc: Enable and split
	out the few ENC_TRAITS bits to...
	* testsuite/22_locale/locale/cons/unicode/1.cc... here.

Added:
    trunk/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc
    trunk/libstdc++-v3/testsuite/22_locale/locale/cons/unicode/
    trunk/libstdc++-v3/testsuite/22_locale/locale/cons/unicode/1.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/src/localename.cc
    trunk/libstdc++-v3/testsuite/22_locale/locale/cons/2.cc

Comment 4 Paolo Carlini 2006-09-27 07:39:27 UTC
Fixed for 4.2.0.
Comment 5 paolo@gcc.gnu.org 2006-09-28 14:40:31 UTC
Subject: Bug 29217

Author: paolo
Date: Thu Sep 28 14:40:12 2006
New Revision: 117282

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117282
Log:
2006-09-28  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/29217
	* include/bits/locale_classes.h: Fix (swap) numerical encodings of
	time and collate categories.
	* src/locale_init.cc: Consistently reorder locale::_Impl::_S_id_time
	and _S_id_collate.
	* src/locale.cc: Tweak.

Modified:
    branches/libstdcxx_so_7-branch/libstdc++-v3/include/bits/locale_classes.h
    branches/libstdcxx_so_7-branch/libstdc++-v3/src/locale.cc
    branches/libstdcxx_so_7-branch/libstdc++-v3/src/locale_init.cc

Comment 6 paolo@gcc.gnu.org 2006-09-28 14:40:58 UTC
Subject: Bug 29217

Author: paolo
Date: Thu Sep 28 14:40:46 2006
New Revision: 117283

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117283
Log:
2006-09-28  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/29217
	* include/bits/locale_classes.h: Fix (swap) numerical encodings of
	time and collate categories.
	* src/locale_init.cc: Consistently reorder locale::_Impl::_S_id_time
	and _S_id_collate.
	* src/locale.cc: Tweak.

Modified:
    branches/libstdcxx_so_7-branch/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch