forked from boostorg/regex
Merge accumulated minor fixes from Trunk.
[SVN r74964]
This commit is contained in:
1 parent
5a0f62f00c
commit
fe16f3f039
14 files changed
+130
-65
No files matched your search
+1
-20
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include "internals.hpp"
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
|
||||
@@ -107,26 +108,6 @@ c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transfo
|
||||
return result;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
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[] =
|
||||
|
||||
+15
-2
@@ -361,11 +361,24 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
while(dstart != dend)
|
||||
{
|
||||
// Verify that sprintf will not overflow:
|
||||
if(std::strlen(dstart.path()) + std::strlen(directory_iterator::separator()) + std::strlen(ptr) >= MAX_PATH)
|
||||
{
|
||||
// Oops overflow, skip this item:
|
||||
++dstart;
|
||||
continue;
|
||||
}
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
(::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
int r = (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
#else
|
||||
(std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
int r = (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
#endif
|
||||
if(r < 0)
|
||||
{
|
||||
// sprintf failed, skip this item:
|
||||
++dstart;
|
||||
continue;
|
||||
}
|
||||
BuildFileList(pl, buf, recurse);
|
||||
++dstart;
|
||||
}
|
||||
|
||||
+8
-2
@@ -847,10 +847,16 @@ bool iswild(const char* mask, const char* name)
|
||||
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') )
|
||||
(std::sprintf)(buf, "%s%s", root, name);
|
||||
r = (std::sprintf)(buf, "%s%s", root, name);
|
||||
else
|
||||
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
||||
r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
||||
if(r < 0)
|
||||
return 0; // sprintf failed
|
||||
DIR* d = opendir(buf);
|
||||
if(d)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2011
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOOST_REGEX_SRC_INTERNALS_HPP
|
||||
#define BOOST_REGEX_SRC_INTERNALS_HPP
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#endif // BOOST_REGEX_SRC_INTERNALS_HPP
|
||||
+8
-2
@@ -167,11 +167,17 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
{
|
||||
if(std::strcmp(e->re_endp, names[i]) == 0)
|
||||
{
|
||||
//
|
||||
// We're converting an integer i to a string, and since i <= REG_E_UNKNOWN
|
||||
// a five character string is *always* large enough:
|
||||
//
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
(::sprintf_s)(localbuf, 5, "%d", i);
|
||||
int r = (::sprintf_s)(localbuf, 5, "%d", i);
|
||||
#else
|
||||
(std::sprintf)(localbuf, "%d", i);
|
||||
int r = (std::sprintf)(localbuf, "%d", i);
|
||||
#endif
|
||||
if(r < 0)
|
||||
return 0; // sprintf failed
|
||||
if(std::strlen(localbuf) < buf_size)
|
||||
re_detail::strcpy_s(buf, buf_size, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
|
||||
+1
-20
@@ -22,6 +22,7 @@
|
||||
#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))\
|
||||
@@ -147,26 +148,6 @@ c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::t
|
||||
return result;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
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[] =
|
||||
|
||||
@@ -74,7 +74,7 @@ const wchar_t* wnames[] = {
|
||||
};
|
||||
}
|
||||
|
||||
typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > c_regex_type;
|
||||
typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > wc_regex_type;
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
expression->guts = new c_regex_type();
|
||||
expression->guts = new wc_regex_type();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
@@ -134,9 +134,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
try{
|
||||
#endif
|
||||
expression->re_magic = wmagic_value;
|
||||
static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<c_regex_type*>(expression->guts)->error_code();
|
||||
static_cast<wc_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<wc_regex_type*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<wc_regex_type*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const boost::regex_error& be)
|
||||
@@ -215,7 +215,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
{
|
||||
std::string p;
|
||||
if((e) && (e->re_magic == wmagic_value))
|
||||
p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
p = static_cast<wc_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
else
|
||||
{
|
||||
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
@@ -264,7 +264,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
#endif
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
|
||||
result = regex_search(start, end, m, *static_cast<wc_regex_type*>(expression->guts), flags);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
@@ -301,7 +301,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
|
||||
{
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
delete static_cast<c_regex_type*>(expression->guts);
|
||||
delete static_cast<wc_regex_type*>(expression->guts);
|
||||
}
|
||||
expression->re_magic = 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user