]> pd.if.org Git - pdclib/commitdiff
PDCLIB-1 PDCLIB-2 PDCLIB-9 PDCLIB-12: Add thread specific locale support; migrate...
authorOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 19:20:06 +0000 (19:20 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 19:20:06 +0000 (19:20 +0000)
28 files changed:
functions/ctype/isalnum.c
functions/ctype/isalpha.c
functions/ctype/isblank.c
functions/ctype/iscntrl.c
functions/ctype/isdigit.c
functions/ctype/isgraph.c
functions/ctype/islower.c
functions/ctype/isprint.c
functions/ctype/ispunct.c
functions/ctype/isspace.c
functions/ctype/isupper.c
functions/ctype/isxdigit.c
functions/ctype/tolower.c
functions/ctype/toupper.c
functions/locale/localeconv.c
functions/stdio/perror.c
functions/string/strcoll.c
functions/string/strerror.c
functions/string/strxfrm.c
includes/locale.h
internals/_PDCLIB_int.h
internals/_PDCLIB_locale.h
opt/basecodecs/_PDCLIB_ascii.c
opt/basecodecs/_PDCLIB_latin1.c
opt/basecodecs/_PDCLIB_utf8.c
platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c
platform/posix/internals/_PDCLIB_config.h
platform/win32/internals/_PDCLIB_config.h

index f4969fa20a48446a6d3181f66e770bbee2ea8a5e..bbb01d50a7b0019c33c4e498e2c300f99ba273f0 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isalnum( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & ( _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT ) );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & ( _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT ) );
 }
 
 #endif
index 9dad397ea44798a7788932a6ec1a73ee60e56b8a..147fd5eb14e82b4ab59f991dcdacb5d6b2f897f6 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isalpha( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_ALPHA );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_ALPHA );
 }
 
 #endif
index cc29fa849048df2b19588b797efc92bc60e6b6bb..fe2a51b21ffd49879728d7b27ef6be05f3df0905 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isblank( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_BLANK );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_BLANK );
 }
 
 #endif
index 8c0a4f3164ef6a536d86802b6fae841e9b567e62..ebb1f47be7f65208098097a0755e299e108c1221 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int iscntrl( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_CNTRL );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_CNTRL );
 }
 
 #endif
index b122f7ec5362434c48f80f44dac763da93a2ed23..36be03728f961d400316e2591faf8bcc8509a809 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isdigit( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_DIGIT );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_DIGIT );
 }
 
 #endif
index d623485f02f6ee34b2372b4bd634aff68fd04a12..133a39cba5e822db199d46d0a6b13cc376c6439f 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isgraph( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_GRAPH );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_GRAPH );
 }
 
 #endif
index db0649d1f0f28b754c78278adab855c8c48fec1d..689e65fb168b191c6cbc63627793c357fd60ee83 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int islower( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_LOWER );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_LOWER );
 }
 
 #endif
index 50b0ad85192d34530056a4d17ff81626e7c296ff..6a5366adaa355959af7c4fd2ee0efa93b55abfa5 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isprint( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_GRAPH ) || ( c == ' ' );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_GRAPH ) || ( c == ' ' );
 }
 
 #endif
index 4dfd52a7c749191d8fe339453829f0e1cab0d921..6c067889f5350394a80650a0e2288fc27102f457 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int ispunct( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_PUNCT );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_PUNCT );
 }
 
 #endif
index b443f6fc4acb7ff355982e3743454b042166941a..097a5209c50faa4b5b27b5c9a24708ef9a68e2b4 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isspace( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_SPACE );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_SPACE );
 }
 
 #endif
index 59539469d7c90601639c2d294fcd891b32ab892c..9d45a746b3415192ddcb0f7fcb49128cfc57c3a7 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isupper( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_UPPER );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_UPPER );
 }
 
 #endif
index 7f5dfec4d97e4c05a90f99f52138ee471613bd21..e0b0f60b2ffafa2f0e219197ba1c8441d19b9c61 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int isxdigit( int c )
 {
-    return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_XDIGT );
+    return ( _PDCLIB_threadlocale()->_CType[c].flags & _PDCLIB_CTYPE_XDIGT );
 }
 
 #endif
index d051ba5c67e7ce257c3409f58ede8785b1d77644..a77001ef8e687fdbbddd10209e8d9fc94f9b1690 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int tolower( int c )
 {
-    return _PDCLIB_lconv.ctype[c].lower;
+    return _PDCLIB_threadlocale()->_CType[c].lower;
 }
 
 #endif
index 801c8ef55b18321cc5773b2d42bda2ff2561a2f2..2972b51b754550c1b1cd8859df3bf152584671e8 100644 (file)
@@ -9,12 +9,11 @@
 #include <ctype.h>
 
 #ifndef REGTEST
-
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int toupper( int c )
 {
-    return _PDCLIB_lconv.ctype[c].upper;
+    return _PDCLIB_threadlocale()->_CType[c].upper;
 }
 
 #endif
index e23fb6a3585d7f6f21398aa18a077d7f7a0dc267..5b49571ec5ae86f26f37c54548fce0c7da088757 100644 (file)
@@ -1,18 +1,16 @@
-/* $Id$ */
-
 /* localeconv( void )
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 #ifndef REGTEST
 
 struct lconv * localeconv( void )
 {
-    return &_PDCLIB_lconv;
+    return &_PDCLIB_threadlocale()->_Conv;
 }
 
 #endif
index 5a794fbaa5a22611c30a60923b97333f4c5b0c1b..9fe694825a632fbaedab7e7d11915ac8aa157654 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifndef REGTEST
 #include <errno.h>
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 /* TODO: Doing this via a static array is not the way to do it. */
 void perror( const char * s )
@@ -25,7 +25,7 @@ void perror( const char * s )
     }
     else
     {
-        fprintf( stderr, "%s\n", _PDCLIB_lconv._PDCLIB_errno_texts[errno] );
+        fprintf( stderr, "%s\n", _PDCLIB_threadlocale()->_ErrnoStr[errno] );
     }
     return;
 }
index 16a5680b610c14ea5aaf078f60ced375095753b8..b6a4cd6d242aa0e195d93e221816162f4c2d73bb 100644 (file)
 
 #ifndef REGTEST
 
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 int strcoll( const char * s1, const char * s2 )
 {
-    while ( ( *s1 ) && ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation ) )
+    _PDCLIB_ctype_t * ctype = _PDCLIB_threadlocale()->_CType;
+
+    while ( ( *s1 ) && ( ctype[(unsigned char)*s1].collation == ctype[(unsigned char)*s2].collation ) )
     {
         ++s1;
         ++s2;
     }
-    return ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation );
+    return ( ctype[(unsigned char)*s1].collation == ctype[(unsigned char)*s2].collation );
 }
 
 #endif
index b0ced5dba5d308ba904276973f32c53575004009..e050394b21778dcb12d7c221dc6b8e2383d0943c 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifndef REGTEST
 
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 /* TODO: Doing this via a static array is not the way to do it. */
 char * strerror( int errnum )
@@ -21,7 +21,7 @@ char * strerror( int errnum )
     }
     else
     {
-        return _PDCLIB_lconv._PDCLIB_errno_texts[errnum];
+        return _PDCLIB_threadlocale()->_ErrnoStr[errnum];
     }
 }
 
index 4f5e4a099bb1902f502b26dce62faa77ef1dce97..3ea8d0fab6259c0f8c983eb4548a7d005fe037c9 100644 (file)
 
 #ifndef REGTEST
 
-#include <locale.h>
+#include <_PDCLIB_locale.h>
 
 size_t strxfrm( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, size_t n )
 {
+    _PDCLIB_ctype_t *ctype = _PDCLIB_threadlocale()->_CType;
     size_t len = strlen( s2 );
     if ( len < n )
     {
         /* Cannot use strncpy() here as the filling of s1 with '\0' is not part
            of the spec.
         */
-        while ( n-- && ( *s1++ = _PDCLIB_lconv.ctype[(unsigned char)*s2++].collation ) );
+        while ( n-- && ( *s1++ = ctype[(unsigned char)*s2++].collation ) );
     }
     return len;
 }
index 21221e33e64df11f71a6eff1d767814d8fcc53d8..1fb04e7d01f7d71798ca36f074ce0090c0da90ae 100644 (file)
@@ -34,8 +34,6 @@ _PDCLIB_BEGIN_EXTERN_C
 */
 struct lconv
 {
-    struct _PDCLIB_ctype_t * ctype;  /* internal <ctype.h> information        */
-    char * _PDCLIB_errno_texts[_PDCLIB_ERRNO_MAX]; /* strerror() / perror()   */
     char * decimal_point;      /* decimal point character                     */
     char * thousands_sep;      /* character for seperating groups of digits   */
     char * grouping;           /* string indicating the size of digit groups  */
@@ -62,9 +60,6 @@ struct lconv
     char int_n_sign_posn;      /* Same as above, for international format     */
 };
 
-/* This is strictly internal, and visible here for technical reasons only. */
-extern struct lconv _PDCLIB_lconv;
-
 /* First arguments to setlocale().
    TODO: Beware, values might change before v0.6 is released.
 */
@@ -98,8 +93,14 @@ char * setlocale( int category, const char * locale ) _PDCLIB_nothrow;
 struct lconv * localeconv( void ) _PDCLIB_nothrow;
 
 #if _PDCLIB_POSIX_MIN(2008)
+
+/* POSIX locale type */
 typedef _PDCLIB_locale_t locale_t;
 
+/* Global locale */
+extern struct _PDCLIB_locale _PDCLIB_global_locale;
+#define LC_GLOBAL_LOCALE (&_PDCLIB_global_locale)
+
 /* Set the thread locale to newlocale
  *
  * If newlocale is (locale_t)0, then doesn't change the locale and just returns
index 315a0e363b44b38bffc2dc4bd97840db55df05a4..c9988a9d7c2d67e045b2b705702f82a1ac696ee2 100644 (file)
@@ -325,29 +325,6 @@ extern int _PDCLIB_errno;
 */
 int * _PDCLIB_errno_func( void ) _PDCLIB_nothrow;
 
-/* -------------------------------------------------------------------------- */
-/* <ctype.h> lookup tables                                                    */
-/* -------------------------------------------------------------------------- */
-
-#define _PDCLIB_CTYPE_ALPHA   1
-#define _PDCLIB_CTYPE_BLANK   2
-#define _PDCLIB_CTYPE_CNTRL   4
-#define _PDCLIB_CTYPE_GRAPH   8
-#define _PDCLIB_CTYPE_PUNCT  16
-#define _PDCLIB_CTYPE_SPACE  32
-#define _PDCLIB_CTYPE_LOWER  64
-#define _PDCLIB_CTYPE_UPPER 128
-#define _PDCLIB_CTYPE_DIGIT 256
-#define _PDCLIB_CTYPE_XDIGT 512
-
-struct _PDCLIB_ctype_t
-{
-    _PDCLIB_uint16_t flags;
-    unsigned char upper;
-    unsigned char lower;
-    unsigned char collation;
-};
-
 /* -------------------------------------------------------------------------- */
 /* locale / wchar / uchar                                                     */
 /* -------------------------------------------------------------------------- */
@@ -383,7 +360,7 @@ typedef struct _PDCLIB_mbstate {
     };
 } _PDCLIB_mbstate_t;
 
-typedef struct _PDCLIB_charcodec  _PDCLIB_charcodec_t;
+typedef struct _PDCLIB_charcodec *_PDCLIB_charcodec_t;
 typedef struct _PDCLIB_locale    *_PDCLIB_locale_t;
 typedef struct lconv              _PDCLIB_lconv_t;
 
index bed89b561a39903a0ea335b1be7401359d87d5d4..e99d9ca1ac85710cf51ce8576ba8d65972708c91 100644 (file)
@@ -1,12 +1,81 @@
 #ifndef __PDCLIB_LOCALE_H
 #define __PDCLIB_LOCALE_H __PDCLIB_LOCALE_H
+#include <_PDCLIB_int.h>
 #include <locale.h>
+#include <threads.h>
+#include <stdlib.h>
 
-#define _PDCLIB_threadlocale() (uselocale(NULL))
+#define _PDCLIB_LOCALE_METHOD_TSS           't'
+#define _PDCLIB_LOCALE_METHOD_THREAD_LOCAL  'T'
+
+#if !defined(_PDCLIB_LOCALE_METHOD)
+    #error _PDCLIB_LOCALE_METHOD undefined: don't know where I'm storing the thread locale
+#elif _PDCLIB_LOCALE_METHOD == _PDCLIB_LOCALE_METHOD_TSS
+    extern tss_t _PDCLIB_locale_tss;
+    static inline locale_t _PDCLIB_threadlocale( void )
+    {
+        locale_t l = tss_get(_PDCLIB_locale_tss);
+        if(l == NULL)
+            l = &_PDCLIB_global_locale;
+        return l;
+    }
+
+    static inline void _PDCLIB_setthreadlocale( locale_t l )
+    {
+        if(tss_set(_PDCLIB_locale_tss, l) != thrd_success)
+            abort();
+    }
+#elif _PDCLIB_LOCALE_METHOD == _PDCLIB_LOCALE_METHOD_THREAD_LOCAL
+    extern thread_local locale_t _PDCLIB_locale_tls;
+    #define _PDCLIB_threadlocale() (_PDCLIB_locale_tls || &_PDCLIB_global_locale)
+    static inline locale_t _PDCLIB_threadlocale( void )
+    {
+        locale_t l = _PDCLIB_locale_tls;
+        if(l == NULL)
+            l = &_PDCLIB_global_locale;
+        return l;
+    }
+
+    static inline void _PDCLIB_setthreadlocale( locale_t l )
+    {
+        _PDCLIB_locale_tls = l;
+    }
+#else
+    #error Locale TSS method unspecified
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* <ctype.h> lookup tables                                                    */
+/* -------------------------------------------------------------------------- */
+
+#define _PDCLIB_CTYPE_ALPHA   1
+#define _PDCLIB_CTYPE_BLANK   2
+#define _PDCLIB_CTYPE_CNTRL   4
+#define _PDCLIB_CTYPE_GRAPH   8
+#define _PDCLIB_CTYPE_PUNCT  16
+#define _PDCLIB_CTYPE_SPACE  32
+#define _PDCLIB_CTYPE_LOWER  64
+#define _PDCLIB_CTYPE_UPPER 128
+#define _PDCLIB_CTYPE_DIGIT 256
+#define _PDCLIB_CTYPE_XDIGT 512
+
+typedef struct _PDCLIB_ctype
+{
+    _PDCLIB_uint16_t flags;
+    unsigned char upper;
+    unsigned char lower;
+    unsigned char collation;
+} _PDCLIB_ctype_t;
 
 struct _PDCLIB_locale {
-    struct _PDCLIB_charcodec    *_Codec;
+    _PDCLIB_charcodec_t          _Codec;
     struct lconv                 _Conv;
+
+    /* ctype */
+    _PDCLIB_ctype_t             *_CType; 
+
+    /* perror/strerror */
+    char                        *_ErrnoStr[_PDCLIB_ERRNO_MAX];
 };
 
 #endif
index d178a54575e90b236618510c922e8be199daad50..86001aff538f2423b58b6c3bb4e9dd90629f55eb 100644 (file)
@@ -59,7 +59,7 @@ static bool c32toascii(
     return true;
 }
 
-_PDCLIB_charcodec_t _PDCLIB_ascii_codec = {
+struct _PDCLIB_charcodec _PDCLIB_ascii_codec = {
     .__mbstoc32s = asciitoc32,
     .__c32stombs = c32toascii,
 };
index cec13a017e88ef00b3540636e8a0d4fac5da19d9..b397001303921c93f99854aa9ed02da5128e40db 100644 (file)
@@ -57,7 +57,7 @@ static bool c32tolatin1(
     return true;
 }
 
-_PDCLIB_charcodec_t _PDCLIB_latin1_codec = {
+struct _PDCLIB_charcodec _PDCLIB_latin1_codec = {
     .__mbstoc32s = latin1toc32,
     .__c32stombs = c32tolatin1,
 };
index b0d3413e696d7489f3d6b5b2f7f6968a3f8da240..2b3f4f6c5fe42465df0f4c6e3cda8cc5568a346c 100644 (file)
@@ -228,7 +228,7 @@ static bool c32toutf8(
     END_CONVERSION;
 }
 
-_PDCLIB_charcodec_t _PDCLIB_utf8_codec = {
+struct _PDCLIB_charcodec _PDCLIB_utf8_codec = {
     .__mbstoc32s = utf8toc32,
     .__c32stombs = c32toutf8,
 };
index 4c4ba4af8cf1465f45f6ea420e6c41f9e162c866..3f479f53889860e466e359f368e33171f53b5db1 100644 (file)
@@ -17,6 +17,7 @@
 
 #ifndef REGTEST
 #include <_PDCLIB_io.h>
+#include <_PDCLIB_locale.h>
 #include <threads.h>
 
 /* In a POSIX system, stdin / stdout / stderr are equivalent to the (int) file
@@ -77,9 +78,11 @@ FILE * stdin  = &_PDCLIB_sin;
 FILE * stdout = &_PDCLIB_sout;
 FILE * stderr = &_PDCLIB_serr;
 
+tss_t _PDCLIB_locale_tss;
 /* Todo: Better solution than this! */
 __attribute__((constructor)) void init_stdio(void)
 {
+    tss_create(&_PDCLIB_locale_tss, (tss_dtor_t) freelocale);
     mtx_init(&stdin->lock,  mtx_recursive);
     mtx_init(&stdout->lock, mtx_recursive);
     mtx_init(&stderr->lock, mtx_recursive);
@@ -92,7 +95,8 @@ FILE * _PDCLIB_filelist = &_PDCLIB_sin;
    1 kByte (+ 4 byte) of <ctype.h> data.
    Each line: flags, lowercase, uppercase, collation.
 */
-static struct _PDCLIB_ctype_t _ctype[] = {
+static 
+_PDCLIB_ctype_t global_ctype[] = {
     { /* EOF */    0,    0,    0,    0 },
     { /* NUL */ _PDCLIB_CTYPE_CNTRL,                                             0x00, 0x00, 0x00 },
     { /* SOH */ _PDCLIB_CTYPE_CNTRL,                                             0x01, 0x01, 0x01 },
@@ -352,15 +356,7 @@ static struct _PDCLIB_ctype_t _ctype[] = {
     { 0x00, 0xFF, 0xFF, 0xFF }
 };
 
-struct lconv _PDCLIB_lconv = { 
-    /* _PDCLIB_ctype      */ _ctype + 1,
-    /* _PDCLIB_errno_texts */
-    {
-        /* no error */ (char *)"",
-        /* ERANGE   */ (char *)"ERANGE (Range error)",
-        /* EDOM     */ (char *)"EDOM (Domain error)",
-        /* EILSEQ   */ (char *)"EILSEQ (Illegal sequence)"
-    },
+static struct lconv global_lconv = { 
     /* decimal_point      */ (char *)".",
     /* thousands_sep      */ (char *)"",
     /* grouping           */ (char *)"",
@@ -387,6 +383,20 @@ struct lconv _PDCLIB_lconv = {
     /* int_n_sign_posn    */ CHAR_MAX,
 };
 
+extern struct _PDCLIB_charcodec _PDCLIB_ascii_codec;
+struct _PDCLIB_locale _PDCLIB_global_locale 
+= {
+    ._Codec = &_PDCLIB_ascii_codec,
+    ._Conv  = &global_lconv,
+    ._CType = &global_ctype[1],
+    ._ErrnoStr = {
+        /* no error */ (char *)"",
+        /* ERANGE   */ (char *)"ERANGE (Range error)",
+        /* EDOM     */ (char *)"EDOM (Domain error)",
+        /* EILSEQ   */ (char *)"EILSEQ (Illegal sequence)"
+    },
+};
+
 #endif
 
 #ifdef TEST
index 099e970fda5d7240f23ad88cf0446a3caefddd0b..273f2d2f5997f55382880556406fa8a791bed0a3 100644 (file)
@@ -322,6 +322,11 @@ struct _PDCLIB_imaxdiv_t
 
 /* TODO: Better document these */
 
+/* Locale --------------------------------------------------------------------*/
+
+/* Locale method. See _PDCLIB_locale.h */
+#define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS
+
 /* I/O ---------------------------------------------------------------------- */
 
 /* The default size for file buffers. Must be at least 256. */
index 5e91db53d04cd8f1df57500a186ef591d6773cfa..4e4050153f399e7dc7e5bd623ce26d0d06613bb9 100644 (file)
@@ -333,6 +333,11 @@ struct _PDCLIB_imaxdiv_t
 
 /* TODO: Better document these */
 
+/* Locale --------------------------------------------------------------------*/
+
+/* Locale method. See _PDCLIB_locale.h */
+#define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS
+
 /* I/O ---------------------------------------------------------------------- */
 
 /* The default size for file buffers. Must be at least 256. */