-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ported regex files for Windows Phone 8.1 #22
base: develop
Are you sure you want to change the base?
Changes from 1 commit
e9cae88
29690c7
30302c4
dc9ec1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,12 @@ namespace std{ | |
#include <sys/cygwin.h> | ||
#endif | ||
|
||
#if defined (BOOST_ASIO_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't use internal asio macros here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Indeed, the line should read: #if defined (BOOST_PLAT_WINDOWS_RUNTIME) || defined (BOOST_PLAT_WINDOWS_PHONE) (Note the use of 'PLAT' rather than 'ASIO'.) This must have leaked through from my port of ASIO and submitted to Chris Kohlhoff. :-) I'd like to make the change to the #ifdef statement. I'm relatively new to Git: how can I make that change? Do I need to submit a new pull request? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No just push the change to the cloned repro you used for the PR and the Thanks, John. |
||
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<const char*>(MapViewOfFileFromAppW(hmap, FILE_MAP_READ, 0, 0)); | ||
#else | ||
_first = static_cast<const char*>(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,21 +405,26 @@ 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 | ||
} | ||
|
||
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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the assert earlier, these checks look redundant to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The three functions:
are not consistent in their manner of validity checking. If BOOST_ASSERT is like its C counterpart, then it will only catch a null 'f' value in debug, not release. For release mode, all validity checks must be in the form of C++ comparison statements. For that matter, the BOOST_ASSERT() macro should be used in all three functions.
In addition, the check of "if (file && node)" was being done in only function no. 1, not in 2 and 3. IMHO, the check should be done in all three functions (and not in 1 & 2 only as I submitted).
Both "file" and "node' should be checked for null values in all three functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comment #19 for a similar discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 03/11/2015 20:35, mosherubin wrote:
You need to realise that these are strictly internal implementation
details that are only constructed in certain ways (they're also
deprecated so we're arguing over angels on a pinhead, but never mind).
The following invariants hold:
if file is NULL then node is NULL.
If file is not NULL then node is not NULL.
When constructing from a mapfile then the argument is never NULL.
IMO using asserts to check these invariants is exactly the correct thing
to do.
Best, John.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi John,
I most certainly defer to you on these issues 👍 ! Do you need me to make any changes or can you make them? if the former, what would you like me to do?
Regards,
Moshe