[haiku-commits] r37355 - in haiku/branches/developer/zooey/posix-locale: headers/private/libroot/locale src/system/libroot/posix/locale

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 2 Jul 2010 20:42:34 +0200 (CEST)

Author: zooey
Date: 2010-07-02 20:42:34 +0200 (Fri, 02 Jul 2010)
New Revision: 37355
Changeset: http://dev.haiku-os.org/changeset/37355/haiku

Modified:
   
haiku/branches/developer/zooey/posix-locale/headers/private/libroot/locale/LocaleBackend.h
   
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp
   
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp
Log:
* added support for passing POSIX-specific data containers into LocaleBackend
  via LocaleDataBridge.


Modified: 
haiku/branches/developer/zooey/posix-locale/headers/private/libroot/locale/LocaleBackend.h
===================================================================
--- 
haiku/branches/developer/zooey/posix-locale/headers/private/libroot/locale/LocaleBackend.h
  2010-07-02 18:40:44 UTC (rev 37354)
+++ 
haiku/branches/developer/zooey/posix-locale/headers/private/libroot/locale/LocaleBackend.h
  2010-07-02 18:42:34 UTC (rev 37355)
@@ -16,6 +16,18 @@
 namespace BPrivate {
 
 
+struct LocaleCtypeDataBridge {
+       unsigned short int* classInfo;
+       int* toLowerTable;
+       int* toUpperTable;
+};
+
+
+struct LocaleDataBridge {
+       LocaleCtypeDataBridge ctypeDataBridge;
+};
+
+
 class LocaleBackend {
 public:
                                                                LocaleBackend();
@@ -25,7 +37,12 @@
        virtual const struct lconv*     LocaleConv() = 0;
        virtual const struct lc_time_t* LCTimeInfo() = 0;
 
-       static  status_t                        LoadBackend();
+                       void                            
SetDataBridge(LocaleDataBridge& dataBridge);
+                       LocaleDataBridge&       DataBridge();
+
+       static  status_t                        LoadBackend(LocaleDataBridge& 
dataBridge);
+private:
+                       LocaleDataBridge        fDataBridge;
 };
 
 

Modified: 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp
===================================================================
--- 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp
       2010-07-02 18:40:44 UTC (rev 37354)
+++ 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp
       2010-07-02 18:42:34 UTC (rev 37355)
@@ -46,11 +46,28 @@
 }
 
 
+void
+LocaleBackend::SetDataBridge(LocaleDataBridge& dataBridge)
+{
+       fDataBridge = dataBridge;
+}
+
+
+LocaleDataBridge&
+LocaleBackend::DataBridge()
+{
+       return fDataBridge;
+}
+
+
 status_t
-LocaleBackend::LoadBackend()
+LocaleBackend::LoadBackend(LocaleDataBridge& dataBridge)
 {
-       if (gLocaleBackend == NULL)
+       if (gLocaleBackend == NULL) {
                pthread_once(&sBackendInitOnce, &BPrivate::LoadBackend);
+               if (gLocaleBackend != NULL)
+                       gLocaleBackend->SetDataBridge(dataBridge);
+       }
 
        return gLocaleBackend != NULL ? B_OK : B_ERROR;
 }

Modified: 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp
===================================================================
--- 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp
   2010-07-02 18:40:44 UTC (rev 37354)
+++ 
haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp
   2010-07-02 18:42:34 UTC (rev 37355)
@@ -5,6 +5,7 @@
  */
 
 
+#include <ctype.h>
 #include <locale.h>
 #include <stdlib.h>
 #include <string.h>
@@ -12,8 +13,24 @@
 #include "LocaleBackend.h"
 
 
+namespace BPrivate {
+
+
+static LocaleDataBridge sLocaleDataBridge = {
+       {
+               const_cast<unsigned short*>(__ctype_b),
+               const_cast<int*>(__ctype_tolower),
+               const_cast<int*>(__ctype_toupper)
+       }
+};
+
+
+}
+
+
 using BPrivate::gLocaleBackend;
 using BPrivate::LocaleBackend;
+using BPrivate::sLocaleDataBridge;
 
 
 static status_t
@@ -99,7 +116,8 @@
                                break;
                        }
                }
-               if (needBackend && LocaleBackend::LoadBackend() != B_OK)
+               if (needBackend
+                       && LocaleBackend::LoadBackend(sLocaleDataBridge) != 
B_OK)
                        return NULL;
        }
 


Other related posts:

  • » [haiku-commits] r37355 - in haiku/branches/developer/zooey/posix-locale: headers/private/libroot/locale src/system/libroot/posix/locale - zooey