From e9cae888a5ecbee812186b7298ac0ec8b8341ff0 Mon Sep 17 00:00:00 2001 From: Moshe Rubin Date: Tue, 3 Nov 2015 14:08:21 +0200 Subject: [PATCH 1/4] Ported regex files for Windows Phone 8.1 --- include/boost/regex/v4/fileiter.hpp | 5 +- src/fileiter.cpp | 44 ++- src/static_mutex.cpp | 8 + src/w32_regex_traits.cpp | 450 +++++++++++++++++++++++----- 4 files changed, 422 insertions(+), 85 deletions(-) diff --git a/include/boost/regex/v4/fileiter.hpp b/include/boost/regex/v4/fileiter.hpp index 256a7e460..4f58b19b3 100644 --- a/include/boost/regex/v4/fileiter.hpp +++ b/include/boost/regex/v4/fileiter.hpp @@ -229,14 +229,15 @@ class BOOST_REGEX_DECL mapfile_iterator file = f; node = f->_first + arg_position / mapfile::buf_size; offset = arg_position % mapfile::buf_size; - file->lock(node); + if(file && node) + file->lock(node); } mapfile_iterator(const mapfile_iterator& i) { file = i.file; node = i.node; offset = i.offset; - if(file) + if(file && node) file->lock(node); } ~mapfile_iterator() diff --git a/src/fileiter.cpp b/src/fileiter.cpp index c48ed657c..3083c5b0a 100644 --- a/src/fileiter.cpp +++ b/src/fileiter.cpp @@ -53,6 +53,12 @@ namespace std{ #include #endif +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +WINBASEAPI HANDLE WINAPI CreateFileMappingFromAppW(HANDLE, LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR); +WINBASEAPI LPVOID WINAPI MapViewOfFileFromAppW(HANDLE, ULONG, ULONG64, SIZE_T); +WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); +#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + #ifdef BOOST_MSVC # pragma warning(disable: 4800) #endif @@ -87,13 +93,23 @@ const char* _fi_sep_alt = _fi_sep; void mapfile::open(const char* file) { -#if defined(BOOST_NO_ANSI_APIS) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) 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 + { +# if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + CREATEFILE2_EXTENDED_PARAMETERS params = { 0 }; + + params.dwSize = sizeof (CREATEFILE2_EXTENDED_PARAMETERS); + params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + hfile = CreateFile2(wide_file, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, ¶ms); +# else hfile = CreateFileW(wide_file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); +# endif + } #elif defined(__CYGWIN__)||defined(__CYGWIN32__) char win32file[ MAX_PATH ]; cygwin_conv_to_win32_path( file, win32file ); @@ -103,7 +119,11 @@ void mapfile::open(const char* file) #endif if(hfile != INVALID_HANDLE_VALUE) { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + hmap = CreateFileMappingFromAppW(hfile, 0, PAGE_READONLY, 0, 0); +#else hmap = CreateFileMapping(hfile, 0, PAGE_READONLY, 0, 0, 0); +#endif if((hmap == INVALID_HANDLE_VALUE) || (hmap == NULL)) { CloseHandle(hfile); @@ -112,7 +132,13 @@ void mapfile::open(const char* file) std::runtime_error err("Unable to create file mapping."); boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } + +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + _first = static_cast(MapViewOfFileFromAppW(hmap, FILE_MAP_READ, 0, 0)); +#else _first = static_cast(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0)); +#endif + if(_first == 0) { CloseHandle(hmap); @@ -121,7 +147,14 @@ void mapfile::open(const char* file) hfile = 0; std::runtime_error err("Unable to create file mapping."); } + +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WIN32_FILE_ATTRIBUTE_DATA fad = { 0 }; + GetFileAttributesExW(wide_file, GetFileExInfoStandard, &fad); + _last = _first + fad.nFileSizeLow; +#else _last = _first + GetFileSize(hfile, 0); +#endif } else { @@ -372,13 +405,18 @@ void mapfile::close() inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data) { -#ifdef BOOST_NO_ANSI_APIS +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) 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; +# if defined (BOOST_NO_ANSI_APIS) return FindFirstFileW(wide_wild, &data); +# elif defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + return FindFirstFileExW(wide_wild, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0); +# endif + #else return FindFirstFileA(wild, &data); #endif @@ -386,7 +424,7 @@ inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data) inline bool find_next_file(_fi_find_handle hf, _fi_find_data& data) { -#ifdef BOOST_NO_ANSI_APIS +#if defined (BOOST_NO_ANSI_APIS) return FindNextFileW(hf, &data); #else return FindNextFileA(hf, &data); diff --git a/src/static_mutex.cpp b/src/static_mutex.cpp index d02b01fc6..fb01d4ecf 100644 --- a/src/static_mutex.cpp +++ b/src/static_mutex.cpp @@ -19,6 +19,10 @@ #define BOOST_REGEX_SOURCE #include #include +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#include +#include +#endif #ifdef BOOST_HAS_THREADS @@ -99,7 +103,11 @@ void scoped_static_mutex_lock::lock() while(0 != InterlockedCompareExchange(reinterpret_cast(&(m_mutex.m_mutex)), 1, 0)) #endif { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); +#else Sleep(0); +#endif } m_have_lock = true; } diff --git a/src/w32_regex_traits.cpp b/src/w32_regex_traits.cpp index 0f8257024..f9ff098cb 100644 --- a/src/w32_regex_traits.cpp +++ b/src/w32_regex_traits.cpp @@ -42,12 +42,22 @@ namespace std{ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#ifdef BOOST_NO_ANSI_APIS +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT get_code_page_for_locale_id(lcid_type idx) { WCHAR code_page_string[7]; +#if defined(BOOST_NO_ANSI_APIS) if (::GetLocaleInfoW(idx, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0) return 0; +#else /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return 0; + + if (::GetLocaleInfoEx(strLocaleNameBuffer, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0) + return 0; +#endif return static_cast(_wtol(code_page_string)); } @@ -118,10 +128,8 @@ void w32_regex_traits_char_layer::init() char char_map[1 << CHAR_BIT]; for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) char_map[ii] = static_cast(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 + +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(this->m_locale); BOOST_ASSERT(code_page != 0); @@ -130,12 +138,27 @@ void w32_regex_traits_char_layer::init() BOOST_ASSERT(conv_r != 0); WCHAR wide_lower_map[1 << CHAR_BIT]; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(this->m_locale, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + { + // Invalid locale identifier, cannot initialize the char layer + return; + } + int r = ::LCMapStringEx(strLocaleNameBuffer, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT, NULL, NULL, 0); +#else int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT); +#endif 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); +#else + int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL, 0); + BOOST_ASSERT(r != 0); #endif + if(r < (1 << CHAR_BIT)) { // if we have multibyte characters then not all may have been given @@ -144,27 +167,29 @@ void w32_regex_traits_char_layer::init() this->m_lower_map[jj] = static_cast(jj); } -#ifndef BOOST_NO_ANSI_APIS - r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); -#else +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); +#else + r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); #endif BOOST_ASSERT(0 != r); } BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + GetUserDefaultLocaleName(strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH); + return LocaleNameToLCID(strLocaleNameBuffer, LOCALE_ALLOW_NEUTRAL_NAMES); +#else return ::GetUserDefaultLCID(); +#endif } BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx) { -#ifndef BOOST_NO_ANSI_APIS - WORD mask; - if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) - return true; - return false; -#else +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -177,6 +202,11 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx) if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER)) return true; return false; +#else + WORD mask; + if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; #endif } @@ -200,12 +230,7 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx) { -#ifndef BOOST_NO_ANSI_APIS - WORD mask; - if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) - return true; - return false; -#else +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -218,6 +243,11 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx) if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER)) return true; return false; +#else + WORD mask; + if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; #endif } @@ -246,7 +276,13 @@ void free_module(void* mod) BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) { -#ifndef BOOST_NO_ANSI_APIS +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + std::string m("w32_cat_open not supported in Windows Runtime: "); + std::runtime_error err(m + name); + ::boost::re_detail::raise_runtime_error(err); + cat_type emptyReturn; + return emptyReturn; +#elif !defined (BOOST_NO_ANSI_APIS) cat_type result(::LoadLibraryA(name.c_str()), &free_module); return result; #else @@ -261,7 +297,17 @@ BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) 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 +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + (void) cat; + (void) i; + + std::string m("w32_cat_get not supported in Windows Runtime: "); + std::runtime_error err(m + def); + ::boost::re_detail::raise_runtime_error(err); + + std::string emptyResult; + return emptyResult; +#elif !defined (BOOST_NO_ANSI_APIS) char buf[256]; if(0 == ::LoadStringA( static_cast(cat.get()), @@ -288,13 +334,25 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, l LPSTR buf = (LPSTR)_alloca(buf_size); if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, buf_size, NULL, NULL) == 0) return def; // failed conversion. -#endif return std::string(buf); +#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #ifndef BOOST_NO_WREGEX BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def) { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + (void) cat; + (void) i; + (void) def; + + std::string m("w32_cat_get not supported in Windows Runtime"); + std::runtime_error err(m); + ::boost::re_detail::raise_runtime_error(err); + + std::wstring emptyResult; + return emptyResult; +#else wchar_t buf[256]; if(0 == ::LoadStringW( static_cast(cat.get()), @@ -306,10 +364,23 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, return def; } return std::wstring(buf); +#endif /* (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string& def) { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + (void)cat; + (void)i; + (void)def; + + std::string m("w32_cat_get not supported in Windows Runtime"); + std::runtime_error err(m); + ::boost::re_detail::raise_runtime_error(err); + + std::basic_string emptyResult; + return emptyResult; +#else unsigned short buf[256]; if(0 == ::LoadStringW( static_cast(cat.get()), @@ -321,32 +392,13 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get( return def; } return std::basic_string(buf); +#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #endif #endif BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2) { -#ifndef BOOST_NO_ANSI_APIS - int bytes = ::LCMapStringA( - idx, // locale identifier - LCMAP_SORTKEY, // mapping transformation type - p1, // source string - static_cast(p2 - p1), // 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 = ::LCMapStringA( - idx, // locale identifier - LCMAP_SORTKEY, // mapping transformation type - p1, // source string - static_cast(p2 - p1), // number of characters in source string - &*result.begin(), // destination buffer - bytes // size of destination buffer - ); -#else +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return std::string(p1, p2); @@ -356,6 +408,38 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const if(::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0) return std::string(p1, p2); +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return std::string(p1, p2); + + int bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + 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 + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); + if (!bytes) + return std::string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + 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 + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#elif defined(BOOST_NO_ANSI_APIS) int bytes = ::LCMapStringW( idx, // locale identifier LCMAP_SORTKEY, // mapping transformation type @@ -375,7 +459,28 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const (LPWSTR)&*result.begin(), // destination buffer bytes // size of destination buffer ); -#endif +#else + int bytes = ::LCMapStringA( + idx, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // 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 = ::LCMapStringA( + idx, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + &*result.begin(), // destination buffer + bytes // size of destination buffer + ); +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + if(bytes > static_cast(result.size())) return std::string(p1, p2); while(result.size() && result[result.size()-1] == '\0') @@ -385,9 +490,41 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const return result; } -#ifndef BOOST_NO_WREGEX +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2) { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return L""; + + int bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + 0, // destination buffer + 0, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); + if(!bytes) + return std::wstring(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + reinterpret_cast(&*result.begin()), // destination buffer *of bytes* + bytes, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int bytes = ::LCMapStringW( idx, // locale identifier LCMAP_SORTKEY, // mapping transformation type @@ -407,6 +544,7 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(bytes > static_cast(result.size())) return std::wstring(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -418,9 +556,44 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons r2.append(1, static_cast(static_cast(result[i]))); return r2; } -#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type idx, const unsigned short* p1, const unsigned short* p2) { +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + std::basic_string emptyReturn; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return emptyReturn; + + int bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast(p2 - p1), // number of characters in source string + 0, // destination buffer + 0, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); + if(!bytes) + return std::basic_string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast(p2 - p1), // number of characters in source string + reinterpret_cast(&*result.begin()), // destination buffer *of bytes* + bytes, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int bytes = ::LCMapStringW( idx, // locale identifier LCMAP_SORTKEY, // mapping transformation type @@ -440,6 +613,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(bytes > static_cast(result.size())) return std::basic_string(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -456,17 +630,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) { char result[2]; -#ifndef BOOST_NO_ANSI_APIS - int b = ::LCMapStringA( - idx, // locale identifier - LCMAP_LOWERCASE, // mapping transformation type - &c, // source string - 1, // number of characters in source string - result, // destination buffer - 1); // size of destination buffer - if(b == 0) - return c; -#else +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return c; @@ -476,6 +640,24 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) return c; WCHAR wide_result; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + 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 + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int b = ::LCMapStringW( idx, // locale identifier LCMAP_LOWERCASE, // mapping transformation type @@ -483,19 +665,48 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) 1, // number of characters in source string &wide_result, // destination buffer 1); // size of destination buffer +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) return c; // No single byte lower case equivalent available -#endif +#else + int b = ::LCMapStringA( + idx, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if (b == 0) + return c; +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + return result[0]; } -#ifndef BOOST_NO_WREGEX +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) { wchar_t result[2]; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int b = ::LCMapStringW( idx, // locale identifier LCMAP_LOWERCASE, // mapping transformation type @@ -503,14 +714,34 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; } -#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T + +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type idx) { wchar_t result[2]; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_LOWERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int b = ::LCMapStringW( idx, // locale identifier LCMAP_LOWERCASE, // mapping transformation type @@ -518,6 +749,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; @@ -527,17 +759,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) { char result[2]; -#ifndef BOOST_NO_ANSI_APIS - int b = ::LCMapStringA( - idx, // locale identifier - LCMAP_UPPERCASE, // mapping transformation type - &c, // source string - 1, // number of characters in source string - result, // destination buffer - 1); // size of destination buffer - if(b == 0) - return c; -#else +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return c; @@ -547,6 +769,8 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) return c; WCHAR wide_result; + +#if defined (BOOST_NO_ANSI_APIS) int b = ::LCMapStringW( idx, // locale identifier LCMAP_UPPERCASE, // mapping transformation type @@ -554,19 +778,65 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) 1, // number of characters in source string &wide_result, // destination buffer 1); // size of destination buffer +#else + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + 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 + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#endif /* defined (BOOST_NO_ANSI_APIS) */ if(b == 0) return c; if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) return c; // No single byte upper case equivalent available. -#endif +#else + int b = ::LCMapStringA( + idx, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if (b == 0) + return c; +#endif /* defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ return result[0]; } -#ifndef BOOST_NO_WREGEX +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) { wchar_t result[2]; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#elif !defined (BOOST_NO_WREGEX) int b = ::LCMapStringW( idx, // locale identifier LCMAP_UPPERCASE, // mapping transformation type @@ -574,14 +844,34 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer +#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; } -#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ + +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type idx) { wchar_t result[2]; +#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) + WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; + + if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) + return c; + int b = ::LCMapStringEx( + strLocaleNameBuffer, // locale name + LCMAP_UPPERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1, // size of destination buffer + NULL, // lpVersionInformation + NULL, // lpReserved + 0 // sorthandle + ); +#else int b = ::LCMapStringW( idx, // locale identifier LCMAP_UPPERCASE, // mapping transformation type @@ -589,19 +879,16 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, l 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) */ if(b == 0) return c; return result[0]; } #endif -#endif BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c) { WORD mask; -#ifndef BOOST_NO_ANSI_APIS - if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) - return true; -#else +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return false; @@ -612,6 +899,9 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) return true; +#else + if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) + return true; #endif if((m & w32_regex_traits_implementation::mask_word) && (c == '_')) return true; From 29690c741e7d47bbbb0b7f4249be0179248e1c6d Mon Sep 17 00:00:00 2001 From: Moshe Rubin Date: Wed, 4 Nov 2015 12:01:12 +0200 Subject: [PATCH 2/4] Changed all instances of BOOST_ASIO_WINDOWS_RUNTIME to BOOST_PLAT_WINDOWS_RUNTIME --- src/fileiter.cpp | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/fileiter.cpp b/src/fileiter.cpp index 3083c5b0a..35ccc0030 100644 --- a/src/fileiter.cpp +++ b/src/fileiter.cpp @@ -3,12 +3,12 @@ * Copyright (c) 1998-2002 * John Maddock * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ - + /* * LOCATION: see http://www.boost.org for most recent version. * FILE: fileiter.cpp @@ -53,11 +53,11 @@ namespace std{ #include #endif -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WINBASEAPI HANDLE WINAPI CreateFileMappingFromAppW(HANDLE, LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR); WINBASEAPI LPVOID WINAPI MapViewOfFileFromAppW(HANDLE, ULONG, ULONG64, SIZE_T); WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); -#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ #ifdef BOOST_MSVC # pragma warning(disable: 4800) @@ -93,14 +93,14 @@ const char* _fi_sep_alt = _fi_sep; void mapfile::open(const char* file) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) 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 { -# if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +# if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) CREATEFILE2_EXTENDED_PARAMETERS params = { 0 }; params.dwSize = sizeof (CREATEFILE2_EXTENDED_PARAMETERS); @@ -119,7 +119,7 @@ void mapfile::open(const char* file) #endif if(hfile != INVALID_HANDLE_VALUE) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) hmap = CreateFileMappingFromAppW(hfile, 0, PAGE_READONLY, 0, 0); #else hmap = CreateFileMapping(hfile, 0, PAGE_READONLY, 0, 0, 0); @@ -133,7 +133,7 @@ void mapfile::open(const char* file) boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) _first = static_cast(MapViewOfFileFromAppW(hmap, FILE_MAP_READ, 0, 0)); #else _first = static_cast(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0)); @@ -148,7 +148,7 @@ void mapfile::open(const char* file) std::runtime_error err("Unable to create file mapping."); } -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WIN32_FILE_ATTRIBUTE_DATA fad = { 0 }; GetFileAttributesExW(wide_file, GetFileExInfoStandard, &fad); _last = _first + fad.nFileSizeLow; @@ -292,23 +292,23 @@ void mapfile::lock(pointer* node)const *p = 0; *(reinterpret_cast(*node)) = 1; } - - std::size_t read_size = 0; - int read_pos = std::fseek(hfile, (node - _first) * buf_size, SEEK_SET); - if(0 == read_pos && node == _last - 1) - read_size = std::fread(*node + sizeof(int), _size % buf_size, 1, hfile); + std::size_t read_size = 0; + int read_pos = std::fseek(hfile, (node - _first) * buf_size, SEEK_SET); + + if(0 == read_pos && node == _last - 1) + read_size = std::fread(*node + sizeof(int), _size % buf_size, 1, hfile); else read_size = std::fread(*node + sizeof(int), buf_size, 1, hfile); if((read_size == 0) || (std::ferror(hfile))) - { -#ifndef BOOST_NO_EXCEPTIONS + { +#ifndef BOOST_NO_EXCEPTIONS unlock(node); - throw std::runtime_error("Unable to read file."); -#else - BOOST_REGEX_NOEH_ASSERT((0 == std::ferror(hfile)) && (read_size != 0)); -#endif - } + throw std::runtime_error("Unable to read file."); +#else + BOOST_REGEX_NOEH_ASSERT((0 == std::ferror(hfile)) && (read_size != 0)); +#endif + } } else { @@ -405,7 +405,7 @@ void mapfile::close() inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data) { -#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) 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) @@ -413,7 +413,7 @@ inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data) # if defined (BOOST_NO_ANSI_APIS) return FindFirstFileW(wide_wild, &data); -# elif defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +# elif defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) return FindFirstFileExW(wide_wild, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0); # endif @@ -430,7 +430,7 @@ inline bool find_next_file(_fi_find_handle hf, _fi_find_data& data) 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 From 30302c42360faa9ee16c0a84fd81c757068bf5c6 Mon Sep 17 00:00:00 2001 From: Moshe Rubin Date: Wed, 4 Nov 2015 12:37:06 +0200 Subject: [PATCH 3/4] Changed BOOST_ASIO_WINDOWS_RUNTIME to BOOST_PLAT_WINDOWS_RUNTIME --- src/static_mutex.cpp | 10 ++-- src/w32_regex_traits.cpp | 100 +++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/static_mutex.cpp b/src/static_mutex.cpp index fb01d4ecf..f670d093e 100644 --- a/src/static_mutex.cpp +++ b/src/static_mutex.cpp @@ -3,12 +3,12 @@ * Copyright (c) 2004 * John Maddock * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ - + /* * LOCATION: see http://www.boost.org for most recent version. * FILE static_mutex.cpp @@ -19,7 +19,7 @@ #define BOOST_REGEX_SOURCE #include #include -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) #include #include #endif @@ -103,7 +103,7 @@ void scoped_static_mutex_lock::lock() while(0 != InterlockedCompareExchange(reinterpret_cast(&(m_mutex.m_mutex)), 1, 0)) #endif { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) || (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) std::this_thread::sleep_for(std::chrono::milliseconds(1000)); #else Sleep(0); diff --git a/src/w32_regex_traits.cpp b/src/w32_regex_traits.cpp index f9ff098cb..d219d47df 100644 --- a/src/w32_regex_traits.cpp +++ b/src/w32_regex_traits.cpp @@ -3,12 +3,12 @@ * Copyright (c) 2004 * John Maddock * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ - + /* * LOCATION: see http://www.boost.org for most recent version. * FILE w32_regex_traits.cpp @@ -42,14 +42,14 @@ namespace std{ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT get_code_page_for_locale_id(lcid_type idx) { WCHAR code_page_string[7]; #if defined(BOOST_NO_ANSI_APIS) if (::GetLocaleInfoW(idx, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0) return 0; -#else /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#else /* defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -64,7 +64,7 @@ UINT get_code_page_for_locale_id(lcid_type idx) #endif -void w32_regex_traits_char_layer::init() +void w32_regex_traits_char_layer::init() { // we need to start by initialising our syntax map so we know which // character is used for which purpose: @@ -115,9 +115,9 @@ void w32_regex_traits_char_layer::init() { if(m_char_map[i] == 0) { - if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0002u, (char)i)) + if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0002u, (char)i)) m_char_map[i] = regex_constants::escape_type_class; - else if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0001u, (char)i)) + else if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0001u, (char)i)) m_char_map[i] = regex_constants::escape_type_not_class; } }while(0xFF != i++); @@ -129,7 +129,7 @@ void w32_regex_traits_char_layer::init() for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) char_map[ii] = static_cast(ii); -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(this->m_locale); BOOST_ASSERT(code_page != 0); @@ -138,7 +138,7 @@ void w32_regex_traits_char_layer::init() BOOST_ASSERT(conv_r != 0); WCHAR wide_lower_map[1 << CHAR_BIT]; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(this->m_locale, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -167,7 +167,7 @@ void w32_regex_traits_char_layer::init() this->m_lower_map[jj] = static_cast(jj); } -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); #else r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); @@ -177,7 +177,7 @@ void w32_regex_traits_char_layer::init() BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; GetUserDefaultLocaleName(strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH); @@ -189,7 +189,7 @@ BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -230,7 +230,7 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -276,7 +276,7 @@ void free_module(void* mod) BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) std::string m("w32_cat_open not supported in Windows Runtime: "); std::runtime_error err(m + name); ::boost::re_detail::raise_runtime_error(err); @@ -297,7 +297,7 @@ BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) (void) cat; (void) i; @@ -335,13 +335,13 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, l if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, buf_size, NULL, NULL) == 0) return def; // failed conversion. return std::string(buf); -#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #ifndef BOOST_NO_WREGEX BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) (void) cat; (void) i; (void) def; @@ -364,12 +364,12 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, return def; } return std::wstring(buf); -#endif /* (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string& def) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) (void)cat; (void)i; (void)def; @@ -392,13 +392,13 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get( return def; } return std::basic_string(buf); -#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ } #endif #endif BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return std::string(p1, p2); @@ -408,7 +408,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const if(::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0) return std::string(p1, p2); -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -479,7 +479,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const &*result.begin(), // destination buffer bytes // size of destination buffer ); -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(bytes > static_cast(result.size())) return std::string(p1, p2); @@ -490,10 +490,10 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const return result; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -544,7 +544,7 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(bytes > static_cast(result.size())) return std::wstring(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -556,12 +556,12 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons r2.append(1, static_cast(static_cast(result[i]))); return r2; } -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type idx, const unsigned short* p1, const unsigned short* p2) { -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; std::basic_string emptyReturn; @@ -613,7 +613,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); -#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(bytes > static_cast(result.size())) return std::basic_string(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -630,7 +630,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) { char result[2]; -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return c; @@ -640,7 +640,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) return c; WCHAR wide_result; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -665,7 +665,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) 1, // number of characters in source string &wide_result, // destination buffer 1); // size of destination buffer -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; @@ -681,16 +681,16 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) 1); // size of destination buffer if (b == 0) return c; -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ return result[0]; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) { wchar_t result[2]; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -714,17 +714,17 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; } -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type idx) { wchar_t result[2]; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -749,7 +749,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer -#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; @@ -759,7 +759,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) { char result[2]; -#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return c; @@ -811,15 +811,15 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) 1); // size of destination buffer if (b == 0) return c; -#endif /* defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ return result[0]; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) { wchar_t result[2]; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -844,18 +844,18 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer -#endif /* defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ if(b == 0) return c; return result[0]; } -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type idx) { wchar_t result[2]; -#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) WCHAR strLocaleNameBuffer[LOCALE_NAME_MAX_LENGTH]; if (LCIDToLocaleName(idx, strLocaleNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) == 0) @@ -888,7 +888,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, l BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c) { WORD mask; -#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return false; From dc9ec1cb36b384f0e6883175283a4bbb055d580b Mon Sep 17 00:00:00 2001 From: Moshe Rubin Date: Wed, 4 Nov 2015 12:58:33 +0200 Subject: [PATCH 4/4] As per MarcelRaad's comment, I have removed any WinRT-related preprocessor symbols. This is because line 22's '#if defined(_WIN32)' means that the entire file will be ignored for WinRT --- src/w32_regex_traits.cpp | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/w32_regex_traits.cpp b/src/w32_regex_traits.cpp index d219d47df..81a6dfa4a 100644 --- a/src/w32_regex_traits.cpp +++ b/src/w32_regex_traits.cpp @@ -42,7 +42,7 @@ namespace std{ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT get_code_page_for_locale_id(lcid_type idx) { WCHAR code_page_string[7]; @@ -129,7 +129,7 @@ void w32_regex_traits_char_layer::init() for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) char_map[ii] = static_cast(ii); -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(this->m_locale); BOOST_ASSERT(code_page != 0); @@ -167,7 +167,7 @@ void w32_regex_traits_char_layer::init() this->m_lower_map[jj] = static_cast(jj); } -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); #else r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); @@ -189,7 +189,7 @@ BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -230,7 +230,7 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return false; @@ -398,7 +398,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get( #endif BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2) { -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return std::string(p1, p2); @@ -479,7 +479,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const &*result.begin(), // destination buffer bytes // size of destination buffer ); -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) */ if(bytes > static_cast(result.size())) return std::string(p1, p2); @@ -490,7 +490,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const return result; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2) { #if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) @@ -544,7 +544,7 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) */ if(bytes > static_cast(result.size())) return std::wstring(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -556,9 +556,9 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, cons r2.append(1, static_cast(static_cast(result[i]))); return r2; } -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) */ -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type idx, const unsigned short* p1, const unsigned short* p2) { #if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) @@ -613,7 +613,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor reinterpret_cast(&*result.begin()), // destination buffer *of bytes* bytes // size of destination buffer ); -#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) */ if(bytes > static_cast(result.size())) return std::basic_string(p1, p2); while(result.size() && result[result.size()-1] == L'\0') @@ -630,7 +630,7 @@ BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transfor BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) { char result[2]; -#if defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined(BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if (code_page == 0) return c; @@ -665,7 +665,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) 1, // number of characters in source string &wide_result, // destination buffer 1); // size of destination buffer -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) */ if(b == 0) return c; @@ -681,12 +681,12 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) 1); // size of destination buffer if (b == 0) return c; -#endif /* defined(BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined(BOOST_NO_ANSI_APIS) */ return result[0]; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) { wchar_t result[2]; @@ -714,13 +714,13 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx) 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) */ if(b == 0) return c; return result[0]; } -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type idx) { wchar_t result[2]; @@ -749,7 +749,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l 1, // number of characters in source string result, // destination buffer 1); // size of destination buffer -#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) */ if(b == 0) return c; return result[0]; @@ -759,7 +759,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) { char result[2]; -#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return c; @@ -811,11 +811,11 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) 1); // size of destination buffer if (b == 0) return c; -#endif /* defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* defined (BOOST_NO_ANSI_APIS) */ return result[0]; } -#if !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if !defined (BOOST_NO_WREGEX) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) { wchar_t result[2]; @@ -849,9 +849,9 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx) return c; return result[0]; } -#endif /* !defined (BOOST_NO_WREGEX) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) */ +#endif /* !defined (BOOST_NO_WREGEX) */ -#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_REGEX_HAS_OTHER_WCHAR_T) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type idx) { wchar_t result[2]; @@ -888,7 +888,7 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, l BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c) { WORD mask; -#if defined (BOOST_NO_ANSI_APIS) || defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) +#if defined (BOOST_NO_ANSI_APIS) UINT code_page = get_code_page_for_locale_id(idx); if(code_page == 0) return false;