[patch/ob]: setlocale: Allow language per ISO 639-2
Corinna Vinschen
vinschen@redhat.com
Sun Jan 17 14:42:00 GMT 2010
Hi,
I applied the below patch as obvious. Some languages didn't fit
into the original ISO 639 two character language code, so the standard
has been extended to allow three character codes as well. These are
used, for instamce, on Linux and Windows for a couple of languages.
The below patch just adds two lines to loadlocale() which allow to
specify three character language codes as well.
Of course this is still just fake, but I'm working on extending the
loadlocale() function for Cygwin to allow only languages and territories
which are actually supported on Windows, and subsequently fetch
LC_COLLATE, LC_MONETARY, LC_NUMERIC, and LC_TIME information from
Windows.
Corinna
* libc/locale/locale.c (loadlocale): Allow three character
language codes to accommodate ISO 639-2 codes.
Index: libc/locale/locale.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v
retrieving revision 1.30
diff -u -p -r1.30 locale.c
--- libc/locale/locale.c 17 Jan 2010 09:39:06 -0000 1.30
+++ libc/locale/locale.c 17 Jan 2010 14:40:19 -0000
@@ -51,8 +51,10 @@ the form
language[_TERRITORY][.charset][@@modifier]
-<<"language">> is a two character string per ISO 639. <<"TERRITORY">> is a
-country code per ISO 3166. For <<"charset">> and <<"modifier">> see below.
+<<"language">> is a two character string per ISO 639, or, if not available
+for a given language, a three character string per ISO 639-2.
+<<"TERRITORY">> is a country code per ISO 3166. For <<"charset">> and
+<<"modifier">> see below.
Additionally to the POSIX specifier, seven extensions are supported for
backward compatibility with older implementations using newlib:
@@ -473,6 +475,9 @@ loadlocale(struct _reent *p, int categor
|| c[1] < 'a' || c[1] > 'z')
return NULL;
c += 2;
+ /* Allow three character Language per ISO 639-2 */
+ if (c[0] >= 'a' && c[0] <= 'z')
+ ++c;
if (c[0] == '_')
{
/* Territory */
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the Newlib
mailing list