[PATCH] libc/locale/locale.c: Allow "C." additionally to "C-" prefix

Jeff Johnston jjohnstn@redhat.com
Tue Sep 29 19:11:00 GMT 2009


On 29/09/09 12:39 PM, Corinna Vinschen wrote:
> Ping?
>
>
> Corinna
>
>
> On Sep 23 11:38, Corinna Vinschen wrote:
>> Hi,
>>
>> The C- prefix as used by newlib for a long time allows to specify
>> a charset alone, while sticking to the "C" locale, thus staying
>> language neutral.
>>
>> The Debian project is going along with the idea to allow to use the
>> UTF-8 charset while keeping all other settings language neutral.
>> The syntax for this locale is "C.UTF-8".  For a discussion of this
>> change, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=522776
>>
>> The below patch allows to specify the "C." prefix alongside of ther "C-"
>> prefix.  That allows to stick to a language neutral setting in all
>> other respects, while switching to a charset of choice.
>>
>> Patch below, tested on Cygwin.
>>
>> Ok to apply?
>>
>>
>> Thanks,
>> Corinna
>>
>>
>> 	* libc/locale/locale.c (loadlocale): Allow "C." same as "C-"
>> 	as locale prefix.  Add some words to documentation.
>>
>>
>> Index: libc/locale/locale.c
>> ===================================================================
>> RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v
>> retrieving revision 1.25
>> diff -u -p -r1.25 locale.c
>> --- libc/locale/locale.c	25 Aug 2009 18:47:24 -0000	1.25
>> +++ libc/locale/locale.c	23 Sep 2009 09:38:12 -0000
>> @@ -61,6 +61,11 @@ backward compatibility with older implem
>>   xxx in [437, 720, 737, 775, 850, 852, 855, 857, 858, 862, 866, 874, 1125,
>>   1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258].
>>
>> +Instead of<<"C-">>, you can specify also<<"C.">>.  Both variations allow
>> +to specify language neutral locales while using other charsets than ASCII,
>> +for instance<<"C.UTF-8">>, which keeps all settings as in the C locale,
>> +but uses the UTF-8 charset.
>> +
>>   Even when using POSIX locale strings, the only charsets allowed are
>>   <<"UTF-8">>,<<"JIS">>,<<"EUCJP">>,<<"SJIS">>,<<KOI8-R>>,<<KOI8-U>>,
>>   <<"ISO-8859-x">>  with 1<= x<= 15, or<<"CPxxx">>  with xxx in
>> @@ -432,8 +437,14 @@ loadlocale(struct _reent *p, int categor
>>       strcpy (locale, "C");
>>     if (!strcmp (locale, "C"))				/* Default "C" locale */
>>       strcpy (charset, "ASCII");
>> -  else if (locale[0] == 'C'&&  locale[1] == '-')	/* Old newlib style */
>> -	strcpy (charset, locale + 2);
>> +  else if (locale[0] == 'C'
>> +	&&  (locale[1] == '-'		/* Old newlib style */
>> +	       || locale[1] == '.'))	/* Extension for the C locale to allow
>> +					   specifying different charsets while
>> +					   sticking to the C locale in terms
>> +					   of sort order, etc.  Proposed in
>> +					   the Debian project. */
>> +    strcpy (charset, locale + 2);
>>     else							/* POSIX style */
>>       {
>>         char *c = locale;
>>
>> --
>> Corinna Vinschen
>> Cygwin Project Co-Leader
>> Red Hat
>

Ok.

-- Jeff J.



More information about the Newlib mailing list