Skip to content

universal-windows: Port to winrt #17

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions include/boost/regex/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# include BOOST_REGEX_USER_CONFIG

# include <boost/config.hpp>
# include <boost/predef.h>

#else
/*
Expand Down Expand Up @@ -177,10 +178,20 @@
* with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
* of the non-inline functions in the library, so that users can still link to the lib,
* irrespective of whether their own code is built with /Zc:wchar_t.
* Note that this does NOT WORK with VC10 when the C++ locale is in effect as
* Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
* the locale's <unsigned short> facets simply do not compile in that case.
* As we default to the C++ locale when compiling for the windows runtime we
* skip in this case aswell.
*/
#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) && ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE))
#if defined(__cplusplus) && \
(defined(BOOST_MSVC) || defined(__ICL)) && \
!defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
defined(BOOST_WINDOWS) && \
!defined(__SGI_STL_PORT) && \
!defined(_STLPORT_VERSION) && \
!defined(BOOST_RWSTD_VER) && \
((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
!BOOST_PLAT_WINDOWS_RUNTIME
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
# ifdef BOOST_MSVC
# pragma warning(push)
Expand Down Expand Up @@ -278,8 +289,12 @@
# define BOOST_REGEX_USE_C_LOCALE
#endif

#if BOOST_PLAT_WINDOWS_RUNTIME
# define BOOST_REGEX_NO_WIN32_LOCALE
#endif

/* Win32 defaults to native Win32 locale: */
#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32)
#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_NO_WIN32_LOCALE)
# define BOOST_REGEX_USE_WIN32_LOCALE
#endif
/* otherwise use C++ locale if supported: */
Expand Down
4 changes: 4 additions & 0 deletions include/boost/regex/v4/w32_regex_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED
#define BOOST_W32_REGEX_TRAITS_HPP_INCLUDED

#ifndef BOOST_REGEX_NO_WIN32_LOCALE

#ifndef BOOST_RE_PAT_EXCEPT_HPP
#include <boost/regex/pattern_except.hpp>
#endif
Expand Down Expand Up @@ -736,4 +738,6 @@ static_mutex& w32_regex_traits<charT>::get_mutex_inst()
#pragma warning(pop)
#endif

#endif // BOOST_REGEX_NO_WIN32_LOCALE

#endif
25 changes: 22 additions & 3 deletions src/fileiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <climits>
#include <stdexcept>
#include <string>
#include <boost/predef.h>
#include <boost/throw_exception.hpp>
#include <boost/regex/v4/fileiter.hpp>
#include <boost/regex/v4/regex_workaround.hpp>
Expand Down Expand Up @@ -92,8 +93,13 @@ void mapfile::open(const char* 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
else {
#if BOOST_PLAT_WINDOWS_RUNTIME
hfile = CreateFile2(wide_file, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, NULL);
#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 );
Expand Down Expand Up @@ -121,7 +127,20 @@ void mapfile::open(const char* file)
hfile = 0;
std::runtime_error err("Unable to create file mapping.");
}
#if BOOST_PLAT_WINDOWS_RUNTIME
FILE_STANDARD_INFO fsi;
if (!GetFileInformationByHandleEx(hfile, FileStandardInfo, &fsi, sizeof(fsi)))
{
// call failed
_last = _first;
}
else
{
_last = _first + fsi.EndOfFile.QuadPart;
}
#else
_last = _first + GetFileSize(hfile, 0);
#endif
}
else
{
Expand Down Expand Up @@ -378,9 +397,9 @@ inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data)
if (::MultiByteToWideChar(CP_ACP, 0, wild, wild_size, wide_wild, wild_size + 1) == 0)
return _fi_invalid_handle;

return FindFirstFileW(wide_wild, &data);
return FindFirstFileExW(wide_wild, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the MSDN library documentation, FindFirstFileExW is available in Windows XP and Server 2003, so maybe it can be used unconditionally (like in your filesystem pull request)?

And the boost/predef/platform.h include for the BOOST_PLAT_* macros seems to be missing, also in your filesystem and test pull requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(thanks for the review: @MarcelRaad )

I will switch to unconditionally use FindFirstFileExW.

As it were boost.predef was being pulled in by something else which is the reason why it worked. I guess it is ok to add a dependency to boost.predef?

#else
return FindFirstFileA(wild, &data);
return FindFirstFileExA(wild, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/w32_regex_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define BOOST_REGEX_SOURCE
#include <boost/regex/config.hpp>

#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_NO_WIN32_LOCALE)
#include <boost/regex/regex_traits.hpp>
#include <boost/regex/pattern_except.hpp>

Expand Down