Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-11-24 07:25:26


Author: johnmaddock
Date: 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
New Revision: 41327
URL: http://svn.boost.org/trac/boost/changeset/41327

Log:
Apply patches for building regex on WinCE see: http://lists.boost.org/Archives/boost/2007/11/130839.php
Text files modified:
   trunk/boost/config/compiler/visualc.hpp | 3
   trunk/boost/regex/v4/fileiter.hpp | 4
   trunk/libs/regex/example/timer/regex_timer.cpp | 18 +-
   trunk/libs/regex/src/cregex.cpp | 2
   trunk/libs/regex/src/fileiter.cpp | 71 +++++++++++++--
   trunk/libs/regex/src/posix_api.cpp | 4
   trunk/libs/regex/src/w32_regex_traits.cpp | 181 +++++++++++++++++++++++++++++++++++++++
   trunk/libs/regex/src/wide_posix_api.cpp | 10 +-
   trunk/libs/regex/test/c_compiler_checks/posix_api_check.c | 14 +-
   trunk/libs/regex/test/c_compiler_checks/posix_api_check.cpp | 14 +-
   trunk/libs/regex/test/regress/test_locale.cpp | 44 +++++++++
   11 files changed, 321 insertions(+), 44 deletions(-)

Modified: trunk/boost/config/compiler/visualc.hpp
==============================================================================
--- trunk/boost/config/compiler/visualc.hpp (original)
+++ trunk/boost/config/compiler/visualc.hpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -82,9 +82,10 @@
 # define BOOST_NO_INTRINSIC_WCHAR_T
 #endif
 
-#ifdef _WIN32_WCE
+#if defined(_WIN32_WCE) || defined(UNDER_CE)
 # define BOOST_NO_THREADEX
 # define BOOST_NO_GETSYSTEMTIMEASFILETIME
+# define BOOST_NO_SWPRINTF
 #endif
 
 //

Modified: trunk/boost/regex/v4/fileiter.hpp
==============================================================================
--- trunk/boost/regex/v4/fileiter.hpp (original)
+++ trunk/boost/regex/v4/fileiter.hpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -51,7 +51,11 @@
 namespace boost{
    namespace re_detail{
 
+#ifndef BOOST_NO_ANSI_APIS
 typedef WIN32_FIND_DATAA _fi_find_data;
+#else
+typedef WIN32_FIND_DATAW _fi_find_data;
+#endif
 typedef HANDLE _fi_find_handle;
 
    } // namespace re_detail

Modified: trunk/libs/regex/example/timer/regex_timer.cpp
==============================================================================
--- trunk/libs/regex/example/timer/regex_timer.cpp (original)
+++ trunk/libs/regex/example/timer/regex_timer.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -143,7 +143,7 @@
    boost::match_results<std::deque<char>::iterator> dm;
    std::string s1, s2, ts;
    std::deque<char> ds;
- boost::regex_t r;
+ boost::regex_tA r;
    boost::scoped_array<boost::regmatch_t> matches;
    std::size_t nsubs;
    boost::timer t;
@@ -175,12 +175,12 @@
          cout << "Error in expression: \"" << e.what() << "\"" << endl;
          continue;
       }
- int code = regcomp(&r, s1.c_str(), boost::REG_PERL);
+ int code = regcompA(&r, s1.c_str(), boost::REG_PERL);
       if(code != 0)
       {
          char buf[256];
- regerror(code, &r, buf, 256);
- cout << "regcomp error: \"" << buf << "\"" << endl;
+ regerrorA(code, &r, buf, 256);
+ cout << "regcompA error: \"" << buf << "\"" << endl;
          continue;
       }
       nsubs = r.re_nsub + 1;
@@ -324,17 +324,17 @@
          iters = 10;
          tim = 1.1;
          // cache load:
- regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
+ regex_tA(&r, s2.c_str(), nsubs, matches.get(), 0);
          do{
             iters *= (tim > 0.001) ? (1.1/tim) : 100;
             t.restart();
             for(i = 0; i < iters; ++i)
             {
- result = regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
+ result = regex_tA(&r, s2.c_str(), nsubs, matches.get(), 0);
             }
             tim = t.elapsed();
          }while(tim < wait_time);
- cout << "POSIX regexec time: " << (tim * 1000000 / iters) << "us" << endl;
+ cout << "POSIX regex_tA time: " << (tim * 1000000 / iters) << "us" << endl;
 
          if(result == 0)
          {
@@ -360,7 +360,7 @@
             cout << "\" (matched=" << (matches[0].rm_eo != s2.size()) << ")" << endl << endl;
          }
       }
- regfree(&r);
+ regfreeA(&r);
    }
 
    if(pbuf)
@@ -372,7 +372,7 @@
    return 0;
 }
 
-#if defined(_WIN32) && defined(BOOST_REGEX_USE_WIN32_LOCALE)
+#if defined(_WIN32) && defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(UNDER_CE)
 #pragma comment(lib, "user32.lib")
 #endif
 

Modified: trunk/libs/regex/src/cregex.cpp
==============================================================================
--- trunk/libs/regex/src/cregex.cpp (original)
+++ trunk/libs/regex/src/cregex.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -354,7 +354,7 @@
 
       while(dstart != dend)
       {
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
          (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
 #else
          (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);

Modified: trunk/libs/regex/src/fileiter.cpp
==============================================================================
--- trunk/libs/regex/src/fileiter.cpp (original)
+++ trunk/libs/regex/src/fileiter.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -86,7 +86,14 @@
 
 void mapfile::open(const char* file)
 {
-#if defined(__CYGWIN__)||defined(__CYGWIN32__)
+#if defined(BOOST_NO_ANSI_APIS)
+ int filename_size = strlen(file);
+ LPWSTR wide_file = (LPWSTR)_alloca( (filename_size + 1) * sizeof(WCHAR) );
+ if(::MultiByteToWideChar(CP_ACP, 0, file, filename_size, wide_file, filename_size + 1) == 0)
+ hfile = INVALID_HANDLE_VALUE;
+ else
+ hfile = CreateFileW(wide_file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+#elif defined(__CYGWIN__)||defined(__CYGWIN32__)
    char win32file[ MAX_PATH ];
    cygwin_conv_to_win32_path( file, win32file );
    hfile = CreateFileA(win32file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
@@ -350,6 +357,48 @@
 
 #endif
 
+inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data)
+{
+#ifdef BOOST_NO_ANSI_APIS
+ std::size_t wild_size = std::strlen(wild);
+ LPWSTR wide_wild = (LPWSTR)_alloca( (wild_size + 1) * sizeof(WCHAR) );
+ if (::MultiByteToWideChar(CP_ACP, 0, wild, wild_size, wide_wild, wild_size + 1) == 0)
+ return _fi_invalid_handle;
+
+ return FindFirstFileW(wide_wild, &data);
+#else
+ return FindFirstFileA(wild, &data);
+#endif
+}
+
+inline bool find_next_file(_fi_find_handle hf, _fi_find_data& data)
+{
+#ifdef BOOST_NO_ANSI_APIS
+ return FindNextFileW(hf, &data);
+#else
+ return FindNextFileA(hf, &data);
+#endif
+}
+
+inline void copy_find_file_result_with_overflow_check(const _fi_find_data& data, char* path, size_t max_size)
+{
+#ifdef BOOST_NO_ANSI_APIS
+ if (::WideCharToMultiByte(CP_ACP, 0, data.cFileName, -1, path, max_size, NULL, NULL) == 0)
+ re_detail::overflow_error_if_not_zero(1);
+#else
+ re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(path, max_size, data.cFileName));
+#endif
+}
+
+inline bool is_not_current_or_parent_path_string(const _fi_find_data& data)
+{
+#ifdef BOOST_NO_ANSI_APIS
+ return (std::wcscmp(data.cFileName, L".") && std::wcscmp(data.cFileName, L".."));
+#else
+ return (std::strcmp(data.cFileName, ".") && std::strcmp(data.cFileName, ".."));
+#endif
+}
+
 
 file_iterator::file_iterator()
 {
@@ -413,7 +462,7 @@
 
    ref = new file_iterator_ref();
    BOOST_REGEX_NOEH_ASSERT(ref)
- ref->hf = FindFirstFileA(wild, &(ref->_data));
+ ref->hf = find_first_file(wild, ref->_data);
    ref->count = 1;
 
    if(ref->hf == _fi_invalid_handle)
@@ -423,7 +472,7 @@
    }
    else
    {
- re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, (MAX_PATH - (ptr - _path)), ref->_data.cFileName));
+ copy_find_file_result_with_overflow_check(ref->_data, ptr, (MAX_PATH - (ptr - _path)));
       if(ref->_data.dwFileAttributes & _fi_dir)
          next();
    }
@@ -510,7 +559,7 @@
       bool cont = true;
       while(cont)
       {
- cont = FindNextFileA(ref->hf, &(ref->_data));
+ cont = find_next_file(ref->hf, ref->_data);
          if(cont && ((ref->_data.dwFileAttributes & _fi_dir) == 0))
             break;
       }
@@ -523,7 +572,7 @@
          ptr = _path;
       }
       else
- re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName));
+ copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
    }
 }
 
@@ -593,7 +642,7 @@
    ref = new file_iterator_ref();
    BOOST_REGEX_NOEH_ASSERT(ref)
    ref->count = 1;
- ref->hf = FindFirstFileA(wild, &(ref->_data));
+ ref->hf = find_first_file(wild, ref->_data);
    if(ref->hf == _fi_invalid_handle)
    {
       *_path = 0;
@@ -601,8 +650,8 @@
    }
    else
    {
- re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName));
- if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ref->_data.cFileName, ".") == 0) || (std::strcmp(ref->_data.cFileName, "..") == 0))
+ copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
+ if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ptr, ".") == 0) || (std::strcmp(ptr, "..") == 0))
          next();
    }
 #ifndef BOOST_NO_EXCEPTIONS
@@ -686,10 +735,10 @@
       bool cont = true;
       while(cont)
       {
- cont = FindNextFileA(ref->hf, &(ref->_data));
+ cont = find_next_file(ref->hf, ref->_data);
          if(cont && (ref->_data.dwFileAttributes & _fi_dir))
          {
- if(std::strcmp(ref->_data.cFileName, ".") && std::strcmp(ref->_data.cFileName, ".."))
+ if(is_not_current_or_parent_path_string(ref->_data))
                break;
          }
       }
@@ -702,7 +751,7 @@
          ptr = _path;
       }
       else
- re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName));
+ copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
    }
 }
 

Modified: trunk/libs/regex/src/posix_api.cpp
==============================================================================
--- trunk/libs/regex/src/posix_api.cpp (original)
+++ trunk/libs/regex/src/posix_api.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -164,7 +164,7 @@
       {
          if(std::strcmp(e->re_endp, names[i]) == 0)
          {
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
             (::sprintf_s)(localbuf, 5, "%d", i);
 #else
             (std::sprintf)(localbuf, "%d", i);
@@ -174,7 +174,7 @@
             return std::strlen(localbuf) + 1;
          }
       }
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
       (::sprintf_s)(localbuf, 5, "%d", 0);
 #else
       (std::sprintf)(localbuf, "%d", 0);

Modified: trunk/libs/regex/src/w32_regex_traits.cpp
==============================================================================
--- trunk/libs/regex/src/w32_regex_traits.cpp (original)
+++ trunk/libs/regex/src/w32_regex_traits.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -30,7 +30,7 @@
 #define NOGDI
 #include <windows.h>
 
-#if defined(_MSC_VER) && !defined(_WIN32_WCE)
+#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
 #pragma comment(lib, "user32.lib")
 #endif
 
@@ -42,6 +42,18 @@
 
 namespace boost{ namespace re_detail{
 
+#ifdef BOOST_NO_ANSI_APIS
+UINT get_code_page_for_locale_id(lcid_type id)
+{
+ WCHAR code_page_string[7];
+ if (::GetLocaleInfoW(id, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0)
+ return 0;
+
+ return static_cast<UINT>(_wtol(code_page_string));
+}
+#endif
+
+
 void w32_regex_traits_char_layer<char>::init()
 {
    // we need to start by initialising our syntax map so we know which
@@ -106,8 +118,24 @@
    char char_map[1 << CHAR_BIT];
    for(int ii = 0; ii < (1 << CHAR_BIT); ++ii)
       char_map[ii] = static_cast<char>(ii);
+#ifndef BOOST_NO_ANSI_APIS
    int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT);
    BOOST_ASSERT(r != 0);
+#else
+ UINT code_page = get_code_page_for_locale_id(this->m_locale);
+ BOOST_ASSERT(code_page != 0);
+
+ WCHAR wide_char_map[1 << CHAR_BIT];
+ int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT);
+ BOOST_ASSERT(conv_r != 0);
+
+ WCHAR wide_lower_map[1 << CHAR_BIT];
+ int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT);
+ BOOST_ASSERT(r != 0);
+
+ conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL);
+ BOOST_ASSERT(conv_r != 0);
+#endif
    if(r < (1 << CHAR_BIT))
    {
       // if we have multibyte characters then not all may have been given
@@ -115,7 +143,12 @@
       for(int jj = r; jj < (1 << CHAR_BIT); ++jj)
          this->m_lower_map[jj] = static_cast<char>(jj);
    }
+
+#ifndef BOOST_NO_ANSI_APIS
    r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map);
+#else
+ r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map);
+#endif
    BOOST_ASSERT(0 != r);
 }
 
@@ -126,18 +159,48 @@
 
 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id)
 {
+#ifndef BOOST_NO_ANSI_APIS
    WORD mask;
    if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
       return true;
    return false;
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if (code_page == 0)
+ return false;
+
+ WCHAR wide_c;
+ if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
+ return false;
+
+ WORD mask;
+ if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
+ return true;
+ return false;
+#endif
 }
 
 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type id)
 {
+#ifndef BOOST_NO_ANSI_APIS
    WORD mask;
    if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
       return true;
    return false;
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if (code_page == 0)
+ return false;
+
+ WCHAR wide_c;
+ if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
+ return false;
+
+ WORD mask;
+ if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
+ return true;
+ return false;
+#endif
 }
 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id)
@@ -183,12 +246,21 @@
 
 BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name)
 {
+#ifndef BOOST_NO_ANSI_APIS
    cat_type result(::LoadLibraryA(name.c_str()), &free_module);
    return result;
+#else
+ LPWSTR wide_name = (LPWSTR)_alloca( (name.size() + 1) * sizeof(WCHAR) );
+ if (::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.size(), wide_name, name.size() + 1) == 0)
+ return cat_type();
+
+ cat_type result(::LoadLibraryW(wide_name), &free_module);
+#endif
 }
 
 BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def)
 {
+#ifndef BOOST_NO_ANSI_APIS
    char buf[256];
    if(0 == ::LoadStringA(
       static_cast<HMODULE>(cat.get()),
@@ -199,6 +271,21 @@
    {
       return def;
    }
+#else
+ WCHAR wbuf[256];
+ int r = ::LoadStringW(
+ static_cast<HMODULE>(cat.get()),
+ i,
+ wbuf,
+ 256
+ );
+ if (r == 0)
+ return def;
+
+ LPSTR buf = (LPSTR)_alloca( (r + 1) * 2 );
+ if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, (r + 1) * 2, NULL, NULL) == 0)
+ return def;
+#endif
    return std::string(buf);
 }
 
@@ -236,6 +323,7 @@
 #endif
 BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2)
 {
+#ifndef BOOST_NO_ANSI_APIS
    int bytes = ::LCMapStringA(
       id, // locale identifier
       LCMAP_SORTKEY, // mapping transformation type
@@ -255,6 +343,36 @@
       &*result.begin(), // destination buffer
       bytes // size of destination buffer
       );
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if(code_page == 0)
+ return std::string(p1, p2);
+
+ int src_len = static_cast<int>(p2 - p1);
+ LPWSTR wide_p1 = (LPWSTR)_alloca( (src_len + 1) * 2 );
+ if(::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0)
+ return std::string(p1, p2);
+
+ int bytes = ::LCMapStringW(
+ id, // locale identifier
+ LCMAP_SORTKEY, // mapping transformation type
+ wide_p1, // source string
+ src_len, // number of characters in source string
+ 0, // destination buffer
+ 0 // size of destination buffer
+ );
+ if(!bytes)
+ return std::string(p1, p2);
+ std::string result(++bytes, '\0');
+ bytes = ::LCMapStringW(
+ id, // locale identifier
+ LCMAP_SORTKEY, // mapping transformation type
+ wide_p1, // source string
+ src_len, // number of characters in source string
+ (LPWSTR)&*result.begin(), // destination buffer
+ bytes // size of destination buffer
+ );
+#endif
    if(bytes > static_cast<int>(result.size()))
       return std::string(p1, p2);
    while(result.size() && result[result.size()-1] == '\0')
@@ -335,6 +453,7 @@
 BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id)
 {
    char result[2];
+#ifndef BOOST_NO_ANSI_APIS
    int b = ::LCMapStringA(
       id, // locale identifier
       LCMAP_LOWERCASE, // mapping transformation type
@@ -344,6 +463,29 @@
       1); // size of destination buffer
    if(b == 0)
       return c;
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if (code_page == 0)
+ return c;
+
+ WCHAR wide_c;
+ if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
+ return c;
+
+ WCHAR wide_result;
+ int b = ::LCMapStringW(
+ id, // locale identifier
+ LCMAP_LOWERCASE, // mapping transformation type
+ &wide_c, // source string
+ 1, // number of characters in source string
+ &wide_result, // destination buffer
+ 1); // size of destination buffer
+ if(b == 0)
+ return c;
+
+ if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
+ return c;
+#endif
    return result[0];
 }
 
@@ -382,6 +524,7 @@
 BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id)
 {
    char result[2];
+#ifndef BOOST_NO_ANSI_APIS
    int b = ::LCMapStringA(
       id, // locale identifier
       LCMAP_UPPERCASE, // mapping transformation type
@@ -391,6 +534,29 @@
       1); // size of destination buffer
    if(b == 0)
       return c;
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if(code_page == 0)
+ return c;
+
+ WCHAR wide_c;
+ if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
+ return c;
+
+ WCHAR wide_result;
+ int b = ::LCMapStringW(
+ id, // locale identifier
+ LCMAP_UPPERCASE, // mapping transformation type
+ &wide_c, // source string
+ 1, // number of characters in source string
+ &wide_result, // destination buffer
+ 1); // size of destination buffer
+ if(b == 0)
+ return c;
+
+ if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
+ return c;
+#endif
    return result[0];
 }
 
@@ -429,8 +595,21 @@
 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, char c)
 {
    WORD mask;
+#ifndef BOOST_NO_ANSI_APIS
    if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
       return true;
+#else
+ UINT code_page = get_code_page_for_locale_id(id);
+ if(code_page == 0)
+ return false;
+
+ WCHAR wide_c;
+ if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
+ return false;
+
+ if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
+ return true;
+#endif
    if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_'))
       return true;
    return false;

Modified: trunk/libs/regex/src/wide_posix_api.cpp
==============================================================================
--- trunk/libs/regex/src/wide_posix_api.cpp (original)
+++ trunk/libs/regex/src/wide_posix_api.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -157,7 +157,7 @@
       {
          result = std::wcslen(wnames[code]) + 1;
          if(buf_size >= result)
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
             ::wcscpy_s(buf, buf_size, wnames[code]);
 #else
             std::wcscpy(buf, wnames[code]);
@@ -176,13 +176,13 @@
       {
          if(std::wcscmp(e->re_endp, wnames[i]) == 0)
          {
-#if defined(_WIN32_WCE)
+#if defined(_WIN32_WCE) && !defined(UNDER_CE)
             (std::swprintf)(localbuf, L"%d", i);
 #else
             (std::swprintf)(localbuf, 5, L"%d", i);
 #endif
             if(std::wcslen(localbuf) < buf_size)
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
                ::wcscpy_s(buf, buf_size, localbuf);
 #else
                std::wcscpy(buf, localbuf);
@@ -190,13 +190,13 @@
             return std::wcslen(localbuf) + 1;
          }
       }
-#if defined(_WIN32_WCE)
+#if defined(_WIN32_WCE) && !defined(UNDER_CE)
       (std::swprintf)(localbuf, L"%d", 0);
 #else
       (std::swprintf)(localbuf, 5, L"%d", 0);
 #endif
       if(std::wcslen(localbuf) < buf_size)
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE)
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
          ::wcscpy_s(buf, buf_size, localbuf);
 #else
          std::wcscpy(buf, localbuf);

Modified: trunk/libs/regex/test/c_compiler_checks/posix_api_check.c
==============================================================================
--- trunk/libs/regex/test/c_compiler_checks/posix_api_check.c (original)
+++ trunk/libs/regex/test/c_compiler_checks/posix_api_check.c 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -32,30 +32,30 @@
 
 int main()
 {
- regex_t re;
+ regex_tA re;
    int result;
- result = regcomp(&re, expression, REG_AWK);
+ result = regcompA(&re, expression, REG_AWK);
    if(result > REG_NOERROR)
    {
       char buf[256];
- regerror(result, &re, buf, sizeof(buf));
+ regerrorA(result, &re, buf, sizeof(buf));
       printf(buf);
       return result;
    }
    assert(re.re_nsub == 0);
    matches[0].rm_so = 0;
    matches[0].rm_eo = strlen(text);
- result = regexec(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
+ result = regexecA(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
    if(result > REG_NOERROR)
    {
       char buf[256];
- regerror(result, &re, buf, sizeof(buf));
+ regerrorA(result, &re, buf, sizeof(buf));
       printf(buf);
- regfree(&re);
+ regfreeA(&re);
       return result;
    }
    assert(matches[0].rm_so == matches[0].rm_eo == 1);
- regfree(&re);
+ regfreeA(&re);
    printf("no errors found\n");
    return 0;
 }

Modified: trunk/libs/regex/test/c_compiler_checks/posix_api_check.cpp
==============================================================================
--- trunk/libs/regex/test/c_compiler_checks/posix_api_check.cpp (original)
+++ trunk/libs/regex/test/c_compiler_checks/posix_api_check.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -33,30 +33,30 @@
 
 int main()
 {
- regex_t re;
+ regex_tA re;
    int result;
- result = regcomp(&re, expression, REG_AWK);
+ result = regcompA(&re, expression, REG_AWK);
    if(result > REG_NOERROR)
    {
       char buf[256];
- regerror(result, &re, buf, sizeof(buf));
+ regerrorA(result, &re, buf, sizeof(buf));
       printf(buf);
       return result;
    }
    BOOST_TEST(re.re_nsub == 0);
    matches[0].rm_so = 0;
    matches[0].rm_eo = strlen(text);
- result = regexec(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
+ result = regexecA(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
    if(result > REG_NOERROR)
    {
       char buf[256];
- regerror(result, &re, buf, sizeof(buf));
+ regerrorA(result, &re, buf, sizeof(buf));
       printf(buf);
- regfree(&re);
+ regfreeA(&re);
       return result;
    }
    BOOST_TEST(matches[0].rm_so == matches[0].rm_eo == 1);
- regfree(&re);
+ regfreeA(&re);
    printf("no errors found\n");
    return boost::report_errors();
 }

Modified: trunk/libs/regex/test/regress/test_locale.cpp
==============================================================================
--- trunk/libs/regex/test/regress/test_locale.cpp (original)
+++ trunk/libs/regex/test/regress/test_locale.cpp 2007-11-24 07:25:25 EST (Sat, 24 Nov 2007)
@@ -26,6 +26,7 @@
 
 test_locale::test_locale(const char* c_name, boost::uint32_t lcid)
 {
+#ifndef UNDER_CE
    // store the name:
    m_old_name = m_name;
    m_name = c_name;
@@ -43,6 +44,9 @@
       s_c_locale = no_test;
       std::cout << "The global C locale: " << c_name << " is not available and will not be tested." << std::endl;
    }
+#else
+ s_c_locale = no_test;
+#endif
 #ifndef BOOST_NO_STD_LOCALE
    // back up the C++ locale and create the new one:
    m_old_cpp_locale = s_cpp_locale_inst;
@@ -69,6 +73,7 @@
    // Start by geting the printable name of the locale.
    // We use this for debugging purposes only:
    //
+#ifndef BOOST_NO_ANSI_APIS
    boost::scoped_array<char> p;
    int r = ::GetLocaleInfoA(
                lcid, // locale identifier
@@ -83,6 +88,43 @@
                p.get(), // information buffer
                r+1 // size of buffer
             );
+#else
+ WCHAR code_page_string[7];
+ int r = ::GetLocaleInfoW(
+ lcid,
+ LOCALE_IDEFAULTANSICODEPAGE,
+ code_page_string,
+ 7);
+ BOOST_ASSERT(r != 0);
+
+ UINT code_page = static_cast<UINT>(_wtol(code_page_string));
+
+ boost::scoped_array<wchar_t> wp;
+ r = ::GetLocaleInfoW(
+ lcid, // locale identifier
+ LOCALE_SCOUNTRY, // information type
+ 0, // information buffer
+ 0 // size of buffer
+ );
+ wp.reset(new wchar_t[r+1]);
+ r = ::GetLocaleInfoW(
+ lcid, // locale identifier
+ LOCALE_SCOUNTRY, // information type
+ wp.get(), // information buffer
+ r+1 // size of buffer
+ );
+
+ int name_size = (r+1) * 2;
+ boost::scoped_array<char> p(new char[name_size]);
+ int conv_r = ::WideCharToMultiByte(
+ code_page,
+ 0,
+ wp.get(), r,
+ p.get(), name_size,
+ NULL, NULL
+ );
+ BOOST_ASSERT(conv_r != 0);
+#endif
    //
    // now see if locale is installed and behave accordingly:
    //
@@ -104,8 +146,10 @@
 test_locale::~test_locale()
 {
    // restore to previous state:
+#ifndef UNDER_CE
    std::setlocale(LC_ALL, m_old_c_locale.c_str());
    s_c_locale = m_old_c_state;
+#endif
 #ifndef BOOST_NO_STD_LOCALE
    s_cpp_locale_inst = m_old_cpp_locale;
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk