forked from boostorg/regex
Make c_regex_traits all inline.
Fix some C++20 issues.
This commit is contained in:
@ -122,9 +122,7 @@ explicit has_icu ;
|
|||||||
alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ;
|
alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ;
|
||||||
|
|
||||||
SOURCES =
|
SOURCES =
|
||||||
c_regex_traits.cpp
|
|
||||||
cpp_regex_traits.cpp
|
cpp_regex_traits.cpp
|
||||||
fileiter.cpp
|
|
||||||
icu.cpp
|
icu.cpp
|
||||||
posix_api.cpp
|
posix_api.cpp
|
||||||
regex.cpp
|
regex.cpp
|
||||||
@ -133,9 +131,8 @@ SOURCES =
|
|||||||
regex_traits_defaults.cpp
|
regex_traits_defaults.cpp
|
||||||
static_mutex.cpp
|
static_mutex.cpp
|
||||||
w32_regex_traits.cpp
|
w32_regex_traits.cpp
|
||||||
wc_regex_traits.cpp
|
|
||||||
wide_posix_api.cpp
|
wide_posix_api.cpp
|
||||||
|
;
|
||||||
|
|
||||||
lib boost_regex : ../src/$(SOURCES) icu_options
|
lib boost_regex : ../src/$(SOURCES) icu_options
|
||||||
:
|
:
|
||||||
@ -145,10 +142,3 @@ lib boost_regex : ../src/$(SOURCES) icu_options
|
|||||||
|
|
||||||
boost-install boost_regex ;
|
boost-install boost_regex ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <boost/regex/config.hpp>
|
#include <boost/regex/config.hpp>
|
||||||
#endif
|
#endif
|
||||||
#ifndef BOOST_REGEX_WORKAROUND_HPP
|
#ifndef BOOST_REGEX_WORKAROUND_HPP
|
||||||
#include <boost/regex/v4/regex_workaround.hpp>
|
#include <boost/regex/v5/regex_workaround.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@ -36,7 +36,7 @@ namespace std{
|
|||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4103)
|
#pragma warning(disable: 4103 4244)
|
||||||
#endif
|
#endif
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
#ifdef BOOST_HAS_ABI_HEADERS
|
||||||
# include BOOST_ABI_PREFIX
|
# include BOOST_ABI_PREFIX
|
||||||
@ -47,6 +47,30 @@ namespace std{
|
|||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
|
|
||||||
|
namespace BOOST_REGEX_DETAIL_NS {
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
char_class_space = 1 << 0,
|
||||||
|
char_class_print = 1 << 1,
|
||||||
|
char_class_cntrl = 1 << 2,
|
||||||
|
char_class_upper = 1 << 3,
|
||||||
|
char_class_lower = 1 << 4,
|
||||||
|
char_class_alpha = 1 << 5,
|
||||||
|
char_class_digit = 1 << 6,
|
||||||
|
char_class_punct = 1 << 7,
|
||||||
|
char_class_xdigit = 1 << 8,
|
||||||
|
char_class_alnum = char_class_alpha | char_class_digit,
|
||||||
|
char_class_graph = char_class_alnum | char_class_punct,
|
||||||
|
char_class_blank = 1 << 9,
|
||||||
|
char_class_word = 1 << 10,
|
||||||
|
char_class_unicode = 1 << 11,
|
||||||
|
char_class_horizontal = 1 << 12,
|
||||||
|
char_class_vertical = 1 << 13
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template <class charT>
|
template <class charT>
|
||||||
struct c_regex_traits;
|
struct c_regex_traits;
|
||||||
|
|
||||||
@ -139,58 +163,334 @@ private:
|
|||||||
c_regex_traits& operator=(const c_regex_traits&);
|
c_regex_traits& operator=(const c_regex_traits&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
#endif // BOOST_NO_WREGEX
|
||||||
|
|
||||||
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
|
||||||
|
{
|
||||||
|
std::string result(10, ' ');
|
||||||
|
std::size_t s = result.size();
|
||||||
|
std::size_t r;
|
||||||
|
std::string src(p1, p2);
|
||||||
|
while (s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
|
||||||
|
{
|
||||||
|
#if defined(_CPPLIB_VER)
|
||||||
//
|
//
|
||||||
// Provide an unsigned short version as well, so the user can link to this
|
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
||||||
// no matter whether they build with /Zc:wchar_t or not (MSVC specific).
|
// to std::strxfrm, but only for certain locales :-(
|
||||||
|
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
||||||
//
|
//
|
||||||
template<>
|
if (r == INT_MAX)
|
||||||
struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
|
|
||||||
{
|
{
|
||||||
c_regex_traits(){}
|
result.erase();
|
||||||
typedef unsigned short char_type;
|
result.insert(result.begin(), static_cast<char>(0));
|
||||||
typedef std::size_t size_type;
|
return result;
|
||||||
typedef std::basic_string<unsigned short> string_type;
|
}
|
||||||
struct locale_type{};
|
#endif
|
||||||
typedef boost::uint32_t char_class_type;
|
result.append(r - s + 3, ' ');
|
||||||
|
s = result.size();
|
||||||
static size_type length(const char_type* p)
|
}
|
||||||
{
|
result.erase(r);
|
||||||
return (std::wcslen)((const wchar_t*)p);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short translate(unsigned short c) const
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
|
||||||
{
|
{
|
||||||
return c;
|
static char s_delim;
|
||||||
|
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
|
||||||
|
std::string result;
|
||||||
|
//
|
||||||
|
// What we do here depends upon the format of the sort key returned by
|
||||||
|
// sort key returned by this->transform:
|
||||||
|
//
|
||||||
|
switch (s_collate_type)
|
||||||
|
{
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
||||||
|
// the best we can do is translate to lower case, then get a regular sort key:
|
||||||
|
{
|
||||||
|
result.assign(p1, p2);
|
||||||
|
for (std::string::size_type i = 0; i < result.size(); ++i)
|
||||||
|
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
|
||||||
|
result = transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
unsigned short translate_nocase(unsigned short c) const
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
||||||
{
|
{
|
||||||
return (std::towlower)((wchar_t)c);
|
// get a regular sort key, and then truncate it:
|
||||||
|
result = transform(p1, p2);
|
||||||
|
result.erase(s_delim);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
||||||
|
// get a regular sort key, and then truncate everything after the delim:
|
||||||
|
result = transform(p1, p2);
|
||||||
|
if ((!result.empty()) && (result[0] == s_delim))
|
||||||
|
break;
|
||||||
|
std::size_t i;
|
||||||
|
for (i = 0; i < result.size(); ++i)
|
||||||
|
{
|
||||||
|
if (result[i] == s_delim)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.erase(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result.empty())
|
||||||
|
result = std::string(1, char(0));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
|
inline c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
|
||||||
static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
|
static const char_class_type masks[] =
|
||||||
static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
|
{
|
||||||
|
0,
|
||||||
static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
|
char_class_alnum,
|
||||||
static int BOOST_REGEX_CALL value(unsigned short, int);
|
char_class_alpha,
|
||||||
|
char_class_blank,
|
||||||
locale_type imbue(locale_type l)
|
char_class_cntrl,
|
||||||
{ return l; }
|
char_class_digit,
|
||||||
locale_type getloc()const
|
char_class_digit,
|
||||||
{ return locale_type(); }
|
char_class_graph,
|
||||||
|
char_class_horizontal,
|
||||||
private:
|
char_class_lower,
|
||||||
// this type is not copyable:
|
char_class_lower,
|
||||||
c_regex_traits(const c_regex_traits&);
|
char_class_print,
|
||||||
c_regex_traits& operator=(const c_regex_traits&);
|
char_class_punct,
|
||||||
|
char_class_space,
|
||||||
|
char_class_space,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_unicode,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_vertical,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_xdigit,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
||||||
|
if (idx < 0)
|
||||||
|
{
|
||||||
|
std::string s(p1, p2);
|
||||||
|
for (std::string::size_type i = 0; i < s.size(); ++i)
|
||||||
|
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
|
||||||
|
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||||
|
}
|
||||||
|
BOOST_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0]));
|
||||||
|
return masks[idx + 1];
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BOOST_NO_WREGEX
|
inline bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
return
|
||||||
|
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
||||||
|
|| ((mask & char_class_word) && (c == '_'))
|
||||||
|
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|
||||||
|
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
|
||||||
|
{
|
||||||
|
std::string s(p1, p2);
|
||||||
|
s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s);
|
||||||
|
if (s.empty() && (p2 - p1 == 1))
|
||||||
|
s.append(1, *p1);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix)
|
||||||
|
{
|
||||||
|
char b[2] = { c, '\0', };
|
||||||
|
char* ep;
|
||||||
|
int result = std::strtol(b, &ep, radix);
|
||||||
|
if (ep == b)
|
||||||
|
return -1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_WREGEX
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
std::size_t r;
|
||||||
|
std::size_t s = 10;
|
||||||
|
std::wstring src(p1, p2);
|
||||||
|
std::wstring result(s, L' ');
|
||||||
|
while (s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
|
||||||
|
{
|
||||||
|
#if defined(_CPPLIB_VER)
|
||||||
|
//
|
||||||
|
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
||||||
|
// to std::strxfrm, but only for certain locales :-(
|
||||||
|
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
||||||
|
//
|
||||||
|
if (r == INT_MAX)
|
||||||
|
{
|
||||||
|
result.erase();
|
||||||
|
result.insert(result.begin(), static_cast<wchar_t>(0));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
result.append(r - s + 3, L' ');
|
||||||
|
s = result.size();
|
||||||
|
}
|
||||||
|
result.erase(r);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
static wchar_t s_delim;
|
||||||
|
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
|
||||||
|
std::wstring result;
|
||||||
|
//
|
||||||
|
// What we do here depends upon the format of the sort key returned by
|
||||||
|
// sort key returned by this->transform:
|
||||||
|
//
|
||||||
|
switch (s_collate_type)
|
||||||
|
{
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
||||||
|
// the best we can do is translate to lower case, then get a regular sort key:
|
||||||
|
{
|
||||||
|
result.assign(p1, p2);
|
||||||
|
for (std::wstring::size_type i = 0; i < result.size(); ++i)
|
||||||
|
result[i] = (std::towlower)(result[i]);
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
||||||
|
{
|
||||||
|
// get a regular sort key, and then truncate it:
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
result.erase(s_delim);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
||||||
|
// get a regular sort key, and then truncate everything after the delim:
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
if ((!result.empty()) && (result[0] == s_delim))
|
||||||
|
break;
|
||||||
|
std::size_t i;
|
||||||
|
for (i = 0; i < result.size(); ++i)
|
||||||
|
{
|
||||||
|
if (result[i] == s_delim)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.erase(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result.empty())
|
||||||
|
result = std::wstring(1, char(0));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
static const char_class_type masks[] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
char_class_alnum,
|
||||||
|
char_class_alpha,
|
||||||
|
char_class_blank,
|
||||||
|
char_class_cntrl,
|
||||||
|
char_class_digit,
|
||||||
|
char_class_digit,
|
||||||
|
char_class_graph,
|
||||||
|
char_class_horizontal,
|
||||||
|
char_class_lower,
|
||||||
|
char_class_lower,
|
||||||
|
char_class_print,
|
||||||
|
char_class_punct,
|
||||||
|
char_class_space,
|
||||||
|
char_class_space,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_unicode,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_vertical,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_xdigit,
|
||||||
|
};
|
||||||
|
|
||||||
|
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
||||||
|
if (idx < 0)
|
||||||
|
{
|
||||||
|
std::wstring s(p1, p2);
|
||||||
|
for (std::wstring::size_type i = 0; i < s.size(); ++i)
|
||||||
|
s[i] = (std::towlower)(s[i]);
|
||||||
|
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||||
|
}
|
||||||
|
BOOST_ASSERT(idx + 1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
|
||||||
|
return masks[idx + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
return
|
||||||
|
((mask & char_class_space) && (std::iswspace)(c))
|
||||||
|
|| ((mask & char_class_print) && (std::iswprint)(c))
|
||||||
|
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|
||||||
|
|| ((mask & char_class_upper) && (std::iswupper)(c))
|
||||||
|
|| ((mask & char_class_lower) && (std::iswlower)(c))
|
||||||
|
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|
||||||
|
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|
||||||
|
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|
||||||
|
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|
||||||
|
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
||||||
|
|| ((mask & char_class_word) && (c == '_'))
|
||||||
|
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|
||||||
|
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|
||||||
|
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4244)
|
||||||
|
#endif
|
||||||
|
std::string name(p1, p2);
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
name = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(name);
|
||||||
|
if (!name.empty())
|
||||||
|
return string_type(name.begin(), name.end());
|
||||||
|
if (p2 - p1 == 1)
|
||||||
|
return string_type(1, *p1);
|
||||||
|
return string_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
|
||||||
|
{
|
||||||
|
#ifdef BOOST_BORLANDC
|
||||||
|
// workaround for broken wcstol:
|
||||||
|
if ((std::iswxdigit)(c) == 0)
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
wchar_t b[2] = { c, '\0', };
|
||||||
|
wchar_t* ep;
|
||||||
|
int result = std::wcstol(b, &ep, radix);
|
||||||
|
if (ep == b)
|
||||||
|
return -1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace std{
|
|||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4103)
|
#pragma warning(disable: 4103 4244)
|
||||||
#endif
|
#endif
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
#ifdef BOOST_HAS_ABI_HEADERS
|
||||||
# include BOOST_ABI_PREFIX
|
# include BOOST_ABI_PREFIX
|
||||||
@ -47,6 +47,30 @@ namespace std{
|
|||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
|
|
||||||
|
namespace BOOST_REGEX_DETAIL_NS {
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
char_class_space = 1 << 0,
|
||||||
|
char_class_print = 1 << 1,
|
||||||
|
char_class_cntrl = 1 << 2,
|
||||||
|
char_class_upper = 1 << 3,
|
||||||
|
char_class_lower = 1 << 4,
|
||||||
|
char_class_alpha = 1 << 5,
|
||||||
|
char_class_digit = 1 << 6,
|
||||||
|
char_class_punct = 1 << 7,
|
||||||
|
char_class_xdigit = 1 << 8,
|
||||||
|
char_class_alnum = char_class_alpha | char_class_digit,
|
||||||
|
char_class_graph = char_class_alnum | char_class_punct,
|
||||||
|
char_class_blank = 1 << 9,
|
||||||
|
char_class_word = 1 << 10,
|
||||||
|
char_class_unicode = 1 << 11,
|
||||||
|
char_class_horizontal = 1 << 12,
|
||||||
|
char_class_vertical = 1 << 13
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template <class charT>
|
template <class charT>
|
||||||
struct c_regex_traits;
|
struct c_regex_traits;
|
||||||
|
|
||||||
@ -139,58 +163,334 @@ private:
|
|||||||
c_regex_traits& operator=(const c_regex_traits&);
|
c_regex_traits& operator=(const c_regex_traits&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
#endif // BOOST_NO_WREGEX
|
||||||
|
|
||||||
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
|
||||||
|
{
|
||||||
|
std::string result(10, ' ');
|
||||||
|
std::size_t s = result.size();
|
||||||
|
std::size_t r;
|
||||||
|
std::string src(p1, p2);
|
||||||
|
while (s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
|
||||||
|
{
|
||||||
|
#if defined(_CPPLIB_VER)
|
||||||
//
|
//
|
||||||
// Provide an unsigned short version as well, so the user can link to this
|
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
||||||
// no matter whether they build with /Zc:wchar_t or not (MSVC specific).
|
// to std::strxfrm, but only for certain locales :-(
|
||||||
|
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
||||||
//
|
//
|
||||||
template<>
|
if (r == INT_MAX)
|
||||||
struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
|
|
||||||
{
|
{
|
||||||
c_regex_traits(){}
|
result.erase();
|
||||||
typedef unsigned short char_type;
|
result.insert(result.begin(), static_cast<char>(0));
|
||||||
typedef std::size_t size_type;
|
return result;
|
||||||
typedef std::basic_string<unsigned short> string_type;
|
}
|
||||||
struct locale_type{};
|
#endif
|
||||||
typedef boost::uint32_t char_class_type;
|
result.append(r - s + 3, ' ');
|
||||||
|
s = result.size();
|
||||||
static size_type length(const char_type* p)
|
}
|
||||||
{
|
result.erase(r);
|
||||||
return (std::wcslen)((const wchar_t*)p);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short translate(unsigned short c) const
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
|
||||||
{
|
{
|
||||||
return c;
|
static char s_delim;
|
||||||
|
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
|
||||||
|
std::string result;
|
||||||
|
//
|
||||||
|
// What we do here depends upon the format of the sort key returned by
|
||||||
|
// sort key returned by this->transform:
|
||||||
|
//
|
||||||
|
switch (s_collate_type)
|
||||||
|
{
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
||||||
|
// the best we can do is translate to lower case, then get a regular sort key:
|
||||||
|
{
|
||||||
|
result.assign(p1, p2);
|
||||||
|
for (std::string::size_type i = 0; i < result.size(); ++i)
|
||||||
|
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
|
||||||
|
result = transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
unsigned short translate_nocase(unsigned short c) const
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
||||||
{
|
{
|
||||||
return (std::towlower)((wchar_t)c);
|
// get a regular sort key, and then truncate it:
|
||||||
|
result = transform(p1, p2);
|
||||||
|
result.erase(s_delim);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
||||||
|
// get a regular sort key, and then truncate everything after the delim:
|
||||||
|
result = transform(p1, p2);
|
||||||
|
if ((!result.empty()) && (result[0] == s_delim))
|
||||||
|
break;
|
||||||
|
std::size_t i;
|
||||||
|
for (i = 0; i < result.size(); ++i)
|
||||||
|
{
|
||||||
|
if (result[i] == s_delim)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.erase(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result.empty())
|
||||||
|
result = std::string(1, char(0));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
|
inline c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
|
||||||
static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
|
static const char_class_type masks[] =
|
||||||
static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
|
{
|
||||||
|
0,
|
||||||
static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
|
char_class_alnum,
|
||||||
static int BOOST_REGEX_CALL value(unsigned short, int);
|
char_class_alpha,
|
||||||
|
char_class_blank,
|
||||||
locale_type imbue(locale_type l)
|
char_class_cntrl,
|
||||||
{ return l; }
|
char_class_digit,
|
||||||
locale_type getloc()const
|
char_class_digit,
|
||||||
{ return locale_type(); }
|
char_class_graph,
|
||||||
|
char_class_horizontal,
|
||||||
private:
|
char_class_lower,
|
||||||
// this type is not copyable:
|
char_class_lower,
|
||||||
c_regex_traits(const c_regex_traits&);
|
char_class_print,
|
||||||
c_regex_traits& operator=(const c_regex_traits&);
|
char_class_punct,
|
||||||
|
char_class_space,
|
||||||
|
char_class_space,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_unicode,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_vertical,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_xdigit,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
||||||
|
if (idx < 0)
|
||||||
|
{
|
||||||
|
std::string s(p1, p2);
|
||||||
|
for (std::string::size_type i = 0; i < s.size(); ++i)
|
||||||
|
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
|
||||||
|
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||||
|
}
|
||||||
|
BOOST_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0]));
|
||||||
|
return masks[idx + 1];
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BOOST_NO_WREGEX
|
inline bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
return
|
||||||
|
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|
||||||
|
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
||||||
|
|| ((mask & char_class_word) && (c == '_'))
|
||||||
|
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|
||||||
|
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
|
||||||
|
{
|
||||||
|
std::string s(p1, p2);
|
||||||
|
s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s);
|
||||||
|
if (s.empty() && (p2 - p1 == 1))
|
||||||
|
s.append(1, *p1);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix)
|
||||||
|
{
|
||||||
|
char b[2] = { c, '\0', };
|
||||||
|
char* ep;
|
||||||
|
int result = std::strtol(b, &ep, radix);
|
||||||
|
if (ep == b)
|
||||||
|
return -1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_WREGEX
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
std::size_t r;
|
||||||
|
std::size_t s = 10;
|
||||||
|
std::wstring src(p1, p2);
|
||||||
|
std::wstring result(s, L' ');
|
||||||
|
while (s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
|
||||||
|
{
|
||||||
|
#if defined(_CPPLIB_VER)
|
||||||
|
//
|
||||||
|
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
||||||
|
// to std::strxfrm, but only for certain locales :-(
|
||||||
|
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
||||||
|
//
|
||||||
|
if (r == INT_MAX)
|
||||||
|
{
|
||||||
|
result.erase();
|
||||||
|
result.insert(result.begin(), static_cast<wchar_t>(0));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
result.append(r - s + 3, L' ');
|
||||||
|
s = result.size();
|
||||||
|
}
|
||||||
|
result.erase(r);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
static wchar_t s_delim;
|
||||||
|
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
|
||||||
|
std::wstring result;
|
||||||
|
//
|
||||||
|
// What we do here depends upon the format of the sort key returned by
|
||||||
|
// sort key returned by this->transform:
|
||||||
|
//
|
||||||
|
switch (s_collate_type)
|
||||||
|
{
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
||||||
|
// the best we can do is translate to lower case, then get a regular sort key:
|
||||||
|
{
|
||||||
|
result.assign(p1, p2);
|
||||||
|
for (std::wstring::size_type i = 0; i < result.size(); ++i)
|
||||||
|
result[i] = (std::towlower)(result[i]);
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
||||||
|
{
|
||||||
|
// get a regular sort key, and then truncate it:
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
result.erase(s_delim);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
||||||
|
// get a regular sort key, and then truncate everything after the delim:
|
||||||
|
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||||
|
if ((!result.empty()) && (result[0] == s_delim))
|
||||||
|
break;
|
||||||
|
std::size_t i;
|
||||||
|
for (i = 0; i < result.size(); ++i)
|
||||||
|
{
|
||||||
|
if (result[i] == s_delim)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.erase(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result.empty())
|
||||||
|
result = std::wstring(1, char(0));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
static const char_class_type masks[] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
char_class_alnum,
|
||||||
|
char_class_alpha,
|
||||||
|
char_class_blank,
|
||||||
|
char_class_cntrl,
|
||||||
|
char_class_digit,
|
||||||
|
char_class_digit,
|
||||||
|
char_class_graph,
|
||||||
|
char_class_horizontal,
|
||||||
|
char_class_lower,
|
||||||
|
char_class_lower,
|
||||||
|
char_class_print,
|
||||||
|
char_class_punct,
|
||||||
|
char_class_space,
|
||||||
|
char_class_space,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_unicode,
|
||||||
|
char_class_upper,
|
||||||
|
char_class_vertical,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_alnum | char_class_word,
|
||||||
|
char_class_xdigit,
|
||||||
|
};
|
||||||
|
|
||||||
|
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
||||||
|
if (idx < 0)
|
||||||
|
{
|
||||||
|
std::wstring s(p1, p2);
|
||||||
|
for (std::wstring::size_type i = 0; i < s.size(); ++i)
|
||||||
|
s[i] = (std::towlower)(s[i]);
|
||||||
|
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||||
|
}
|
||||||
|
BOOST_ASSERT(idx + 1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
|
||||||
|
return masks[idx + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
|
||||||
|
{
|
||||||
|
using namespace BOOST_REGEX_DETAIL_NS;
|
||||||
|
return
|
||||||
|
((mask & char_class_space) && (std::iswspace)(c))
|
||||||
|
|| ((mask & char_class_print) && (std::iswprint)(c))
|
||||||
|
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|
||||||
|
|| ((mask & char_class_upper) && (std::iswupper)(c))
|
||||||
|
|| ((mask & char_class_lower) && (std::iswlower)(c))
|
||||||
|
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|
||||||
|
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|
||||||
|
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|
||||||
|
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|
||||||
|
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
||||||
|
|| ((mask & char_class_word) && (c == '_'))
|
||||||
|
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|
||||||
|
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|
||||||
|
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
|
||||||
|
{
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4244)
|
||||||
|
#endif
|
||||||
|
std::string name(p1, p2);
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
name = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(name);
|
||||||
|
if (!name.empty())
|
||||||
|
return string_type(name.begin(), name.end());
|
||||||
|
if (p2 - p1 == 1)
|
||||||
|
return string_type(1, *p1);
|
||||||
|
return string_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
|
||||||
|
{
|
||||||
|
#ifdef BOOST_BORLANDC
|
||||||
|
// workaround for broken wcstol:
|
||||||
|
if ((std::iswxdigit)(c) == 0)
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
wchar_t b[2] = { c, '\0', };
|
||||||
|
wchar_t* ep;
|
||||||
|
int result = std::wcstol(b, &ep, radix);
|
||||||
|
if (ep == b)
|
||||||
|
return -1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +103,11 @@ struct default_wrapper : public BaseT
|
|||||||
}
|
}
|
||||||
::boost::regex_constants::syntax_type syntax_type(char_type c)const
|
::boost::regex_constants::syntax_type syntax_type(char_type c)const
|
||||||
{
|
{
|
||||||
return ((c & 0x7f) == c) ? get_default_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::syntax_char;
|
return (char_type(c & 0x7f) == c) ? get_default_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::syntax_char;
|
||||||
}
|
}
|
||||||
::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const
|
::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const
|
||||||
{
|
{
|
||||||
return ((c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::escape_type_identity;
|
return (char_type(c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::escape_type_identity;
|
||||||
}
|
}
|
||||||
boost::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const
|
boost::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const
|
||||||
{
|
{
|
||||||
|
@ -1,205 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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: c_regex_traits.cpp
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: Implements out of line c_regex_traits<char> members
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include "internals.hpp"
|
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x560)
|
|
||||||
|
|
||||||
#include <boost/regex/v4/c_regex_traits.hpp>
|
|
||||||
#include <boost/regex/v4/primary_transform.hpp>
|
|
||||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
|
||||||
namespace std{
|
|
||||||
using ::strxfrm; using ::isspace;
|
|
||||||
using ::ispunct; using ::isalpha;
|
|
||||||
using ::isalnum; using ::iscntrl;
|
|
||||||
using ::isprint; using ::isupper;
|
|
||||||
using ::islower; using ::isdigit;
|
|
||||||
using ::isxdigit; using ::strtol;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
|
||||||
# include BOOST_ABI_PREFIX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
|
|
||||||
{
|
|
||||||
std::string result(10, ' ');
|
|
||||||
std::size_t s = result.size();
|
|
||||||
std::size_t r;
|
|
||||||
std::string src(p1, p2);
|
|
||||||
while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
|
|
||||||
{
|
|
||||||
#if defined(_CPPLIB_VER)
|
|
||||||
//
|
|
||||||
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
|
||||||
// to std::strxfrm, but only for certain locales :-(
|
|
||||||
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
|
||||||
//
|
|
||||||
if(r == INT_MAX)
|
|
||||||
{
|
|
||||||
result.erase();
|
|
||||||
result.insert(result.begin(), static_cast<char>(0));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
result.append(r - s + 3, ' ');
|
|
||||||
s = result.size();
|
|
||||||
}
|
|
||||||
result.erase(r);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
|
|
||||||
{
|
|
||||||
static char s_delim;
|
|
||||||
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
|
|
||||||
std::string result;
|
|
||||||
//
|
|
||||||
// What we do here depends upon the format of the sort key returned by
|
|
||||||
// sort key returned by this->transform:
|
|
||||||
//
|
|
||||||
switch(s_collate_type)
|
|
||||||
{
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
|
||||||
// the best we can do is translate to lower case, then get a regular sort key:
|
|
||||||
{
|
|
||||||
result.assign(p1, p2);
|
|
||||||
for(std::string::size_type i = 0; i < result.size(); ++i)
|
|
||||||
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
|
|
||||||
result = transform(&*result.begin(), &*result.begin() + result.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
|
||||||
{
|
|
||||||
// get a regular sort key, and then truncate it:
|
|
||||||
result = transform(p1, p2);
|
|
||||||
result.erase(s_delim);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
|
||||||
// get a regular sort key, and then truncate everything after the delim:
|
|
||||||
result = transform(p1, p2);
|
|
||||||
if((!result.empty()) && (result[0] == s_delim))
|
|
||||||
break;
|
|
||||||
std::size_t i;
|
|
||||||
for(i = 0; i < result.size(); ++i)
|
|
||||||
{
|
|
||||||
if(result[i] == s_delim)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
result.erase(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(result.empty())
|
|
||||||
result = std::string(1, char(0));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
|
|
||||||
{
|
|
||||||
static const char_class_type masks[] =
|
|
||||||
{
|
|
||||||
0,
|
|
||||||
char_class_alnum,
|
|
||||||
char_class_alpha,
|
|
||||||
char_class_blank,
|
|
||||||
char_class_cntrl,
|
|
||||||
char_class_digit,
|
|
||||||
char_class_digit,
|
|
||||||
char_class_graph,
|
|
||||||
char_class_horizontal,
|
|
||||||
char_class_lower,
|
|
||||||
char_class_lower,
|
|
||||||
char_class_print,
|
|
||||||
char_class_punct,
|
|
||||||
char_class_space,
|
|
||||||
char_class_space,
|
|
||||||
char_class_upper,
|
|
||||||
char_class_unicode,
|
|
||||||
char_class_upper,
|
|
||||||
char_class_vertical,
|
|
||||||
char_class_alnum | char_class_word,
|
|
||||||
char_class_alnum | char_class_word,
|
|
||||||
char_class_xdigit,
|
|
||||||
};
|
|
||||||
|
|
||||||
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
|
||||||
if(idx < 0)
|
|
||||||
{
|
|
||||||
std::string s(p1, p2);
|
|
||||||
for(std::string::size_type i = 0; i < s.size(); ++i)
|
|
||||||
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
|
|
||||||
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
|
||||||
}
|
|
||||||
BOOST_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0]));
|
|
||||||
return masks[idx+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|
|
||||||
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
|
||||||
|| ((mask & char_class_word) && (c == '_'))
|
|
||||||
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|
|
||||||
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
|
|
||||||
{
|
|
||||||
std::string s(p1, p2);
|
|
||||||
s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s);
|
|
||||||
if(s.empty() && (p2-p1 == 1))
|
|
||||||
s.append(1, *p1);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix)
|
|
||||||
{
|
|
||||||
char b[2] = { c, '\0', };
|
|
||||||
char* ep;
|
|
||||||
int result = std::strtol(b, &ep, radix);
|
|
||||||
if(ep == b)
|
|
||||||
return -1;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
|
||||||
# include BOOST_ABI_SUFFIX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
933
src/fileiter.cpp
933
src/fileiter.cpp
@ -1,933 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2002
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: Implements file io primitives + directory searching for class boost::RegEx.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <climits>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
#include <boost/throw_exception.hpp>
|
|
||||||
#include <boost/regex/v4/fileiter.hpp>
|
|
||||||
#include <boost/regex/v4/regex_workaround.hpp>
|
|
||||||
#include <boost/regex/pattern_except.hpp>
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
|
||||||
namespace std{
|
|
||||||
using ::sprintf;
|
|
||||||
using ::fseek;
|
|
||||||
using ::fread;
|
|
||||||
using ::ftell;
|
|
||||||
using ::fopen;
|
|
||||||
using ::fclose;
|
|
||||||
using ::FILE;
|
|
||||||
using ::strcpy;
|
|
||||||
using ::strcpy;
|
|
||||||
using ::strcat;
|
|
||||||
using ::strcmp;
|
|
||||||
using ::strlen;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_REGEX_NO_FILEITER
|
|
||||||
|
|
||||||
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
|
|
||||||
#include <sys/cygwin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
|
||||||
# pragma warning(disable: 4800)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
namespace BOOST_REGEX_DETAIL_NS{
|
|
||||||
// start with the operating system specific stuff:
|
|
||||||
|
|
||||||
#if (defined(BOOST_BORLANDC) || defined(BOOST_REGEX_FI_WIN32_DIR) || defined(BOOST_MSVC)) && !defined(BOOST_RE_NO_WIN32)
|
|
||||||
|
|
||||||
// platform is DOS or Windows
|
|
||||||
// directories are separated with '\\'
|
|
||||||
// and names are insensitive of case
|
|
||||||
|
|
||||||
BOOST_REGEX_DECL const char* _fi_sep = "\\";
|
|
||||||
const char* _fi_sep_alt = "/";
|
|
||||||
#define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// platform is not DOS or Windows
|
|
||||||
// directories are separated with '/'
|
|
||||||
// and names are sensitive of case
|
|
||||||
|
|
||||||
BOOST_REGEX_DECL const char* _fi_sep = "/";
|
|
||||||
const char* _fi_sep_alt = _fi_sep;
|
|
||||||
#define BOOST_REGEX_FI_TRANSLATE(c) c
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_FI_WIN32_MAP
|
|
||||||
|
|
||||||
void mapfile::open(const char* file)
|
|
||||||
{
|
|
||||||
#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);
|
|
||||||
#else
|
|
||||||
hfile = CreateFileA(file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
|
||||||
#endif
|
|
||||||
if(hfile != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
hmap = CreateFileMapping(hfile, 0, PAGE_READONLY, 0, 0, 0);
|
|
||||||
if((hmap == INVALID_HANDLE_VALUE) || (hmap == NULL))
|
|
||||||
{
|
|
||||||
CloseHandle(hfile);
|
|
||||||
hmap = 0;
|
|
||||||
hfile = 0;
|
|
||||||
std::runtime_error err("Unable to create file mapping.");
|
|
||||||
boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
|
|
||||||
if (_first == 0)
|
|
||||||
{
|
|
||||||
CloseHandle(hmap);
|
|
||||||
CloseHandle(hfile);
|
|
||||||
hmap = 0;
|
|
||||||
hfile = 0;
|
|
||||||
std::runtime_error err("Unable to create file mapping.");
|
|
||||||
boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_last = _first + GetFileSize(hfile, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hfile = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
throw std::runtime_error("Unable to open file.");
|
|
||||||
#else
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(hfile != INVALID_HANDLE_VALUE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mapfile::close()
|
|
||||||
{
|
|
||||||
if(hfile != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
UnmapViewOfFile((void*)_first);
|
|
||||||
CloseHandle(hmap);
|
|
||||||
CloseHandle(hfile);
|
|
||||||
hmap = hfile = 0;
|
|
||||||
_first = _last = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif !defined(BOOST_RE_NO_STL)
|
|
||||||
|
|
||||||
mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
|
|
||||||
{
|
|
||||||
if(file && node)
|
|
||||||
file->unlock(node);
|
|
||||||
file = i.file;
|
|
||||||
node = i.node;
|
|
||||||
offset = i.offset;
|
|
||||||
if(file)
|
|
||||||
file->lock(node);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator& mapfile_iterator::operator++ ()
|
|
||||||
{
|
|
||||||
if((++offset == mapfile::buf_size) && file)
|
|
||||||
{
|
|
||||||
++node;
|
|
||||||
offset = 0;
|
|
||||||
file->lock(node);
|
|
||||||
file->unlock(node-1);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator mapfile_iterator::operator++ (int)
|
|
||||||
{
|
|
||||||
mapfile_iterator temp(*this);
|
|
||||||
if((++offset == mapfile::buf_size) && file)
|
|
||||||
{
|
|
||||||
++node;
|
|
||||||
offset = 0;
|
|
||||||
file->lock(node);
|
|
||||||
file->unlock(node-1);
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator& mapfile_iterator::operator-- ()
|
|
||||||
{
|
|
||||||
if((offset == 0) && file)
|
|
||||||
{
|
|
||||||
--node;
|
|
||||||
offset = mapfile::buf_size - 1;
|
|
||||||
file->lock(node);
|
|
||||||
file->unlock(node + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
--offset;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator mapfile_iterator::operator-- (int)
|
|
||||||
{
|
|
||||||
mapfile_iterator temp(*this);
|
|
||||||
if((offset == 0) && file)
|
|
||||||
{
|
|
||||||
--node;
|
|
||||||
offset = mapfile::buf_size - 1;
|
|
||||||
file->lock(node);
|
|
||||||
file->unlock(node + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
--offset;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator operator + (const mapfile_iterator& i, long off)
|
|
||||||
{
|
|
||||||
mapfile_iterator temp(i);
|
|
||||||
temp += off;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile_iterator operator - (const mapfile_iterator& i, long off)
|
|
||||||
{
|
|
||||||
mapfile_iterator temp(i);
|
|
||||||
temp -= off;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile::iterator mapfile::begin()const
|
|
||||||
{
|
|
||||||
return mapfile_iterator(this, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile::iterator mapfile::end()const
|
|
||||||
{
|
|
||||||
return mapfile_iterator(this, _size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mapfile::lock(pointer* node)const
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(node >= _first);
|
|
||||||
BOOST_ASSERT(node <= _last);
|
|
||||||
if(node < _last)
|
|
||||||
{
|
|
||||||
if(*node == 0)
|
|
||||||
{
|
|
||||||
if(condemed.empty())
|
|
||||||
{
|
|
||||||
*node = new char[sizeof(int) + buf_size];
|
|
||||||
*(reinterpret_cast<int*>(*node)) = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pointer* p = condemed.front();
|
|
||||||
condemed.pop_front();
|
|
||||||
*node = *p;
|
|
||||||
*p = 0;
|
|
||||||
*(reinterpret_cast<int*>(*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);
|
|
||||||
else
|
|
||||||
read_size = std::fread(*node + sizeof(int), buf_size, 1, hfile);
|
|
||||||
if((read_size == 0) || (std::ferror(hfile)))
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(*reinterpret_cast<int*>(*node) == 0)
|
|
||||||
{
|
|
||||||
*reinterpret_cast<int*>(*node) = 1;
|
|
||||||
condemed.remove(node);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++(*reinterpret_cast<int*>(*node));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mapfile::unlock(pointer* node)const
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(node >= _first);
|
|
||||||
BOOST_ASSERT(node <= _last);
|
|
||||||
if(node < _last)
|
|
||||||
{
|
|
||||||
if(--(*reinterpret_cast<int*>(*node)) == 0)
|
|
||||||
{
|
|
||||||
condemed.push_back(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long int get_file_length(std::FILE* hfile)
|
|
||||||
{
|
|
||||||
long int result;
|
|
||||||
std::fseek(hfile, 0, SEEK_END);
|
|
||||||
result = std::ftell(hfile);
|
|
||||||
std::fseek(hfile, 0, SEEK_SET);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void mapfile::open(const char* file)
|
|
||||||
{
|
|
||||||
hfile = std::fopen(file, "rb");
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
if(hfile != 0)
|
|
||||||
{
|
|
||||||
_size = get_file_length(hfile);
|
|
||||||
long cnodes = (_size + buf_size - 1) / buf_size;
|
|
||||||
|
|
||||||
// check that number of nodes is not too high:
|
|
||||||
if(cnodes > (long)((INT_MAX) / sizeof(pointer*)))
|
|
||||||
{
|
|
||||||
std::fclose(hfile);
|
|
||||||
hfile = 0;
|
|
||||||
_size = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_first = new pointer[(int)cnodes];
|
|
||||||
_last = _first + cnodes;
|
|
||||||
std::memset(_first, 0, cnodes*sizeof(pointer));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::runtime_error err("Unable to open file.");
|
|
||||||
}
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}catch(...)
|
|
||||||
{ close(); throw; }
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void mapfile::close()
|
|
||||||
{
|
|
||||||
if(hfile != 0)
|
|
||||||
{
|
|
||||||
pointer* p = _first;
|
|
||||||
while(p != _last)
|
|
||||||
{
|
|
||||||
if(*p)
|
|
||||||
delete[] *p;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
delete[] _first;
|
|
||||||
_size = 0;
|
|
||||||
_first = _last = 0;
|
|
||||||
std::fclose(hfile);
|
|
||||||
hfile = 0;
|
|
||||||
condemed.erase(condemed.begin(), condemed.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#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)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(1);
|
|
||||||
#else
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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()
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
ptr = _path;
|
|
||||||
*_path = 0;
|
|
||||||
*_root = 0;
|
|
||||||
ref = new file_iterator_ref();
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
|
||||||
ref->hf = _fi_invalid_handle;
|
|
||||||
ref->count = 1;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
delete ref;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
file_iterator::file_iterator(const char* wild)
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, wild));
|
|
||||||
ptr = _root;
|
|
||||||
while(*ptr)++ptr;
|
|
||||||
while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr;
|
|
||||||
if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) )
|
|
||||||
{
|
|
||||||
_root[1]='\0';
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ptr = 0;
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
|
|
||||||
if(*_path == 0)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, "."));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcat_s(_path, MAX_PATH, _fi_sep));
|
|
||||||
}
|
|
||||||
ptr = _path + std::strlen(_path);
|
|
||||||
|
|
||||||
ref = new file_iterator_ref();
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
|
||||||
ref->hf = find_first_file(wild, ref->_data);
|
|
||||||
ref->count = 1;
|
|
||||||
|
|
||||||
if(ref->hf == _fi_invalid_handle)
|
|
||||||
{
|
|
||||||
*_path = 0;
|
|
||||||
ptr = _path;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
copy_find_file_result_with_overflow_check(ref->_data, ptr, (MAX_PATH - (ptr - _path)));
|
|
||||||
if(ref->_data.dwFileAttributes & _fi_dir)
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
delete ref;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
file_iterator::file_iterator(const file_iterator& other)
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, other._path));
|
|
||||||
ptr = _path + (other.ptr - other._path);
|
|
||||||
ref = other.ref;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
++(ref->count);
|
|
||||||
}
|
|
||||||
|
|
||||||
file_iterator& file_iterator::operator=(const file_iterator& other)
|
|
||||||
{
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, other._path));
|
|
||||||
ptr = _path + (other.ptr - other._path);
|
|
||||||
if(--(ref->count) == 0)
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
FindClose(ref->hf);
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
ref = other.ref;
|
|
||||||
++(ref->count);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
file_iterator::~file_iterator()
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
if(--(ref->count) == 0)
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
FindClose(ref->hf);
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file_iterator file_iterator::operator++(int)
|
|
||||||
{
|
|
||||||
file_iterator temp(*this);
|
|
||||||
next();
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void file_iterator::next()
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
{
|
|
||||||
bool cont = true;
|
|
||||||
while(cont)
|
|
||||||
{
|
|
||||||
cont = find_next_file(ref->hf, ref->_data);
|
|
||||||
if(cont && ((ref->_data.dwFileAttributes & _fi_dir) == 0))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(!cont)
|
|
||||||
{
|
|
||||||
// end of sequence
|
|
||||||
FindClose(ref->hf);
|
|
||||||
ref->hf = _fi_invalid_handle;
|
|
||||||
*_path = 0;
|
|
||||||
ptr = _path;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
directory_iterator::directory_iterator()
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
ptr = _path;
|
|
||||||
*_path = 0;
|
|
||||||
*_root = 0;
|
|
||||||
ref = new file_iterator_ref();
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
|
||||||
ref->hf = _fi_invalid_handle;
|
|
||||||
ref->count = 1;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
delete ref;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
directory_iterator::directory_iterator(const char* wild)
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, wild));
|
|
||||||
ptr = _root;
|
|
||||||
while(*ptr)++ptr;
|
|
||||||
while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr;
|
|
||||||
|
|
||||||
if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) )
|
|
||||||
{
|
|
||||||
_root[1]='\0';
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ptr = 0;
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
|
|
||||||
if(*_path == 0)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, "."));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcat_s(_path, MAX_PATH, _fi_sep));
|
|
||||||
}
|
|
||||||
ptr = _path + std::strlen(_path);
|
|
||||||
|
|
||||||
ref = new file_iterator_ref();
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
|
||||||
ref->count = 1;
|
|
||||||
ref->hf = find_first_file(wild, ref->_data);
|
|
||||||
if(ref->hf == _fi_invalid_handle)
|
|
||||||
{
|
|
||||||
*_path = 0;
|
|
||||||
ptr = _path;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
delete ref;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
directory_iterator::~directory_iterator()
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
if(--(ref->count) == 0)
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
FindClose(ref->hf);
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
directory_iterator::directory_iterator(const directory_iterator& other)
|
|
||||||
{
|
|
||||||
_root = _path = 0;
|
|
||||||
ref = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
try{
|
|
||||||
#endif
|
|
||||||
_root = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
|
||||||
_path = new char[MAX_PATH];
|
|
||||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, other._path));
|
|
||||||
ptr = _path + (other.ptr - other._path);
|
|
||||||
ref = other.ref;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
delete[] _root;
|
|
||||||
delete[] _path;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
++(ref->count);
|
|
||||||
}
|
|
||||||
|
|
||||||
directory_iterator& directory_iterator::operator=(const directory_iterator& other)
|
|
||||||
{
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
|
|
||||||
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, other._path));
|
|
||||||
ptr = _path + (other.ptr - other._path);
|
|
||||||
if(--(ref->count) == 0)
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
FindClose(ref->hf);
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
ref = other.ref;
|
|
||||||
++(ref->count);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
directory_iterator directory_iterator::operator++(int)
|
|
||||||
{
|
|
||||||
directory_iterator temp(*this);
|
|
||||||
next();
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void directory_iterator::next()
|
|
||||||
{
|
|
||||||
if(ref->hf != _fi_invalid_handle)
|
|
||||||
{
|
|
||||||
bool cont = true;
|
|
||||||
while(cont)
|
|
||||||
{
|
|
||||||
cont = find_next_file(ref->hf, ref->_data);
|
|
||||||
if(cont && (ref->_data.dwFileAttributes & _fi_dir))
|
|
||||||
{
|
|
||||||
if(is_not_current_or_parent_path_string(ref->_data))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!cont)
|
|
||||||
{
|
|
||||||
// end of sequence
|
|
||||||
FindClose(ref->hf);
|
|
||||||
ref->hf = _fi_invalid_handle;
|
|
||||||
*_path = 0;
|
|
||||||
ptr = _path;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_FI_POSIX_DIR
|
|
||||||
|
|
||||||
struct _fi_priv_data
|
|
||||||
{
|
|
||||||
char root[MAX_PATH];
|
|
||||||
char* mask;
|
|
||||||
DIR* d;
|
|
||||||
_fi_priv_data(const char* p);
|
|
||||||
};
|
|
||||||
|
|
||||||
_fi_priv_data::_fi_priv_data(const char* p)
|
|
||||||
{
|
|
||||||
std::strcpy(root, p);
|
|
||||||
mask = root;
|
|
||||||
while(*mask) ++mask;
|
|
||||||
while((mask > root) && (*mask != *_fi_sep) && (*mask != *_fi_sep_alt)) --mask;
|
|
||||||
if(mask == root && ((*mask== *_fi_sep) || (*mask == *_fi_sep_alt)) )
|
|
||||||
{
|
|
||||||
root[1] = '\0';
|
|
||||||
std::strcpy(root+2, p+1);
|
|
||||||
mask = root+2;
|
|
||||||
}
|
|
||||||
else if(mask == root)
|
|
||||||
{
|
|
||||||
root[0] = '.';
|
|
||||||
root[1] = '\0';
|
|
||||||
std::strcpy(root+2, p);
|
|
||||||
mask = root+2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*mask = 0;
|
|
||||||
++mask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool iswild(const char* mask, const char* name)
|
|
||||||
{
|
|
||||||
while(*mask && *name)
|
|
||||||
{
|
|
||||||
switch(*mask)
|
|
||||||
{
|
|
||||||
case '?':
|
|
||||||
++name;
|
|
||||||
++mask;
|
|
||||||
continue;
|
|
||||||
case '*':
|
|
||||||
++mask;
|
|
||||||
if(*mask == 0)
|
|
||||||
return true;
|
|
||||||
while(*name)
|
|
||||||
{
|
|
||||||
if(iswild(mask, name))
|
|
||||||
return true;
|
|
||||||
++name;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case '.':
|
|
||||||
if(0 == *name)
|
|
||||||
{
|
|
||||||
++mask;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
default:
|
|
||||||
if(BOOST_REGEX_FI_TRANSLATE(*mask) != BOOST_REGEX_FI_TRANSLATE(*name))
|
|
||||||
return false;
|
|
||||||
++mask;
|
|
||||||
++name;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(*mask != *name)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned _fi_attributes(const char* root, const char* name)
|
|
||||||
{
|
|
||||||
char buf[MAX_PATH];
|
|
||||||
// verify that we can not overflow:
|
|
||||||
if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH)
|
|
||||||
return 0;
|
|
||||||
int r;
|
|
||||||
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
|
|
||||||
r = (std::sprintf)(buf, "%s%s", root, name);
|
|
||||||
else
|
|
||||||
r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
|
||||||
if(r < 0)
|
|
||||||
return 0; // sprintf failed
|
|
||||||
DIR* d = opendir(buf);
|
|
||||||
if(d)
|
|
||||||
{
|
|
||||||
closedir(d);
|
|
||||||
return _fi_dir;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData)
|
|
||||||
{
|
|
||||||
_fi_find_handle dat = new _fi_priv_data(lpFileName);
|
|
||||||
|
|
||||||
DIR* h = opendir(dat->root);
|
|
||||||
dat->d = h;
|
|
||||||
if(h != 0)
|
|
||||||
{
|
|
||||||
if(_fi_FindNextFile(dat, lpFindFileData))
|
|
||||||
return dat;
|
|
||||||
closedir(h);
|
|
||||||
}
|
|
||||||
delete dat;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
|
|
||||||
{
|
|
||||||
dirent* d;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
d = readdir(dat->d);
|
|
||||||
} while(d && !iswild(dat->mask, d->d_name));
|
|
||||||
|
|
||||||
if(d)
|
|
||||||
{
|
|
||||||
std::strcpy(lpFindFileData->cFileName, d->d_name);
|
|
||||||
lpFindFileData->dwFileAttributes = _fi_attributes(dat->root, d->d_name);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _fi_FindClose(_fi_find_handle dat)
|
|
||||||
{
|
|
||||||
closedir(dat->d);
|
|
||||||
delete dat;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace BOOST_REGEX_DETAIL_NS
|
|
||||||
} // namspace boost
|
|
||||||
|
|
||||||
#endif // BOOST_REGEX_NO_FILEITER
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2002
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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: instances.cpp
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: regex narrow character template instances.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
|
|
||||||
#include <boost/regex/config.hpp>
|
|
||||||
|
|
||||||
#if !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
|
|
||||||
#define BOOST_REGEX_NARROW_INSTANTIATE
|
|
||||||
|
|
||||||
#ifdef BOOST_BORLANDC
|
|
||||||
#pragma hrdstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2002
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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: winstances.cpp
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: regex unsigned short template instances (MSVC only).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4506) // 'no definition for inline function'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
|
|
||||||
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))\
|
|
||||||
&& BOOST_WORKAROUND(BOOST_MSVC, <1600)
|
|
||||||
//
|
|
||||||
// This is a horrible workaround, but without declaring these symbols extern we get
|
|
||||||
// duplicate symbol errors when linking if the application is built without
|
|
||||||
// /Zc:wchar_t
|
|
||||||
//
|
|
||||||
#ifdef _CRTIMP2_PURE
|
|
||||||
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE
|
|
||||||
#else
|
|
||||||
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std{
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>;
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >;
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
|
|
||||||
template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const unsigned short *,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const unsigned short *);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/regex/config.hpp>
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
|
|
||||||
#define BOOST_REGEX_US_INSTANTIATE
|
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,313 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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: wc_regex_traits.cpp
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: Implements out of line members for c_regex_traits<wchar_t>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include "internals.hpp"
|
|
||||||
|
|
||||||
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
|
|
||||||
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))\
|
|
||||||
&& BOOST_WORKAROUND(BOOST_MSVC, <1600)
|
|
||||||
//
|
|
||||||
// This is a horrible workaround, but without declaring these symbols extern we get
|
|
||||||
// duplicate symbol errors when linking if the application is built without
|
|
||||||
// /Zc:wchar_t
|
|
||||||
//
|
|
||||||
#ifdef _CRTIMP2_PURE
|
|
||||||
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE
|
|
||||||
#else
|
|
||||||
# define BOOST_REGEX_STDLIB_DECL _CRTIMP2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std{
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>;
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >;
|
|
||||||
template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
|
|
||||||
template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const unsigned short *,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const unsigned short *);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>(
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/regex/config.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x560)
|
|
||||||
|
|
||||||
#include <boost/regex/v4/c_regex_traits.hpp>
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
#include <boost/regex/v4/primary_transform.hpp>
|
|
||||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
|
||||||
namespace std{
|
|
||||||
using ::wcstol;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
|
|
||||||
{
|
|
||||||
std::size_t r;
|
|
||||||
std::size_t s = 10;
|
|
||||||
std::wstring src(p1, p2);
|
|
||||||
std::wstring result(s, L' ');
|
|
||||||
while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
|
|
||||||
{
|
|
||||||
#if defined(_CPPLIB_VER)
|
|
||||||
//
|
|
||||||
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
|
|
||||||
// to std::strxfrm, but only for certain locales :-(
|
|
||||||
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
|
|
||||||
//
|
|
||||||
if(r == INT_MAX)
|
|
||||||
{
|
|
||||||
result.erase();
|
|
||||||
result.insert(result.begin(), static_cast<wchar_t>(0));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
result.append(r - s + 3, L' ');
|
|
||||||
s = result.size();
|
|
||||||
}
|
|
||||||
result.erase(r);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
|
|
||||||
{
|
|
||||||
static wchar_t s_delim;
|
|
||||||
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
|
|
||||||
std::wstring result;
|
|
||||||
//
|
|
||||||
// What we do here depends upon the format of the sort key returned by
|
|
||||||
// sort key returned by this->transform:
|
|
||||||
//
|
|
||||||
switch(s_collate_type)
|
|
||||||
{
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
|
|
||||||
// the best we can do is translate to lower case, then get a regular sort key:
|
|
||||||
{
|
|
||||||
result.assign(p1, p2);
|
|
||||||
for(std::wstring::size_type i = 0; i < result.size(); ++i)
|
|
||||||
result[i] = (std::towlower)(result[i]);
|
|
||||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
|
|
||||||
{
|
|
||||||
// get a regular sort key, and then truncate it:
|
|
||||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
|
||||||
result.erase(s_delim);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
|
|
||||||
// get a regular sort key, and then truncate everything after the delim:
|
|
||||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
|
||||||
if((!result.empty()) && (result[0] == s_delim))
|
|
||||||
break;
|
|
||||||
std::size_t i;
|
|
||||||
for(i = 0; i < result.size(); ++i)
|
|
||||||
{
|
|
||||||
if(result[i] == s_delim)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
result.erase(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(result.empty())
|
|
||||||
result = std::wstring(1, char(0));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
|
|
||||||
{
|
|
||||||
static const char_class_type masks[] =
|
|
||||||
{
|
|
||||||
0,
|
|
||||||
char_class_alnum,
|
|
||||||
char_class_alpha,
|
|
||||||
char_class_blank,
|
|
||||||
char_class_cntrl,
|
|
||||||
char_class_digit,
|
|
||||||
char_class_digit,
|
|
||||||
char_class_graph,
|
|
||||||
char_class_horizontal,
|
|
||||||
char_class_lower,
|
|
||||||
char_class_lower,
|
|
||||||
char_class_print,
|
|
||||||
char_class_punct,
|
|
||||||
char_class_space,
|
|
||||||
char_class_space,
|
|
||||||
char_class_upper,
|
|
||||||
char_class_unicode,
|
|
||||||
char_class_upper,
|
|
||||||
char_class_vertical,
|
|
||||||
char_class_alnum | char_class_word,
|
|
||||||
char_class_alnum | char_class_word,
|
|
||||||
char_class_xdigit,
|
|
||||||
};
|
|
||||||
|
|
||||||
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
|
|
||||||
if(idx < 0)
|
|
||||||
{
|
|
||||||
std::wstring s(p1, p2);
|
|
||||||
for(std::wstring::size_type i = 0; i < s.size(); ++i)
|
|
||||||
s[i] = (std::towlower)(s[i]);
|
|
||||||
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
|
||||||
}
|
|
||||||
BOOST_ASSERT(idx+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
|
|
||||||
return masks[idx+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
((mask & char_class_space) && (std::iswspace)(c))
|
|
||||||
|| ((mask & char_class_print) && (std::iswprint)(c))
|
|
||||||
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|
|
||||||
|| ((mask & char_class_upper) && (std::iswupper)(c))
|
|
||||||
|| ((mask & char_class_lower) && (std::iswlower)(c))
|
|
||||||
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|
|
||||||
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|
|
||||||
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|
|
||||||
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|
|
||||||
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|
|
||||||
|| ((mask & char_class_word) && (c == '_'))
|
|
||||||
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|
|
||||||
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|
|
||||||
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
|
|
||||||
{
|
|
||||||
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
|
||||||
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
|
|
||||||
&& !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551)
|
|
||||||
std::string name(p1, p2);
|
|
||||||
#else
|
|
||||||
std::string name;
|
|
||||||
const wchar_t* p0 = p1;
|
|
||||||
while(p0 != p2)
|
|
||||||
name.append(1, char(*p0++));
|
|
||||||
#endif
|
|
||||||
name = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(name);
|
|
||||||
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
|
||||||
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
|
|
||||||
&& !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551)
|
|
||||||
if(!name.empty())
|
|
||||||
return string_type(name.begin(), name.end());
|
|
||||||
#else
|
|
||||||
if(name.size())
|
|
||||||
{
|
|
||||||
string_type result;
|
|
||||||
typedef std::string::const_iterator iter;
|
|
||||||
iter b = name.begin();
|
|
||||||
iter e = name.end();
|
|
||||||
while(b != e)
|
|
||||||
result.append(1, wchar_t(*b++));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(p2 - p1 == 1)
|
|
||||||
return string_type(1, *p1);
|
|
||||||
return string_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
|
|
||||||
{
|
|
||||||
#ifdef BOOST_BORLANDC
|
|
||||||
// workaround for broken wcstol:
|
|
||||||
if((std::iswxdigit)(c) == 0)
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
wchar_t b[2] = { c, '\0', };
|
|
||||||
wchar_t* ep;
|
|
||||||
int result = std::wcstol(b, &ep, radix);
|
|
||||||
if(ep == b)
|
|
||||||
return -1;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
|
||||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform(const unsigned short* p1, const unsigned short* p2)
|
|
||||||
{
|
|
||||||
std::wstring result = c_regex_traits<wchar_t>::transform((const wchar_t*)p1, (const wchar_t*)p2);
|
|
||||||
return string_type(result.begin(), result.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform_primary(const unsigned short* p1, const unsigned short* p2)
|
|
||||||
{
|
|
||||||
std::wstring result = c_regex_traits<wchar_t>::transform_primary((const wchar_t*)p1, (const wchar_t*)p2);
|
|
||||||
return string_type(result.begin(), result.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<unsigned short>::char_class_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_classname(const unsigned short* p1, const unsigned short* p2)
|
|
||||||
{
|
|
||||||
return c_regex_traits<wchar_t>::lookup_classname((const wchar_t*)p1, (const wchar_t*)p2);
|
|
||||||
}
|
|
||||||
|
|
||||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_collatename(const unsigned short* p1, const unsigned short* p2)
|
|
||||||
{
|
|
||||||
std::wstring result = c_regex_traits<wchar_t>::lookup_collatename((const wchar_t*)p1, (const wchar_t*)p2);
|
|
||||||
return string_type(result.begin(), result.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BOOST_REGEX_CALL c_regex_traits<unsigned short>::isctype(unsigned short c, char_class_type m)
|
|
||||||
{
|
|
||||||
return c_regex_traits<wchar_t>::isctype(c, m);
|
|
||||||
}
|
|
||||||
|
|
||||||
int BOOST_REGEX_CALL c_regex_traits<unsigned short>::value(unsigned short c, int radix)
|
|
||||||
{
|
|
||||||
return c_regex_traits<wchar_t>::value(c, radix);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_NO_WREGEX
|
|
||||||
|
|
||||||
#endif // BOOST_BORLANDC
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2002
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* 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: winstances.cpp
|
|
||||||
* VERSION: see <boost/version.hpp>
|
|
||||||
* DESCRIPTION: regex wide character template instances.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
|
|
||||||
#include <boost/regex/config.hpp>
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
|
|
||||||
#define BOOST_REGEX_WIDE_INSTANTIATE
|
|
||||||
|
|
||||||
#ifdef BOOST_BORLANDC
|
|
||||||
#pragma hrdstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,31 +60,6 @@ test_overloads.cpp
|
|||||||
test_operators.cpp
|
test_operators.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
lib boost_regex_recursive :
|
|
||||||
../src/c_regex_traits.cpp
|
|
||||||
../src/cpp_regex_traits.cpp
|
|
||||||
../src/cregex.cpp
|
|
||||||
../src/fileiter.cpp
|
|
||||||
../src/icu.cpp
|
|
||||||
../src/instances.cpp
|
|
||||||
../src/posix_api.cpp
|
|
||||||
../src/regex.cpp
|
|
||||||
../src/regex_debug.cpp
|
|
||||||
../src/regex_raw_buffer.cpp
|
|
||||||
../src/regex_traits_defaults.cpp
|
|
||||||
../src/static_mutex.cpp
|
|
||||||
../src/w32_regex_traits.cpp
|
|
||||||
../src/wc_regex_traits.cpp
|
|
||||||
../src/wide_posix_api.cpp
|
|
||||||
../src/winstances.cpp
|
|
||||||
../src/usinstances.cpp
|
|
||||||
../build//icu_options
|
|
||||||
:
|
|
||||||
<define>BOOST_REGEX_RECURSIVE=1
|
|
||||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
|
||||||
:
|
|
||||||
;
|
|
||||||
|
|
||||||
local regress-sources = regress/$(R_SOURCE) ;
|
local regress-sources = regress/$(R_SOURCE) ;
|
||||||
|
|
||||||
test-suite regex
|
test-suite regex
|
||||||
@ -169,14 +144,6 @@ test-suite regex
|
|||||||
captures_test
|
captures_test
|
||||||
]
|
]
|
||||||
|
|
||||||
[ run regress/$(R_SOURCE) .//boost_regex_recursive
|
|
||||||
../build//icu_options
|
|
||||||
: # command line
|
|
||||||
: # input files
|
|
||||||
: # requirements
|
|
||||||
<define>BOOST_REGEX_RECURSIVE=1
|
|
||||||
: regex_regress_recursive ]
|
|
||||||
|
|
||||||
[ run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh
|
[ run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh
|
||||||
../build//icu_options
|
../build//icu_options
|
||||||
: # command line
|
: # command line
|
||||||
|
@ -8,12 +8,8 @@ project
|
|||||||
;
|
;
|
||||||
|
|
||||||
EX_SOURCES =
|
EX_SOURCES =
|
||||||
c_regex_traits.cpp
|
|
||||||
cpp_regex_traits.cpp
|
cpp_regex_traits.cpp
|
||||||
cregex.cpp
|
|
||||||
fileiter.cpp
|
|
||||||
icu.cpp
|
icu.cpp
|
||||||
instances.cpp
|
|
||||||
posix_api.cpp
|
posix_api.cpp
|
||||||
regex.cpp
|
regex.cpp
|
||||||
regex_debug.cpp
|
regex_debug.cpp
|
||||||
@ -21,10 +17,7 @@ EX_SOURCES =
|
|||||||
regex_traits_defaults.cpp
|
regex_traits_defaults.cpp
|
||||||
static_mutex.cpp
|
static_mutex.cpp
|
||||||
w32_regex_traits.cpp
|
w32_regex_traits.cpp
|
||||||
wc_regex_traits.cpp
|
wide_posix_api.cpp ;
|
||||||
wide_posix_api.cpp
|
|
||||||
winstances.cpp
|
|
||||||
usinstances.cpp ;
|
|
||||||
|
|
||||||
lib boost_regex_extra : $(EX_SOURCES) ../../build//icu_options
|
lib boost_regex_extra : $(EX_SOURCES) ../../build//icu_options
|
||||||
:
|
:
|
||||||
|
@ -24,12 +24,8 @@ project
|
|||||||
|
|
||||||
|
|
||||||
lib boost_regex_noeh :
|
lib boost_regex_noeh :
|
||||||
../../src/c_regex_traits.cpp
|
|
||||||
../../src/cpp_regex_traits.cpp
|
../../src/cpp_regex_traits.cpp
|
||||||
../../src/cregex.cpp
|
|
||||||
../../src/fileiter.cpp
|
|
||||||
../../src/icu.cpp
|
../../src/icu.cpp
|
||||||
../../src/instances.cpp
|
|
||||||
../../src/posix_api.cpp
|
../../src/posix_api.cpp
|
||||||
../../src/regex.cpp
|
../../src/regex.cpp
|
||||||
../../src/regex_debug.cpp
|
../../src/regex_debug.cpp
|
||||||
@ -37,10 +33,7 @@ lib boost_regex_noeh :
|
|||||||
../../src/regex_traits_defaults.cpp
|
../../src/regex_traits_defaults.cpp
|
||||||
../../src/static_mutex.cpp
|
../../src/static_mutex.cpp
|
||||||
../../src/w32_regex_traits.cpp
|
../../src/w32_regex_traits.cpp
|
||||||
../../src/wc_regex_traits.cpp
|
|
||||||
../../src/wide_posix_api.cpp
|
../../src/wide_posix_api.cpp
|
||||||
../../src/winstances.cpp
|
|
||||||
../../src/usinstances.cpp
|
|
||||||
../../build//icu_options
|
../../build//icu_options
|
||||||
:
|
:
|
||||||
<link>static
|
<link>static
|
||||||
|
@ -133,6 +133,11 @@ void test_deprecated(const char&, const test_regex_search_tag&)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_narrow_string(std::wstring const& w)
|
||||||
|
{
|
||||||
|
return std::string(w.begin(), w.end());
|
||||||
|
}
|
||||||
|
|
||||||
void test_deprecated(const wchar_t&, const test_regex_search_tag&)
|
void test_deprecated(const wchar_t&, const test_regex_search_tag&)
|
||||||
{
|
{
|
||||||
#ifndef BOOST_NO_WREGEX
|
#ifndef BOOST_NO_WREGEX
|
||||||
@ -154,7 +159,7 @@ void test_deprecated(const wchar_t&, const test_regex_search_tag&)
|
|||||||
boost::regex_tW re;
|
boost::regex_tW re;
|
||||||
if(boost::regcompW(&re, expression.c_str(), posix_options) != 0)
|
if(boost::regcompW(&re, expression.c_str(), posix_options) != 0)
|
||||||
{
|
{
|
||||||
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" did not compile with the POSIX C API.", wchar_t);
|
BOOST_REGEX_TEST_ERROR("Expression : \"" << to_narrow_string(expression.c_str()) << "\" did not compile with the POSIX C API.", wchar_t);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// try and find the first occurrence:
|
// try and find the first occurrence:
|
||||||
@ -183,7 +188,7 @@ void test_deprecated(const wchar_t&, const test_regex_search_tag&)
|
|||||||
{
|
{
|
||||||
if(results[0] >= 0)
|
if(results[0] >= 0)
|
||||||
{
|
{
|
||||||
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" was not found with the POSIX C API.", wchar_t);
|
BOOST_REGEX_TEST_ERROR("Expression : \"" << to_narrow_string(expression.c_str()) << "\" was not found with the POSIX C API.", wchar_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clean up whatever:
|
// clean up whatever:
|
||||||
@ -248,7 +253,7 @@ void test_deprecated(const wchar_t&, const test_invalid_regex_tag&)
|
|||||||
if(code == 0)
|
if(code == 0)
|
||||||
{
|
{
|
||||||
boost::regfreeW(&re);
|
boost::regfreeW(&re);
|
||||||
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", wchar_t);
|
BOOST_REGEX_TEST_ERROR("Expression : \"" << to_narrow_string(expression.c_str()) << "\" unexpectedly compiled with the POSIX C API.", wchar_t);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -10,20 +10,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <libs/regex/src/c_regex_traits.cpp>
|
|
||||||
#include <libs/regex/src/cpp_regex_traits.cpp>
|
#include <libs/regex/src/cpp_regex_traits.cpp>
|
||||||
#include <libs/regex/src/cregex.cpp>
|
|
||||||
#include <libs/regex/src/fileiter.cpp>
|
|
||||||
#include <libs/regex/src/icu.cpp>
|
#include <libs/regex/src/icu.cpp>
|
||||||
#include <libs/regex/src/instances.cpp>
|
|
||||||
#include <libs/regex/src/posix_api.cpp>
|
#include <libs/regex/src/posix_api.cpp>
|
||||||
#include <libs/regex/src/regex.cpp>
|
#include <libs/regex/src/regex.cpp>
|
||||||
#include <libs/regex/src/regex_debug.cpp>
|
#include <libs/regex/src/regex_debug.cpp>
|
||||||
#include <libs/regex/src/regex_raw_buffer.cpp>
|
#include <libs/regex/src/regex_raw_buffer.cpp>
|
||||||
#include <libs/regex/src/regex_traits_defaults.cpp>
|
#include <libs/regex/src/regex_traits_defaults.cpp>
|
||||||
#include <libs/regex/src/static_mutex.cpp>
|
#include <libs/regex/src/static_mutex.cpp>
|
||||||
#include <libs/regex/src/usinstances.cpp>
|
|
||||||
#include <libs/regex/src/wc_regex_traits.cpp>
|
|
||||||
#include <libs/regex/src/w32_regex_traits.cpp>
|
#include <libs/regex/src/w32_regex_traits.cpp>
|
||||||
#include <libs/regex/src/wide_posix_api.cpp>
|
#include <libs/regex/src/wide_posix_api.cpp>
|
||||||
#include <libs/regex/src/winstances.cpp>
|
|
||||||
|
Reference in New Issue
Block a user