forked from boostorg/regex
Rewritten regex formatting code, refactored headers to reduce dependencies.
[SVN r22891]
This commit is contained in:
+7
-1
@@ -33,6 +33,12 @@ typedef boost::match_flag_type match_flag_type;
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@@ -359,7 +365,7 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
while(dstart != dend)
|
||||
{
|
||||
std::sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
(std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
BuildFileList(pl, buf, recurse);
|
||||
++dstart;
|
||||
}
|
||||
|
||||
+18
-2
@@ -21,12 +21,28 @@
|
||||
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
using ::fseek;
|
||||
using ::fread;
|
||||
using ::ftell;
|
||||
using ::fopen;
|
||||
using ::fclose;
|
||||
using ::FILE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||
@@ -787,9 +803,9 @@ unsigned _fi_attributes(const char* root, const char* name)
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
|
||||
std::sprintf(buf, "%s%s", root, name);
|
||||
(std::sprintf)(buf, "%s%s", root, name);
|
||||
else
|
||||
std::sprintf(buf, "%s%s%s", root, _fi_sep, name);
|
||||
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
||||
DIR* d = opendir(buf);
|
||||
if(d)
|
||||
{
|
||||
|
||||
+10
-2
@@ -19,8 +19,16 @@
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <cstdio>
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace{
|
||||
@@ -135,13 +143,13 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
{
|
||||
if(std::strcmp(e->re_endp, names[i]) == 0)
|
||||
{
|
||||
std::sprintf(localbuf, "%d", i);
|
||||
(std::sprintf)(localbuf, "%d", i);
|
||||
if(std::strlen(localbuf) < buf_size)
|
||||
std::strcpy(buf, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
std::sprintf(localbuf, "%d", 0);
|
||||
(std::sprintf)(localbuf, "%d", 0);
|
||||
if(std::strlen(localbuf) < buf_size)
|
||||
std::strcpy(buf, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#define NOGDI
|
||||
#define NOUSER
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||
@@ -72,6 +79,29 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
|
||||
static void execute_eror()
|
||||
{
|
||||
// we only get here after a stack overflow,
|
||||
// this has to be a separate proceedure because we
|
||||
// can't mix __try{}__except block with local objects
|
||||
// that have destructors:
|
||||
reset_stack_guard_page();
|
||||
std::runtime_error err("Out of stack space, while attempting to match a regular expression.");
|
||||
raise_runtime_error(err);
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL abstract_protected_call::execute()const
|
||||
{
|
||||
__try{
|
||||
return this->call();
|
||||
}__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode())
|
||||
{
|
||||
execute_eror();
|
||||
}
|
||||
// We never really get here at all:
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
{
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <memory>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::memcpy;
|
||||
using ::memmove;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
void BOOST_REGEX_CALL raw_storage::resize(size_type n)
|
||||
|
||||
@@ -19,6 +19,23 @@
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
#include <cwctype>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::tolower;
|
||||
using ::toupper;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
using ::towlower;
|
||||
using ::towupper;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n)
|
||||
@@ -113,7 +130,7 @@ BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_con
|
||||
"",
|
||||
};
|
||||
|
||||
return (n > REG_E_UNKNOWN) ? s_default_error_messages[REG_E_UNKNOWN] : s_default_error_messages[n];
|
||||
return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n];
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c)
|
||||
@@ -239,6 +256,26 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const
|
||||
return std::string();
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL global_lower(char c)
|
||||
{
|
||||
return (std::tolower)(c);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL global_upper(char c)
|
||||
{
|
||||
return (std::toupper)(c);
|
||||
}
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL global_lower(wchar_t c)
|
||||
{
|
||||
return (std::towlower)(c);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL global_upper(wchar_t c)
|
||||
{
|
||||
return (std::towupper)(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // re_detail
|
||||
} // boost
|
||||
|
||||
+12
-2
@@ -22,12 +22,22 @@
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <cwchar>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
# ifndef BOOST_NO_SWPRINTF
|
||||
using ::swprintf;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace {
|
||||
@@ -144,13 +154,13 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
{
|
||||
if(std::wcscmp(e->re_endp, wnames[i]) == 0)
|
||||
{
|
||||
std::swprintf(localbuf, 5, L"%d", i);
|
||||
(std::swprintf)(localbuf, 5, L"%d", i);
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
std::wcscpy(buf, localbuf);
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
std::swprintf(localbuf, 5, L"%d", 0);
|
||||
(std::swprintf)(localbuf, 5, L"%d", 0);
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
std::wcscpy(buf, localbuf);
|
||||
return std::wcslen(localbuf) + 1;
|
||||
|
||||
Reference in New Issue
Block a user