From 99d5760d2b7da26c4c3660cf80db2b280ab95a8a Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 12 Mar 2004 13:20:12 +0000 Subject: [PATCH] removing V3 code... [SVN r22488] --- include/boost/regex/v3/cregex.hpp | 314 --- include/boost/regex/v3/fileiter.hpp | 453 ---- include/boost/regex/v3/instances.hpp | 165 -- include/boost/regex/v3/regex.hpp | 1633 ------------- include/boost/regex/v3/regex_compile.hpp | 2122 ----------------- include/boost/regex/v3/regex_cstring.hpp | 131 - include/boost/regex/v3/regex_format.hpp | 576 ----- include/boost/regex/v3/regex_fwd.hpp | 67 - include/boost/regex/v3/regex_kmp.hpp | 108 - .../boost/regex/v3/regex_library_include.hpp | 181 -- include/boost/regex/v3/regex_match.hpp | 2013 ---------------- include/boost/regex/v3/regex_raw_buffer.hpp | 246 -- include/boost/regex/v3/regex_split.hpp | 149 -- include/boost/regex/v3/regex_stack.hpp | 224 -- include/boost/regex/v3/regex_synch.hpp | 210 -- include/boost/regex/v3/regex_traits.hpp | 815 ------- 16 files changed, 9407 deletions(-) delete mode 100644 include/boost/regex/v3/cregex.hpp delete mode 100644 include/boost/regex/v3/fileiter.hpp delete mode 100644 include/boost/regex/v3/instances.hpp delete mode 100644 include/boost/regex/v3/regex.hpp delete mode 100644 include/boost/regex/v3/regex_compile.hpp delete mode 100644 include/boost/regex/v3/regex_cstring.hpp delete mode 100644 include/boost/regex/v3/regex_format.hpp delete mode 100644 include/boost/regex/v3/regex_fwd.hpp delete mode 100644 include/boost/regex/v3/regex_kmp.hpp delete mode 100644 include/boost/regex/v3/regex_library_include.hpp delete mode 100644 include/boost/regex/v3/regex_match.hpp delete mode 100644 include/boost/regex/v3/regex_raw_buffer.hpp delete mode 100644 include/boost/regex/v3/regex_split.hpp delete mode 100644 include/boost/regex/v3/regex_stack.hpp delete mode 100644 include/boost/regex/v3/regex_synch.hpp delete mode 100644 include/boost/regex/v3/regex_traits.hpp diff --git a/include/boost/regex/v3/cregex.hpp b/include/boost/regex/v3/cregex.hpp deleted file mode 100644 index 0af1ef6c..00000000 --- a/include/boost/regex/v3/cregex.hpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 cregex.cpp - * VERSION see - * DESCRIPTION: Declares POSIX API functions - * + boost::RegEx high level wrapper. - */ - -#ifndef BOOST_RE_CREGEX_HPP_INCLUDED -#define BOOST_RE_CREGEX_HPP_INCLUDED - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -/* include these defs only for POSIX compatablity */ -#ifdef __cplusplus -namespace boost{ -extern "C" { -#endif - -#if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE) -typedef std::ptrdiff_t regoff_t; -typedef std::size_t regsize_t; -#else -typedef ptrdiff_t regoff_t; -typedef size_t regsize_t; -#endif - -typedef struct -{ - unsigned int re_magic; - unsigned int re_nsub; /* number of parenthesized subexpressions */ - const char* re_endp; /* end pointer for REG_PEND */ - void* guts; /* none of your business :-) */ - unsigned int eflags; /* none of your business :-) */ -} regex_tA; - -#ifndef BOOST_NO_WREGEX -typedef struct -{ - unsigned int re_magic; - unsigned int re_nsub; /* number of parenthesized subexpressions */ - const wchar_t* re_endp; /* end pointer for REG_PEND */ - void* guts; /* none of your business :-) */ - unsigned int eflags; /* none of your business :-) */ -} regex_tW; -#endif - -typedef struct -{ - regoff_t rm_so; /* start of match */ - regoff_t rm_eo; /* end of match */ -} regmatch_t; - -/* regcomp() flags */ -typedef enum{ - REG_BASIC = 0000, - REG_EXTENDED = 0001, - REG_ICASE = 0002, - REG_NOSUB = 0004, - REG_NEWLINE = 0010, - REG_NOSPEC = 0020, - REG_PEND = 0040, - REG_DUMP = 0200, - REG_NOCOLLATE = 0400, - REG_ESCAPE_IN_LISTS = 01000, - REG_NEWLINE_ALT = 02000, - - REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS, - REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS, - REG_GREP = REG_BASIC | REG_NEWLINE_ALT, - REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT, - - REG_ASSERT = 15, - REG_INVARG = 16, - REG_ATOI = 255, /* convert name to number (!) */ - REG_ITOA = 0400 /* convert number to name (!) */ -} reg_comp_flags; - -/* regexec() flags */ -typedef enum{ - REG_NOTBOL = 00001, - REG_NOTEOL = 00002, - REG_STARTEND = 00004 -} reg_exec_flags; - -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); -BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int); -BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*); - -#ifndef BOOST_NO_WREGEX -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int); -BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t); -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int); -BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); -#endif - -#ifdef UNICODE -#define regcomp regcompW -#define regerror regerrorW -#define regexec regexecW -#define regfree regfreeW -#define regex_t regex_tW -#else -#define regcomp regcompA -#define regerror regerrorA -#define regexec regexecA -#define regfree regfreeA -#define regex_t regex_tA -#endif - -/* regerror() flags */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH = 1, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT = 2, /* Invalid pattern. */ - REG_ECOLLATE = 3, /* Undefined collating element. */ - REG_ECTYPE = 4, /* Invalid character class name. */ - REG_EESCAPE = 5, /* Trailing backslash. */ - REG_ESUBREG = 6, /* Invalid back reference. */ - REG_EBRACK = 7, /* Unmatched left bracket. */ - REG_EPAREN = 8, /* Parenthesis imbalance. */ - REG_EBRACE = 9, /* Unmatched \{. */ - REG_BADBR = 10, /* Invalid contents of \{\}. */ - REG_ERANGE = 11, /* Invalid range end. */ - REG_ESPACE = 12, /* Ran out of memory. */ - REG_BADRPT = 13, /* No preceding re for repetition op. */ - REG_EEND = 14, /* unexpected end of expression */ - REG_ESIZE = 15, /* expression too big */ - REG_ERPAREN = 16, /* unmatched right parenthesis */ - REG_EMPTY = 17, /* empty expression */ - REG_E_MEMORY = REG_ESIZE, /* out of memory */ - REG_E_UNKNOWN = 18 /* unknown error */ -} reg_errcode_t; - -enum match_flags -{ - match_default = 0, - match_not_bol = 1, // first is not start of line - match_not_eol = match_not_bol << 1, // last is not end of line - match_not_bob = match_not_eol << 1, // first is not start of buffer - match_not_eob = match_not_bob << 1, // last is not end of buffer - match_not_bow = match_not_eob << 1, // first is not start of word - match_not_eow = match_not_bow << 1, // last is not end of word - match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.' - match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.' - match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression - match_init = match_prev_avail << 1, // internal use - match_any = match_init << 1, // don't care what we match - match_not_null = match_any << 1, // string can't be null - match_continuous = match_not_null << 1, // each grep match must continue from - // uninterupted from the previous one - match_partial = match_continuous << 1, // find partial matches - - match_stop = match_partial << 1, // stop after first match (grep) - match_all = match_stop << 1, // must find the whole of input even if match_any is set - match_max = match_all -}; - -typedef unsigned long match_flag_type; - -#ifdef __cplusplus -} // extern "C" -} // namespace -#endif - - -#ifdef __BORLANDC__ - #if __BORLANDC__ > 0x520 - #pragma option pop - #endif -#endif - - -// -// C++ high level wrapper goes here: -// -#if defined(__cplusplus) -#include -#include -namespace boost{ - -#ifdef __BORLANDC__ - #if __BORLANDC__ == 0x530 - #pragma option push -a4 -b - #elif __BORLANDC__ > 0x530 - #pragma option push -a8 -b - #endif -#endif - -class RegEx; - -namespace re_detail{ - -class RegExData; -struct pred1; -struct pred2; -struct pred3; -struct pred4; - -} // namespace re_detail - -#if defined(BOOST_MSVC) || defined(__BORLANDC__) -typedef bool (__cdecl *GrepCallback)(const RegEx& expression); -typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression); -typedef bool (__cdecl *FindFilesCallback)(const char* file); -#else -typedef bool (*GrepCallback)(const RegEx& expression); -typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression); -typedef bool (*FindFilesCallback)(const char* file); -#endif - -class BOOST_REGEX_DECL RegEx -{ -private: - re_detail::RegExData* pdata; -public: - RegEx(); - RegEx(const RegEx& o); - ~RegEx(); - explicit RegEx(const char* c, bool icase = false); - explicit RegEx(const std::string& s, bool icase = false); - RegEx& operator=(const RegEx& o); - RegEx& operator=(const char* p); - RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); } - unsigned int SetExpression(const char* p, bool icase = false); - unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); } - std::string Expression()const; - unsigned int error_code()const; - // - // now matching operators: - // - bool Match(const char* p, match_flag_type flags = match_default); - bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); } - bool Search(const char* p, match_flag_type flags = match_default); - bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); } - unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default); - unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); } - unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); - unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } - unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); - unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } -#ifndef BOOST_REGEX_NO_FILEITER - unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); - unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); } - unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); - unsigned int FindFiles(FindFilesCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return FindFiles(cb, files.c_str(), recurse, flags); } -#endif - - std::string Merge(const std::string& in, const std::string& fmt, - bool copy = true, match_flag_type flags = match_default); - std::string Merge(const char* in, const char* fmt, - bool copy = true, match_flag_type flags = match_default); - - std::size_t Split(std::vector& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0); - // - // now operators for returning what matched in more detail: - // - std::size_t Position(int i = 0)const; - std::size_t Length(int i = 0)const; - bool Matched(int i = 0)const; - unsigned int Line()const; - unsigned int Marks()const; - std::string What(int i = 0)const; - std::string operator[](int i)const { return What(i); } - - static const unsigned int npos; - - friend struct re_detail::pred1; - friend struct re_detail::pred2; - friend struct re_detail::pred3; - friend struct re_detail::pred4; -}; - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#endif - -#endif // include guard - - - - - - - - - - diff --git a/include/boost/regex/v3/fileiter.hpp b/include/boost/regex/v3/fileiter.hpp deleted file mode 100644 index ef861f40..00000000 --- a/include/boost/regex/v3/fileiter.hpp +++ /dev/null @@ -1,453 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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.hpp - * VERSION see - * DESCRIPTION: Declares various platform independent file and - * directory iterators, plus binary file input in - * the form of class map_file. - */ - -#ifndef BOOST_RE_FILEITER_HPP_INCLUDED -#define BOOST_RE_FILEITER_HPP_INCLUDED - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#ifndef BOOST_REGEX_NO_FILEITER - -#if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && !defined(BOOST_REGEX_NO_W32) -#error "Sorry, can't mix with STL code and gcc compiler: if you ran configure, try again with configure --disable-ms-windows" -#define BOOST_REGEX_FI_WIN32_MAP -#define BOOST_REGEX_FI_POSIX_DIR -#elif (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) && !defined(BOOST_REGEX_NO_W32) -#define BOOST_REGEX_FI_WIN32_MAP -#define BOOST_REGEX_FI_WIN32_DIR -#else -#define BOOST_REGEX_FI_POSIX_MAP -#define BOOST_REGEX_FI_POSIX_DIR -#endif - -#if defined(BOOST_REGEX_FI_WIN32_MAP)||defined(BOOST_REGEX_FI_WIN32_DIR) -#include -#endif - -#if defined(BOOST_REGEX_FI_WIN32_DIR) - -namespace boost{ - namespace re_detail{ - -typedef WIN32_FIND_DATAA _fi_find_data; -typedef HANDLE _fi_find_handle; - - } // namespace re_detail - -} // namespace boost - -#define _fi_invalid_handle INVALID_HANDLE_VALUE -#define _fi_dir FILE_ATTRIBUTE_DIRECTORY - -#elif defined(BOOST_REGEX_FI_POSIX_DIR) - -#include -#include -#include -#include -#include -#include - -#if defined(__SUNPRO_CC) -using std::list; -#endif - -#ifndef MAX_PATH -#define MAX_PATH 256 -#endif - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -struct _fi_find_data -{ - unsigned dwFileAttributes; - char cFileName[MAX_PATH]; -}; - -struct _fi_priv_data; - -typedef _fi_priv_data* _fi_find_handle; -#define _fi_invalid_handle 0 -#define _fi_dir 1 - -_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData); -bool _fi_FindNextFile(_fi_find_handle hFindFile, _fi_find_data* lpFindFileData); -bool _fi_FindClose(_fi_find_handle hFindFile); - -#ifdef __BORLANDC__ - #if __BORLANDC__ > 0x520 - #pragma option pop - #endif -#endif - - } // namespace re_detail -} // namespace boost - -#ifdef FindFirstFile - #undef FindFirstFile -#endif -#ifdef FindNextFile - #undef FindNextFile -#endif -#ifdef FindClose - #undef FindClose -#endif - -#define FindFirstFileA _fi_FindFirstFile -#define FindNextFileA _fi_FindNextFile -#define FindClose _fi_FindClose - -#endif - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #if __BORLANDC__ == 0x530 - #pragma option push -a4 -b - #elif __BORLANDC__ > 0x530 - #pragma option push -a8 -b - #endif -#endif - -#ifdef BOOST_REGEX_FI_WIN32_MAP // win32 mapfile - -class BOOST_REGEX_DECL mapfile -{ - HANDLE hfile; - HANDLE hmap; - const char* _first; - const char* _last; -public: - - typedef const char* iterator; - - mapfile(){ hfile = hmap = 0; _first = _last = 0; } - mapfile(const char* file){ hfile = hmap = 0; _first = _last = 0; open(file); } - ~mapfile(){ close(); } - void open(const char* file); - void close(); - const char* begin(){ return _first; } - const char* end(){ return _last; } - size_t size(){ return _last - _first; } - bool valid(){ return (hfile != 0) && (hfile != INVALID_HANDLE_VALUE); } -}; - - -#else - -class BOOST_REGEX_DECL mapfile_iterator; - -class BOOST_REGEX_DECL mapfile -{ - typedef char* pointer; - std::FILE* hfile; - long int _size; - pointer* _first; - pointer* _last; - mutable std::list condemed; - enum sizes - { - buf_size = 4096 - }; - void lock(pointer* node)const; - void unlock(pointer* node)const; -public: - - typedef mapfile_iterator iterator; - - mapfile(){ hfile = 0; _size = 0; _first = _last = 0; } - mapfile(const char* file){ hfile = 0; _size = 0; _first = _last = 0; open(file); } - ~mapfile(){ close(); } - void open(const char* file); - void close(); - iterator begin()const; - iterator end()const; - unsigned long size()const{ return _size; } - bool valid()const{ return hfile != 0; } - friend class mapfile_iterator; -}; - -class BOOST_REGEX_DECL mapfile_iterator -#if !defined(BOOST_NO_STD_ITERATOR) || defined(BOOST_MSVC_STD_ITERATOR) -: public std::iterator -#endif -{ - typedef mapfile::pointer internal_pointer; - internal_pointer* node; - const mapfile* file; - unsigned long offset; - long position()const - { - return file ? ((node - file->_first) * mapfile::buf_size + offset) : 0; - } - void position(long pos) - { - if(file) - { - node = file->_first + (pos / mapfile::buf_size); - offset = pos % mapfile::buf_size; - } - } -public: - typedef std::ptrdiff_t difference_type; - typedef char value_type; - typedef const char* pointer; - typedef const char& reference; - typedef std::random_access_iterator_tag iterator_category; - - mapfile_iterator() { node = 0; file = 0; offset = 0; } - mapfile_iterator(const mapfile* f, long position) - { - file = f; - node = f->_first + position / mapfile::buf_size; - offset = position % mapfile::buf_size; - if(file) - file->lock(node); - } - mapfile_iterator(const mapfile_iterator& i) - { - file = i.file; - node = i.node; - offset = i.offset; - if(file) - file->lock(node); - } - ~mapfile_iterator() - { - if(file && node) - file->unlock(node); - } - mapfile_iterator& operator = (const mapfile_iterator& i); - char operator* ()const - { - assert(node >= file->_first); - assert(node < file->_last); - return file ? *(*node + sizeof(int) + offset) : char(0); - } - char operator[] (long off)const - { - mapfile_iterator tmp(*this); - tmp += off; - return *tmp; - } - mapfile_iterator& operator++ (); - mapfile_iterator operator++ (int); - mapfile_iterator& operator-- (); - mapfile_iterator operator-- (int); - - mapfile_iterator& operator += (long off) - { - position(position() + off); - return *this; - } - mapfile_iterator& operator -= (long off) - { - position(position() - off); - return *this; - } - - friend inline bool operator==(const mapfile_iterator& i, const mapfile_iterator& j) - { - return (i.file == j.file) && (i.node == j.node) && (i.offset == j.offset); - } - - friend inline bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j) - { - return !(i == j); - } - - friend inline bool operator<(const mapfile_iterator& i, const mapfile_iterator& j) - { - return i.position() < j.position(); - } - friend inline bool operator>(const mapfile_iterator& i, const mapfile_iterator& j) - { - return i.position() > j.position(); - } - friend inline bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j) - { - return i.position() <= j.position(); - } - friend inline bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j) - { - return i.position() >= j.position(); - } - - friend mapfile_iterator operator + (const mapfile_iterator& i, long off); - friend mapfile_iterator operator + (long off, const mapfile_iterator& i) - { - mapfile_iterator tmp(i); - return tmp += off; - } - friend mapfile_iterator operator - (const mapfile_iterator& i, long off); - friend inline long operator - (const mapfile_iterator& i, const mapfile_iterator& j) - { - return i.position() - j.position(); - } -}; - -#endif - -// _fi_sep determines the directory separator, either '\\' or '/' -BOOST_REGEX_DECL extern const char* _fi_sep; - -struct file_iterator_ref -{ - _fi_find_handle hf; - _fi_find_data _data; - long count; -}; - - -class BOOST_REGEX_DECL file_iterator -{ - char* _root; - char* _path; - char* ptr; - file_iterator_ref* ref; - -public: - typedef std::ptrdiff_t difference_type; - typedef const char* value_type; - typedef const char** pointer; - typedef const char*& reference; - typedef std::input_iterator_tag iterator_category; - - file_iterator(); - file_iterator(const char* wild); - ~file_iterator(); - file_iterator(const file_iterator&); - file_iterator& operator=(const file_iterator&); - const char* root()const { return _root; } - const char* path()const { return _path; } - const char* name()const { return ptr; } - _fi_find_data* data() { return &(ref->_data); } - void next(); - file_iterator& operator++() { next(); return *this; } - file_iterator operator++(int); - const char* operator*() { return path(); } - - friend inline bool operator == (const file_iterator& f1, const file_iterator& f2) - { - return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); - } - - friend inline bool operator != (const file_iterator& f1, const file_iterator& f2) - { - return !(f1 == f2); - } - -}; - -// dwa 9/13/00 - suppress unused parameter warning -inline bool operator < (const file_iterator&, const file_iterator&) -{ - return false; -} - - -class BOOST_REGEX_DECL directory_iterator -{ - char* _root; - char* _path; - char* ptr; - file_iterator_ref* ref; - -public: - typedef std::ptrdiff_t difference_type; - typedef const char* value_type; - typedef const char** pointer; - typedef const char*& reference; - typedef std::input_iterator_tag iterator_category; - - directory_iterator(); - directory_iterator(const char* wild); - ~directory_iterator(); - directory_iterator(const directory_iterator& other); - directory_iterator& operator=(const directory_iterator& other); - - const char* root()const { return _root; } - const char* path()const { return _path; } - const char* name()const { return ptr; } - _fi_find_data* data() { return &(ref->_data); } - void next(); - directory_iterator& operator++() { next(); return *this; } - directory_iterator operator++(int); - const char* operator*() { return path(); } - - static const char* separator() { return _fi_sep; } - - friend inline bool operator == (const directory_iterator& f1, const directory_iterator& f2) - { - return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); - } - - - friend inline bool operator != (const directory_iterator& f1, const directory_iterator& f2) - { - return !(f1 == f2); - } - - }; - -inline bool operator < (const directory_iterator&, const directory_iterator&) -{ - return false; -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - - -} // namespace re_detail -using boost::re_detail::directory_iterator; -using boost::re_detail::file_iterator; -using boost::re_detail::mapfile; -} // namespace boost - -#endif // BOOST_REGEX_NO_FILEITER -#endif // BOOST_RE_FILEITER_HPP - - - - - - - - - - - - - - - - - - diff --git a/include/boost/regex/v3/instances.hpp b/include/boost/regex/v3/instances.hpp deleted file mode 100644 index 25c7f8bd..00000000 --- a/include/boost/regex/v3/instances.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 - * DESCRIPTION: Defines those template instances that are placed in the - * library rather than in the users object files. - */ - -// -// note no include guard, we may include this multiple times: -// -#ifndef BOOST_REGEX_NO_EXTERNAL_TEMPLATES - -namespace boost{ - -// -// this header can be included multiple times, each time with -// a different character type, BOOST_REGEX_CHAR_T must be defined -// first: -// -#ifndef BOOST_REGEX_CHAR_T -# error "BOOST_REGEX_CHAR_T not defined" -#endif - -// -// what follows is compiler specific: -// - -#ifdef __BORLANDC__ - -#pragma option push -a8 -b -Vx -Ve -pc - -# ifndef BOOST_REGEX_INSTANTIATE -# pragma option push -Jgx -# endif - -template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; -template class BOOST_REGEX_DECL re_detail::match_results_base; -template class BOOST_REGEX_DECL re_detail::match_results_base::const_iterator>; -template class BOOST_REGEX_DECL match_results; -template class BOOST_REGEX_DECL match_results::const_iterator>; - - -# ifndef BOOST_REGEX_INSTANTIATE -# pragma option pop -# endif - -#pragma option pop - -#elif defined(BOOST_MSVC) - -# ifndef BOOST_REGEX_INSTANTIATE -# define template extern template -# endif - -#pragma warning(push) -#pragma warning(disable : 4251 4231 4660) - -//template class BOOST_REGEX_DECL regex_traits< BOOST_REGEX_CHAR_T >; -template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; -template class BOOST_REGEX_DECL re_detail::match_results_base::type) >; -template class BOOST_REGEX_DECL re_detail::match_results_base::const_iterator, BOOST_DEFAULT_ALLOCATOR(re_detail::def_alloc_param_traits::const_iterator>::type) >; -template class BOOST_REGEX_DECL match_results::type) >; -template class BOOST_REGEX_DECL match_results::const_iterator, BOOST_DEFAULT_ALLOCATOR(re_detail::def_alloc_param_traits::const_iterator>::type) >; - - -#pragma warning(pop) - -# ifdef template -# undef template -# endif - -#elif !defined(BOOST_REGEX_HAS_DLL_RUNTIME) - -// -// for each [member] function declare a full specialisation of that -// [member] function, then instantiate it in one translation unit. -// This is not guarenteed to work according to the standard, but in -// practice it should work for all compilers (unless they use a realy -// perverse name mangling convention). Unfortunately this approach -// does *not* work for Win32 style import/export, because that can -// alter the class layout. -// - -# ifndef BOOST_REGEX_INSTANTIATE -# define template template<> -# endif - -template reg_expression::reg_expression(const BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T)&); -template reg_expression::reg_expression(const BOOST_REGEX_CHAR_T* p, reg_expression::flag_type f, const BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T)& a); -template reg_expression::reg_expression(const BOOST_REGEX_CHAR_T* p, size_type len, reg_expression::flag_type f, const BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T)&); -template reg_expression::reg_expression(const reg_expression&); -template reg_expression::~reg_expression(); -template reg_expression& BOOST_REGEX_CALL reg_expression::operator=(const reg_expression&); -template BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) BOOST_REGEX_CALL reg_expression::get_allocator()const; -template bool BOOST_REGEX_CALL reg_expression::operator==(const reg_expression&)const; -template bool BOOST_REGEX_CALL reg_expression::operator<(const reg_expression&)const; -template BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) BOOST_REGEX_CALL reg_expression::allocator()const; -template unsigned int BOOST_REGEX_CALL reg_expression::set_expression(const BOOST_REGEX_CHAR_T* p, const BOOST_REGEX_CHAR_T* end, reg_expression::flag_type f); -template void BOOST_REGEX_CALL reg_expression::compile_maps(); -template void BOOST_REGEX_CALL reg_expression::compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal)const; -template bool BOOST_REGEX_CALL reg_expression::probe_start(re_detail::re_syntax_base* node, BOOST_REGEX_CHAR_T c, re_detail::re_syntax_base* terminal)const; -template bool BOOST_REGEX_CALL reg_expression::probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const; -template void BOOST_REGEX_CALL reg_expression::fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces); -template void BOOST_REGEX_CALL reg_expression::move_offsets(re_detail::re_syntax_base* j, unsigned size); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) >& singles, re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T)>& ranges, re_detail::jstack& classes, re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) >& equivalents, bool isnot, const re_detail::_narrow_type&); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) >& singles, re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T)>& ranges, re_detail::jstack& classes, re_detail::jstack::traits_string_type, BOOST_DEFAULT_ALLOCATOR(BOOST_REGEX_CHAR_T) >& equivalents, bool isnot, const re_detail::_wide_type&); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot); -template unsigned int BOOST_REGEX_CALL reg_expression::parse_inner_set(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size); -template re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_literal(re_detail::re_syntax_base* dat, BOOST_REGEX_CHAR_T c); -template BOOST_REGEX_CHAR_T BOOST_REGEX_CALL reg_expression::parse_escape(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last); -template void BOOST_REGEX_CALL reg_expression::parse_range(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last, unsigned& min, unsigned& max); -template bool BOOST_REGEX_CALL reg_expression::skip_space(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last); -template unsigned int BOOST_REGEX_CALL reg_expression::probe_restart(re_detail::re_syntax_base* dat); -template unsigned int BOOST_REGEX_CALL reg_expression::fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end); -template void BOOST_REGEX_CALL reg_expression::fail(unsigned int err); - -namespace re_detail{ - -#define iterator const BOOST_REGEX_CHAR_T* -#define Allocator match_results_base::alloc_type -#define size_type match_results_base::size_type - -template void BOOST_REGEX_CALL match_results_base::set_first(iterator i); -template void BOOST_REGEX_CALL match_results_base::set_first(iterator i, std::size_t pos); -template match_results_base::match_results_base(const Allocator& a); -template Allocator BOOST_REGEX_CALL match_results_base::allocator()const; -template void BOOST_REGEX_CALL match_results_base::m_free(); -template bool match_results_base::operator==(const match_results_base& that)const; -template void BOOST_REGEX_CALL match_results_base::set_size(size_type n); -template void BOOST_REGEX_CALL match_results_base::set_size(size_type n, iterator i, iterator j); -template void BOOST_REGEX_CALL match_results_base::cow(); - -#undef iterator -#undef Allocator -#undef size_type - -} // namespace re_detail - -# ifdef template -# undef template -# endif - -#endif - -} // namespace boost - -#endif // BOOST_REGEX_NO_EXTERNAL_TEMPLATES - - - - diff --git a/include/boost/regex/v3/regex.hpp b/include/boost/regex/v3/regex.hpp deleted file mode 100644 index 52d745ef..00000000 --- a/include/boost/regex/v3/regex.hpp +++ /dev/null @@ -1,1633 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex.cpp - * VERSION see - * DESCRIPTION: Declares boost::reg_expression<> and associated - * functions and classes. This header is the main - * entry point for the template regex code. - */ - - -/* start with C compatibility API */ - -#ifndef BOOST_RE_REGEX_HPP_INCLUDED -#define BOOST_RE_REGEX_HPP_INCLUDED - -#ifndef BOOST_RE_CREGEX_HPP -#include -#endif - -#ifdef __cplusplus - -// what follows is all C++ don't include in C builds!! - -#ifdef BOOST_REGEX_DEBUG -# include -#endif - -#include -#include -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif -#ifndef BOOST_REGEX_FWD_HPP -#include -#endif -#ifndef BOOST_REGEX_STACK_HPP -#include -#endif -#ifndef BOOST_REGEX_RAW_BUFFER_HPP -#include -#endif -#ifndef BOOST_REGEX_KMP_HPP -#include -#endif -#ifndef BOOST_RE_PAT_EXCEPT_HPP -#include -#endif -#ifndef BOOST_REGEX_TRAITS_HPP -#include -#endif -#include -#include - - -namespace boost{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -w-8027 -#endif - -namespace re_detail{ - -struct re_set_long; -struct re_syntax_base; - -} // namespace re_detail - -namespace deprecated{ -// -// class char_regex_traits_i -// provides case insensitive traits classes (deprecated): -template -class char_regex_traits_i : public regex_traits {}; - -template<> -class char_regex_traits_i : public regex_traits -{ -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef regex_traits base_type; - - char BOOST_REGEX_CALL translate(char c, bool)const - { - return static_cast*>(this)->translate(c, true); - } -}; - -#ifndef BOOST_NO_WREGEX -template<> -class char_regex_traits_i : public regex_traits -{ -public: - typedef wchar_t char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef regex_traits base_type; - - wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool)const - { - return static_cast*>(this)->translate(c, true); - } - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const - { - boost::uint_fast32_t result = static_cast*>(this)->lookup_classname(first, last); - if((result & base_type::char_class_upper) == base_type::char_class_upper) - result |= base_type::char_class_alpha; - return result; - } -}; -#endif -} // namespace deprecated - - -namespace re_detail{ - -enum mask_type -{ - mask_take = 1, - mask_skip = 2, - mask_any = mask_skip | mask_take, - mask_all = mask_any -}; - -struct _narrow_type{}; -struct _wide_type{}; - -template -class is_byte; - -template<> -class is_byte -{ -public: - typedef _narrow_type width_type; -}; - -template<> -class is_byte -{ -public: - typedef _narrow_type width_type; -}; - -template<> -class is_byte -{ -public: - typedef _narrow_type width_type; -}; - -template -class is_byte -{ -public: - typedef _wide_type width_type; -}; - - -// -// compiled structures -// -// the following defs describe the format of the compiled string -// - -// -// enum syntax_element_type -// describes the type of a record -enum syntax_element_type -{ - syntax_element_startmark = 0, - syntax_element_endmark = syntax_element_startmark + 1, - syntax_element_literal = syntax_element_endmark + 1, - syntax_element_start_line = syntax_element_literal + 1, - syntax_element_end_line = syntax_element_start_line + 1, - syntax_element_wild = syntax_element_end_line + 1, - syntax_element_match = syntax_element_wild + 1, - syntax_element_word_boundary = syntax_element_match + 1, - syntax_element_within_word = syntax_element_word_boundary + 1, - syntax_element_word_start = syntax_element_within_word + 1, - syntax_element_word_end = syntax_element_word_start + 1, - syntax_element_buffer_start = syntax_element_word_end + 1, - syntax_element_buffer_end = syntax_element_buffer_start + 1, - syntax_element_backref = syntax_element_buffer_end + 1, - syntax_element_long_set = syntax_element_backref + 1, - syntax_element_set = syntax_element_long_set + 1, - syntax_element_jump = syntax_element_set + 1, - syntax_element_alt = syntax_element_jump + 1, - syntax_element_rep = syntax_element_alt + 1, - syntax_element_combining = syntax_element_rep + 1, - syntax_element_soft_buffer_end = syntax_element_combining + 1, - syntax_element_restart_continue = syntax_element_soft_buffer_end + 1 -}; - -#ifdef BOOST_REGEX_DEBUG -// dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion -std::ostream& operator<<(std::ostream&, syntax_element_type); -#endif - -union offset_type -{ - re_syntax_base* p; - std::size_t i; -}; - -// -// struct re_syntax_base -// base class for all syntax types: -struct re_syntax_base -{ - syntax_element_type type; - offset_type next; - unsigned int can_be_null; -}; - -// -// struct re_brace -// marks start or end of (...) -struct re_brace : public re_syntax_base -{ - int index; -}; - -// -// struct re_literal -// marks a literal string and -// is followed by an array of charT[length]: -struct re_literal : public re_syntax_base -{ - unsigned int length; -}; - -// -// struct re_long_set -// provides data for sets [...] containing -// wide characters -struct re_set_long : public re_syntax_base -{ - unsigned int csingles, cranges, cequivalents; - boost::uint_fast32_t cclasses; - bool isnot; -}; - -// -// struct re_set -// provides a map of bools for sets containing -// narrow, single byte characters. -struct re_set : public re_syntax_base -{ - unsigned char _map[256]; -}; - -// -// struct re_jump -// provides alternative next destination -struct re_jump : public re_syntax_base -{ - offset_type alt; - unsigned char _map[256]; -}; - -// -// struct re_repeat -// provides repeat expressions -struct re_repeat : public re_jump -{ - unsigned min, max; - int id; - bool leading; - bool greedy; - bool singleton; -}; - - -// -// enum re_jump_size_type -// provides compiled size of re_jump -// allowing for trailing alignment -// provide this so we know how many -// bytes to insert -enum re_jump_size_type -{ - re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask), - re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask) -}; - -} // namespace re_detail - -// -// class basic_regex -// handles error codes and flags - -class BOOST_REGEX_DECL regbase -{ -public: - enum flag_type_ - { - escape_in_lists = 1, // '\' special inside [...] - char_classes = escape_in_lists << 1, // [[:CLASS:]] allowed - intervals = char_classes << 1, // {x,y} allowed - limited_ops = intervals << 1, // all of + ? and | are normal characters - newline_alt = limited_ops << 1, // \n is the same as | - bk_plus_qm = newline_alt << 1, // uses \+ and \? - bk_braces = bk_plus_qm << 1, // uses \{ and \} - bk_parens = bk_braces << 1, // uses \( and \) - bk_refs = bk_parens << 1, // \d allowed - bk_vbar = bk_refs << 1, // uses \| - - use_except = bk_vbar << 1, // exception on error - failbit = use_except << 1, // error flag - literal = failbit << 1, // all characters are literals - icase = literal << 1, // characters are matched regardless of case - nocollate = icase << 1, // don't use locale specific collation - - basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs, - extended = char_classes | intervals | bk_refs, - normal = escape_in_lists | char_classes | intervals | bk_refs | nocollate, - emacs = bk_braces | bk_parens | bk_refs | bk_vbar, - awk = extended | escape_in_lists, - grep = basic | newline_alt, - egrep = extended | newline_alt, - sed = basic, - perl = normal - }; - typedef unsigned int flag_type; - - enum restart_info - { - restart_any = 0, - restart_word = 1, - restart_line = 2, - restart_buf = 3, - restart_continue = 4, - restart_lit = 5, - restart_fixed_lit = 6 - }; - - flag_type BOOST_REGEX_CALL flags()const - { - return _flags; - } - - regbase(); - regbase(const regbase& b); -protected: - flag_type _flags; -}; - -// -// some forward declarations: -namespace re_detail{ -template -class _priv_match_data; - -#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - -template -struct regex_iterator_traits -{ - typedef typename T::iterator_category iterator_category; - typedef typename T::value_type value_type; -#if !defined(BOOST_NO_STD_ITERATOR) - typedef typename T::difference_type difference_type; - typedef typename T::pointer pointer; - typedef typename T::reference reference; -#else - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; -#endif -}; - -template -struct pointer_iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; -template -struct const_pointer_iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef const T* pointer; - typedef const T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; - -template<> -struct regex_iterator_traits : pointer_iterator_traits{}; -template<> -struct regex_iterator_traits : const_pointer_iterator_traits{}; -template<> -struct regex_iterator_traits : pointer_iterator_traits{}; -template<> -struct regex_iterator_traits : const_pointer_iterator_traits{}; - -#if defined(__SGI_STL_PORT) && defined(__STL_DEBUG) -template<> -struct regex_iterator_traits : pointer_iterator_traits{}; -template<> -struct regex_iterator_traits : const_pointer_iterator_traits{}; -#ifndef BOOST_NO_STD_WSTRING -template<> -struct regex_iterator_traits : pointer_iterator_traits{}; -template<> -struct regex_iterator_traits : const_pointer_iterator_traits{}; -#endif // BOOST_NO_WSTRING -#endif // stport - -#else - -template -struct regex_iterator_traits : public std::iterator_traits {}; - -#endif - -template -struct def_alloc_param_traits -{ - typedef typename regex_iterator_traits::value_type const_value_type; - typedef typename remove_cv::type type; -}; -template <> -struct def_alloc_param_traits -{ - typedef char type; -}; -template <> -struct def_alloc_param_traits -{ - typedef wchar_t type; -}; - -} - -template ::type) > -#else -BOOST_DEFAULT_ALLOCATOR(re_detail::def_alloc_param_traits::type) > -#endif -class match_results; - -// -// class reg_expression -// represents the compiled -// regular expression: -// - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable : 4251 4231 4660) -#endif - -#ifdef BOOST_REGEX_NO_FWD -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > -#else -template -#endif -class reg_expression : public regbase -{ -public: - typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; - typedef typename traits::string_type traits_string_type; - // typedefs: - typedef charT char_type; - typedef traits traits_type; - - // locale_type - // placeholder for actual locale type used by the - // traits class to localise *this. - typedef typename traits::locale_type locale_type; - // value_type - typedef charT value_type; - // reference, const_reference - typedef charT& reference; - typedef const charT& const_reference; - // iterator, const_iterator - typedef const charT* const_iterator; - typedef const_iterator iterator; - // difference_type - typedef typename Allocator::difference_type difference_type; - // size_type - typedef typename Allocator::size_type size_type; - // allocator_type - typedef Allocator allocator_type; - typedef Allocator alloc_type; - // flag_type - typedef regbase::flag_type flag_type; - -public: - explicit reg_expression(const Allocator& a = Allocator()); - explicit reg_expression(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator()); - reg_expression(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator()); - reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator()); - reg_expression(const reg_expression&); - ~reg_expression(); - reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&); - reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr) - { - set_expression(ptr, regbase::normal | regbase::use_except); - return *this; - } - - // - // assign: - reg_expression& assign(const reg_expression& that) - { return *this = that; } - reg_expression& assign(const charT* ptr, flag_type f = regbase::normal) - { - set_expression(ptr, f | regbase::use_except); - return *this; - } - - reg_expression& assign(const charT* first, - const charT* last, - flag_type f = regbase::normal) - { - set_expression(first, last, f | regbase::use_except); - return *this; - } -#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502)) - - template - unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regbase::normal) - { return set_expression(p.data(), p.data() + p.size(), f); } - - template - explicit reg_expression(const std::basic_string& p, flag_type f = regbase::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regbase::use_except); } - - template - reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator()) - : data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0) - { - size_type len = last-first; - scoped_array a(new charT[len]); - std::copy(first, last, a.get()); - set_expression(a.get(), a.get() + len, f | regbase::use_except); - } - - template - reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) - { - set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except); - return *this; - } - - template - reg_expression& BOOST_REGEX_CALL assign( - const std::basic_string& s, - flag_type f = regbase::normal) - { - set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except); - return *this; - } - - template - reg_expression& BOOST_REGEX_CALL assign(fwd_iterator first, - fwd_iterator last, - flag_type f = regbase::normal) - { - size_type len = last-first; - scoped_array a(new charT[len]); - std::copy(first, last, a.get()); - set_expression(a.get(), a.get() + len, f | regbase::use_except); - return *this; - } -#else - unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regbase::normal) - { return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); } - - reg_expression(const std::basic_string& p, flag_type f = regbase::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0) { set_expression(p, f | regbase::use_except); } - - reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) - { - set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except); - return *this; - } - - reg_expression& BOOST_REGEX_CALL assign( - const std::basic_string& s, - flag_type f = regbase::normal) - { - set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except); - return *this; - } - -#endif - - - // - // allocator access: - Allocator BOOST_REGEX_CALL get_allocator()const; - // - // locale: - locale_type BOOST_REGEX_CALL imbue(locale_type l){ return traits_inst.imbue(l); } - locale_type BOOST_REGEX_CALL getloc()const{ return traits_inst.getloc(); } - // - // flags: - flag_type BOOST_REGEX_CALL getflags()const - { return flags(); } - // - // str: - std::basic_string BOOST_REGEX_CALL str()const - { - std::basic_string result; - if(this->error_code() == 0) - result = std::basic_string(_expression, _expression_len); - return result; - } - // - // begin, end: - const_iterator BOOST_REGEX_CALL begin()const - { return (this->error_code() ? 0 : _expression); } - const_iterator BOOST_REGEX_CALL end()const - { return (this->error_code() ? 0 : _expression + _expression_len); } - // - // swap: - void BOOST_REGEX_CALL swap(reg_expression&)throw(); - // - // size: - size_type BOOST_REGEX_CALL size()const - { return (this->error_code() ? 0 : _expression_len); } - // - // max_size: - size_type BOOST_REGEX_CALL max_size()const - { return UINT_MAX; } - // - // empty: - bool BOOST_REGEX_CALL empty()const - { return 0 != this->error_code(); } - - unsigned BOOST_REGEX_CALL mark_count()const { return (this->error_code() ? 0 : marks); } - bool BOOST_REGEX_CALL operator==(const reg_expression&)const; - bool BOOST_REGEX_CALL operator<(const reg_expression&)const; - // - // The following are deprecated as public interfaces - // but are available for compatibility with earlier versions. - allocator_type BOOST_REGEX_CALL allocator()const; - const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); } - unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal); - unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); } - // - // this should be private but template friends don't work: - const traits_type& get_traits()const { return traits_inst; } - unsigned int BOOST_REGEX_CALL error_code()const - { - return error_code_; - } - -private: - traits_type traits_inst; - re_detail::raw_storage data; - unsigned _restart_type; - unsigned marks; - int repeats; - unsigned char* startmap; - std::size_t _expression_len; - std::size_t _leading_len; - const charT* _leading_string; - std::size_t _leading_string_len; - re_detail::kmp_info* pkmp; - unsigned error_code_; - charT* _expression; - - void BOOST_REGEX_CALL compile_maps(); - void BOOST_REGEX_CALL compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal = 0)const; - bool BOOST_REGEX_CALL probe_start(re_detail::re_syntax_base* node, charT c, re_detail::re_syntax_base* terminal)const; - bool BOOST_REGEX_CALL probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const; - void BOOST_REGEX_CALL fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces); - void BOOST_REGEX_CALL move_offsets(re_detail::re_syntax_base* j, unsigned size); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set(const charT*& first, const charT* last); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_narrow_type&); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_wide_type&); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot = false); - unsigned int BOOST_REGEX_CALL parse_inner_set(const charT*& first, const charT* last); - - re_detail::re_syntax_base* BOOST_REGEX_CALL add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size = sizeof(re_detail::re_syntax_base)); - re_detail::re_syntax_base* BOOST_REGEX_CALL add_literal(re_detail::re_syntax_base* dat, charT c); - charT BOOST_REGEX_CALL parse_escape(const charT*& first, const charT* last); - void BOOST_REGEX_CALL parse_range(const charT*& first, const charT* last, unsigned& min, unsigned& max); - bool BOOST_REGEX_CALL skip_space(const charT*& first, const charT* last); - unsigned int BOOST_REGEX_CALL probe_restart(re_detail::re_syntax_base* dat); - unsigned int BOOST_REGEX_CALL fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end); - void BOOST_REGEX_CALL fail(unsigned int err); - -protected: - static int BOOST_REGEX_CALL repeat_count(const reg_expression& e) - { return e.repeats; } - static unsigned int BOOST_REGEX_CALL restart_type(const reg_expression& e) - { return e._restart_type; } - static const re_detail::re_syntax_base* BOOST_REGEX_CALL first(const reg_expression& e) - { return (const re_detail::re_syntax_base*)e.data.data(); } - static const unsigned char* BOOST_REGEX_CALL get_map(const reg_expression& e) - { return e.startmap; } - static std::size_t BOOST_REGEX_CALL leading_length(const reg_expression& e) - { return e._leading_len; } - static const re_detail::kmp_info* get_kmp(const reg_expression& e) - { return e.pkmp; } - static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&); - static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&); -}; - -#ifdef BOOST_MSVC -#pragma warning (pop) -#endif - -template -inline void BOOST_REGEX_CALL reg_expression::swap(reg_expression& that)throw() -{ - // this is not as efficient as it should be, - // however swapping traits classes is problematic - // so just use 'brute force' method for now: - reg_expression e(that); - that = *this; - *this = e; -} - - -// -// class match_results and match_results_base -// handles what matched where - -template -struct sub_match -{ - typedef typename re_detail::regex_iterator_traits::value_type value_type; -#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - typedef std::ptrdiff_t difference_type; -#else - typedef typename re_detail::regex_iterator_traits::difference_type difference_type; -#endif - typedef iterator iterator_type; - - iterator first; - iterator second; - bool matched; - - operator std::basic_string ()const - { - std::basic_string result; - std::size_t len = boost::re_detail::distance((iterator)first, (iterator)second); - result.reserve(len); - iterator i = first; - while(i != second) - { - result.append(1, *i); - ++i; - } - return result; - } - #ifdef BOOST_OLD_REGEX_H - // - // the following are deprecated, do not use!! - // - operator int()const; - operator unsigned int()const; - operator short()const - { - return (short)(int)(*this); - } - operator unsigned short()const - { - return (unsigned short)(unsigned int)(*this); - } - #endif - sub_match() { matched = false; } - sub_match(iterator i) : first(i), second(i), matched(false) {} - - bool operator==(const sub_match& that)const - { - return (first == that.first) && (second == that.second) && (matched == that.matched); - } - bool BOOST_REGEX_CALL operator !=(const sub_match& that)const - { return !(*this == that); } - - difference_type BOOST_REGEX_CALL length()const - { - difference_type n = boost::re_detail::distance((iterator)first, (iterator)second); - return n; - } -}; - -#ifdef BOOST_OLD_REGEX_H -namespace re_detail{ -template -int do_toi(iterator i, iterator j, char c, int radix) -{ - std::string s(i, j); - char* p; - int result = std::strtol(s.c_str(), &p, radix); -#ifndef BOOST_NO_EXCEPTIONS - if(*p)throw bad_pattern("Bad sub-expression"); -#endif - BOOST_REGEX_NOEH_ASSERT(0 == *p) - return result; -} - -// -// helper: -template -int do_toi(I& i, I j, charT c) -{ - int result = 0; - while((i != j) && (isdigit(*i))) - { - result = result*10 + (*i - '0'); - ++i; - } - return result; -} -} - - -template -sub_match::operator int()const -{ - iterator i = first; - iterator j = second; -#ifndef BOOST_NO_EXCEPTIONS - if(i == j)throw bad_pattern("Bad sub-expression"); -#endif - BOOST_REGEX_NOEH_ASSERT(i != j) - int neg = 1; - if((i != j) && (*i == '-')) - { - neg = -1; - ++i; - } - neg *= re_detail::do_toi(i, j, *i); -#ifndef BOOST_NO_EXCEPTIONS - if(i != j)throw bad_pattern("Bad sub-expression"); -#endif - BOOST_REGEX_NOEH_ASSERT(i == j) - return neg; -} -template -sub_match::operator unsigned int()const -{ - iterator i = first; - iterator j = second; -#ifndef BOOST_NO_EXCEPTIONS - if(i == j) - throw bad_pattern("Bad sub-expression"); -#endif - BOOST_REGEX_NOEH_ASSERT(i != j) - return re_detail::do_toi(i, j, *first); -} -#endif - -namespace re_detail{ - -template ::type) > -class match_results_base -{ -public: - typedef Allocator alloc_type; - typedef typename boost::detail::rebind_allocator::type iterator_alloc; - typedef typename iterator_alloc::size_type size_type; -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::value_type char_type; -#else - typedef std::ptrdiff_t difference_type; - typedef typename re_detail::regex_iterator_traits::value_type char_type; -#endif - typedef sub_match value_type; - typedef iterator iterator_type; - -protected: - typedef typename boost::detail::rebind_allocator::type c_alloc; - - struct c_reference : public c_alloc - { - std::size_t cmatches; - unsigned count; - sub_match head, tail, re_null; - unsigned int lines; - iterator line_pos, base; - c_reference(const Allocator& a) - : c_alloc(a), cmatches(0), count(0), lines(0) { } - - bool operator==(const c_reference& that)const - { - return (cmatches == that.cmatches) && - (count == that.count) && - (head == that.head) && - (tail == that.tail) && - (lines == that.lines) && - (base == that.base); - } - bool operator!=(const c_reference& that)const - { return !(*this == that); } - }; - - c_reference* ref; - - void BOOST_REGEX_CALL cow(); - - // protected contructor for derived class... - match_results_base(bool){} - void BOOST_REGEX_CALL m_free(); - -public: - - match_results_base(const Allocator& a = Allocator()); - - match_results_base(const match_results_base& m) - { - ref = m.ref; - ++(ref->count); - } - - match_results_base& BOOST_REGEX_CALL operator=(const match_results_base& m); - - ~match_results_base() - { - m_free(); - } - - size_type BOOST_REGEX_CALL size()const - { - //return (*this)[0].matched ? ref->cmatches : 0; - return ref->cmatches; - } - - const sub_match& BOOST_REGEX_CALL operator[](int n) const - { - if((n >= 0) && ((unsigned int)n < ref->cmatches)) - return *(sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match)*n); - return (n == -1) ? ref->head : (n == -2) ? ref->tail : ref->re_null; - } - - Allocator BOOST_REGEX_CALL allocator()const; - - difference_type BOOST_REGEX_CALL length(unsigned int sub = 0)const - { - jm_assert(ref->cmatches); - const sub_match& m = (*this)[sub]; - if(m.matched == false) - return 0; - difference_type n = boost::re_detail::distance((iterator)m.first, (iterator)m.second); - return n; - } - - std::basic_string str(int i)const - { - return static_cast >((*this)[i]); - } - - unsigned int BOOST_REGEX_CALL line()const - { - return ref->lines; - } - - difference_type BOOST_REGEX_CALL position(unsigned int sub = 0)const - { - jm_assert(ref->cmatches); - const sub_match& s = (*this)[sub]; - if(s.matched == false) - return -1; - difference_type n = boost::re_detail::distance((iterator)(ref->base), (iterator)(s.first)); - return n; - } - - iterator BOOST_REGEX_CALL line_start()const - { - return ref->line_pos; - } - - void swap(match_results_base& that) - { - c_reference* t = that.ref; - that.ref = ref; - ref = t; - } - - bool operator==(const match_results_base& that)const; - bool operator<(const match_results_base& that)const - { return position() < that.position(); } - - friend class match_results; - - void BOOST_REGEX_CALL set_size(size_type n); - void BOOST_REGEX_CALL set_size(size_type n, iterator i, iterator j); - void BOOST_REGEX_CALL maybe_assign(const match_results_base& m); - void BOOST_REGEX_CALL init_fail(iterator i, iterator j); - - void BOOST_REGEX_CALL set_first(iterator i); - void BOOST_REGEX_CALL set_first(iterator i, std::size_t pos); - - void BOOST_REGEX_CALL set_second(iterator i) - { - cow(); - ((sub_match*)(ref+1))->second = i; - ((sub_match*)(ref+1))->matched = true; - ref->tail.first = i; - ref->tail.matched = (ref->tail.first == ref->tail.second) ? false : true; - } - - void BOOST_REGEX_CALL set_second(iterator i, std::size_t pos, bool m = true) - { - cow(); - ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->second = i; - ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->matched = m; - if(pos == 0) - { - ref->tail.first = i; - ref->tail.matched = (ref->tail.first == ref->tail.second) ? false : true; - } - } - - void BOOST_REGEX_CALL set_line(unsigned int i, iterator pos) - { - ref->lines = i; - ref->line_pos = pos; - } - - void BOOST_REGEX_CALL set_base(iterator pos) - { - ref->base = pos; - } -}; - -template -void BOOST_REGEX_CALL match_results_base::set_first(iterator i) -{ - cow(); - ref->head.second = i; - ref->head.matched = (ref->head.first == ref->head.second) ? false : true; - sub_match* p1 = (sub_match*)(ref+1); - sub_match* p2 = p1 + ref->cmatches; - p1->first = i; - p1->matched = false; - ++p1; - while(p1 != p2) - { - p1->matched = false; - p1->first = ref->tail.second; - p1->second = ref->tail.second; - ++p1; - } -} - -template -void BOOST_REGEX_CALL match_results_base::set_first(iterator i, std::size_t pos) -{ - cow(); - ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->first = i; - if(pos == 0) - { - ref->head.second = i; - ref->head.matched = (ref->head.first == ref->head.second) ? false : true; - sub_match* p1 = (sub_match*)(ref+1); - sub_match* p2 = p1 + ref->cmatches; - p1->first = i; - p1->matched = false; - ++p1; - while(p1 != p2) - { - p1->matched = false; - p1->first = ref->tail.second; - p1->second = ref->tail.second; - ++p1; - } - } -} - - -template -match_results_base::match_results_base(const Allocator& a) -{ - ref = (c_reference*)c_alloc(a).allocate(sizeof(sub_match) + sizeof(c_reference)); - BOOST_REGEX_NOEH_ASSERT(ref) -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - new (ref) c_reference(a); - ref->cmatches = 1; - ref->count = 1; - // construct the sub_match: -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - new ((sub_match*)(ref+1)) sub_match(); -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - ::boost::re_detail::pointer_destroy(ref); - throw; - } - } - catch(...) - { - c_alloc(a).deallocate((char*)(void*)ref, sizeof(sub_match) + sizeof(c_reference)); - throw; - } -#endif -} - -template -Allocator BOOST_REGEX_CALL match_results_base::allocator()const -{ - return *((c_alloc*)ref); -} - -template -inline match_results_base& BOOST_REGEX_CALL match_results_base::operator=(const match_results_base& m) -{ - if(ref != m.ref) - { - m_free(); - ref = m.ref; - ++(ref->count); - } - return *this; -} - - -template -void BOOST_REGEX_CALL match_results_base::m_free() -{ - if(--(ref->count) == 0) - { - c_alloc a(*ref); - sub_match* p1, *p2; - p1 = (sub_match*)(ref+1); - p2 = p1 + ref->cmatches; - while(p1 != p2) - { - ::boost::re_detail::pointer_destroy(p1); - ++p1; - } - ::boost::re_detail::pointer_destroy(ref); - a.deallocate((char*)(void*)ref, sizeof(sub_match) * ref->cmatches + sizeof(c_reference)); - } -} - -template -bool match_results_base::operator==(const match_results_base& that)const -{ - if(*ref != *(that.ref)) - return false; - const sub_match* p1 = (sub_match*)(ref+1); - const sub_match* p2 = p1 + ref->cmatches; - const sub_match* p3 = (sub_match*)(that.ref+1); - while(p1 != p2) - { - if(*p1 != *p3) - return false; - ++p1; - ++p3; - } - return true; -} - -template -void BOOST_REGEX_CALL match_results_base::set_size(size_type n) -{ - if(ref->cmatches != n) - { - c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match) * n + sizeof(c_reference)); - BOOST_REGEX_NOEH_ASSERT(newref) -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - new (newref) c_reference(*ref); - newref->count = 1; - newref->cmatches = n; - sub_match* p1, *p2; - p1 = (sub_match*)(newref+1); - p2 = p1 + newref->cmatches; -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - while(p1 != p2) - { - new (p1) sub_match(); - ++p1; - } - m_free(); -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - p2 = (sub_match*)(newref+1); - while(p2 != p1) - { - ::boost::re_detail::pointer_destroy(p2); - ++p2; - } - ::boost::re_detail::pointer_destroy(ref); - throw; - } -#endif - ref = newref; -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - ref->deallocate((char*)(void*)newref, sizeof(sub_match) * n + sizeof(c_reference)); - throw; - } -#endif - } -} - -template -void BOOST_REGEX_CALL match_results_base::set_size(size_type n, iterator i, iterator j) -{ - if(ref->cmatches != n) - { - c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match) * n + sizeof(c_reference)); - BOOST_REGEX_NOEH_ASSERT(newref) -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - new (newref) c_reference(*ref); - newref->count = 1; - newref->cmatches = n; - sub_match* p1 = (sub_match*)(newref+1); - sub_match* p2 = p1 + newref->cmatches; -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - while(p1 != p2) - { - new (p1) sub_match(j); - ++p1; - } - m_free(); -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - p2 = (sub_match*)(newref+1); - while(p2 != p1) - { - ::boost::re_detail::pointer_destroy(p2); - ++p2; - } - ::boost::re_detail::pointer_destroy(ref); - throw; - } -#endif - ref = newref; -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - ref->deallocate((char*)(void*)newref, sizeof(sub_match) * n + sizeof(c_reference)); - throw; - } -#endif - } - else - { - cow(); - // set iterators to be i, matched to false: - sub_match* p1, *p2; - p1 = (sub_match*)(ref+1); - p2 = p1 + ref->cmatches; - while(p1 != p2) - { - p1->first = j; - p1->second = j; - p1->matched = false; - ++p1; - } - } - ref->head.first = i; - ref->tail.second = j; - ref->head.matched = ref->tail.matched = true; - ref->re_null.first = ref->re_null.second = j; - ref->re_null.matched = false; -} - -template -inline void BOOST_REGEX_CALL match_results_base::init_fail(iterator i, iterator j) -{ - set_size(ref->cmatches, i, j); -} - -template -void BOOST_REGEX_CALL match_results_base::maybe_assign(const match_results_base& m) -{ - sub_match* p1, *p2; - p1 = (sub_match*)(ref+1); - p2 = (sub_match*)(m.ref+1); - iterator base = (*this)[-1].first; - std::size_t len1 = 0; - std::size_t len2 = 0; - std::size_t base1 = 0; - std::size_t base2 = 0; - std::size_t i; - for(i = 0; i < ref->cmatches; ++i) - { - // - // leftmost takes priority over longest: - base1 = boost::re_detail::distance(base, p1->first); - base2 = boost::re_detail::distance(base, p2->first); - if(base1 < base2) return; - if(base2 < base1) break; - - len1 = boost::re_detail::distance(p1->first, p1->second); - len2 = boost::re_detail::distance(p2->first, p2->second); - if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) - break; - if((p1->matched == true) && (p2->matched == false)) - return; - ++p1; - ++p2; - } - if(i == ref->cmatches) - return; - if(base2 < base1) - *this = m; - else if((len2 > len1) || ((p1->matched == false) && (p2->matched == true)) ) - *this = m; -} - -template -void BOOST_REGEX_CALL match_results_base::cow() -{ - if(ref->count > 1) - { - c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match) * ref->cmatches + sizeof(c_reference)); - BOOST_REGEX_NOEH_ASSERT(newref) -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - new (newref) c_reference(*ref); - newref->count = 1; - sub_match* p1 = (sub_match*)(newref+1); - sub_match* p2 = p1 + newref->cmatches; - sub_match* p3 = (sub_match*)(ref+1); -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - while(p1 != p2) - { - new (p1) sub_match(*p3); - ++p1; - ++p3; - } -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - p2 = (sub_match*)(newref+1); - while(p2 != p1) - { - ::boost::re_detail::pointer_destroy(p2); - ++p2; - } - ::boost::re_detail::pointer_destroy(ref); - throw; - } -#endif - --(ref->count); - ref = newref; -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - ref->deallocate((char*)(void*)newref, sizeof(sub_match) * ref->cmatches + sizeof(c_reference)); - throw; - } -#endif - } -} - -} // namespace re_detail - -// -// class match_results -// encapsulates match_results_base, does a deep copy rather than -// reference counting to ensure thread safety when copying -// other match_results instances - -template -class match_results : public re_detail::match_results_base -{ - typedef re_detail::match_results_base base_type; -public: - - typedef typename base_type::alloc_type alloc_type; - typedef typename base_type::size_type size_type; - typedef typename base_type::char_type char_type; - typedef typename base_type::value_type value_type; - typedef typename base_type::difference_type difference_type; - typedef typename base_type::iterator_type iterator_type; - - explicit match_results(const Allocator& a = Allocator()) - : re_detail::match_results_base(a){} - - match_results(const re_detail::match_results_base& m) - : re_detail::match_results_base(m){} - - match_results& operator=(const re_detail::match_results_base& m) - { - // shallow copy - base_type::operator=(m); - return *this; - } - - match_results(const match_results& m); - match_results& operator=(const match_results& m); - // - // the following function definitions should *not* be required, except - // when this class is used as a template inside another template definition, - // in which members of the base class are not visible to the calling code. - // As a workaround we define simple forwarding functions: - // - size_type size()const - { return static_cast(this)->size(); } - - const sub_match& operator[](int n) const - { return (*static_cast(this))[n]; } - - Allocator allocator()const - { return static_cast(this)->allocator(); } - - difference_type length(int sub = 0)const - { return static_cast(this)->length(sub); } - - difference_type position(unsigned int sub = 0)const - { return static_cast(this)->position(sub); } - - unsigned int line()const - { return static_cast(this)->line(); } - - iterator line_start()const - { return static_cast(this)->line_start(); } - - std::basic_string str(int sub = 0)const - { return static_cast(this)->str(sub); } - - void swap(match_results& that) - { static_cast(this)->swap(that); } - - bool operator==(const match_results& that)const - { return static_cast(*this) == static_cast(that); } - - bool operator<(const match_results& that) const - { return position() < that.position(); } -}; - -template -match_results::match_results(const match_results& m) - : re_detail::match_results_base(false) -{ - this->ref = - reinterpret_cast::c_reference *> - (m.ref->allocate(sizeof(sub_match) * m.ref->cmatches + - sizeof(typename re_detail::match_results_base::c_reference))); - BOOST_REGEX_NOEH_ASSERT(this->ref) -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - new (this->ref) typename re_detail::match_results_base::c_reference(*m.ref); - this->ref->count = 1; - sub_match* p1 = (sub_match*)(this->ref+1); - sub_match* p2 = p1 + this->ref->cmatches; - sub_match* p3 = (sub_match*)(m.ref+1); -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - while(p1 != p2) - { - new (p1) sub_match(*p3); - ++p1; - ++p3; - } -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - p2 = (sub_match*)(this->ref+1); - while(p2 != p1) - { - re_detail::pointer_destroy(p2); - ++p2; - } - re_detail::pointer_destroy(this->ref); - throw; - } - } - catch(...) - { - m.ref->deallocate((char*)(void*)this->ref, sizeof(sub_match) * m.ref->cmatches + sizeof(typename re_detail::match_results_base::c_reference)); - throw; - } -#endif -} - -template -match_results& match_results::operator=(const match_results& m) -{ - match_results t(m); - this->swap(t); - return *this; -} - -namespace re_detail{ -template -iterator BOOST_REGEX_CALL re_is_set_member(iterator next, - iterator last, - const re_set_long* set_, - const reg_expression& e); -} // namepsace re_detail - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#ifndef BOOST_REGEX_COMPILE_HPP -#include -#endif - -// -// template instances: -// -#define BOOST_REGEX_CHAR_T char -#ifdef BOOST_REGEX_NARROW_INSTANTIATE -# define BOOST_REGEX_INSTANTIATE -#endif -#include -#undef BOOST_REGEX_CHAR_T -#ifdef BOOST_REGEX_INSTANTIATE -# undef BOOST_REGEX_INSTANTIATE -#endif - -#ifndef BOOST_NO_WREGEX -#define BOOST_REGEX_CHAR_T wchar_t -#ifdef BOOST_REGEX_WIDE_INSTANTIATE -# define BOOST_REGEX_INSTANTIATE -#endif -#include -#undef BOOST_REGEX_CHAR_T -#ifdef BOOST_REGEX_INSTANTIATE -# undef BOOST_REGEX_INSTANTIATE -#endif -#endif - - -namespace boost{ -#ifdef BOOST_REGEX_NO_FWD -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(char)> regex; -#ifndef BOOST_NO_WREGEX -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(wchar_t)> wregex; -#endif -#endif - -typedef match_results cmatch; -typedef match_results smatch; -#ifndef BOOST_NO_WREGEX -typedef match_results wcmatch; -typedef match_results wsmatch; -#endif - -} // namespace boost -#ifndef BOOST_REGEX_MATCH_HPP -#include -#endif -#ifndef BOOST_REGEX_FORMAT_HPP -#include -#endif -#ifndef BOOST_REGEX_SPLIT_HPP -#include -#endif - -#endif // __cplusplus - -#endif // include - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/boost/regex/v3/regex_compile.hpp b/include/boost/regex/v3/regex_compile.hpp deleted file mode 100644 index b1b7e972..00000000 --- a/include/boost/regex/v3/regex_compile.hpp +++ /dev/null @@ -1,2122 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_compile.hpp - * VERSION see - * DESCRIPTION: Declares reg_expression<> member functions. This is - * an internal header file, do not include directly. - */ - -#ifndef BOOST_REGEX_COMPILE_HPP -#define BOOST_REGEX_COMPILE_HPP - -namespace boost{ -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -w-8004 -#endif - namespace re_detail{ - - -template -struct kmp_translator -{ - typedef typename traits::char_type char_type; - bool icase; - const traits* pt; - kmp_translator(bool c, traits* p) : icase(c), pt(p) {} - char_type operator()(char_type c) - { - return pt->translate(c, icase); - } -}; - - -template -bool BOOST_REGEX_CALL re_maybe_set_member(charT c, - const re_set_long* set_, - const reg_expression& e) -{ - const charT* p = reinterpret_cast(set_+1); - bool icase = e.flags() & regbase::icase; - charT col = e.get_traits().translate(c, icase); - for(unsigned int i = 0; i < set_->csingles; ++i) - { - if(col == *p) - return set_->isnot ? false : true; - - while(*p)++p; - ++p; // skip null - } - return set_->isnot ? true : false; -} - -} // namespace re_detail - - -template -inline bool BOOST_REGEX_CALL reg_expression::can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&) -{ - if((traits_size_type)(traits_uchar_type)c >= 256) - return true; - return BOOST_REGEX_MAKE_BOOL(_map[(traits_uchar_type)c] & mask); -} - -template -inline bool BOOST_REGEX_CALL reg_expression::can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&) -{ - return BOOST_REGEX_MAKE_BOOL(_map[(traits_uchar_type)c] & mask); -} - -template -reg_expression::reg_expression(const Allocator& a) - : regbase(), data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ -} - -template -reg_expression::reg_expression(const charT* p, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p, f | regbase::use_except); -} - -template -reg_expression::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p1, p2, f | regbase::use_except); -} - -template -reg_expression::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p, p + len, f | regbase::use_except); -} - -template -reg_expression::reg_expression(const reg_expression& e) - : regbase(e), data(e.allocator()), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - // - // we do a deep copy only if e is a valid expression, otherwise fail. - // - if(e.error_code() == 0) - { - const charT* pe = e.expression(); - set_expression(pe, pe + e._expression_len, e.flags() | regbase::use_except); - } - else - { - _flags = e.flags() & ~(regbase::use_except); - fail(e.error_code()); - } -} - -template -reg_expression::~reg_expression() -{ - if(pkmp) - re_detail::kmp_free(pkmp, data.allocator()); -} - -template -reg_expression& BOOST_REGEX_CALL reg_expression::operator=(const reg_expression& e) -{ - // - // we do a deep copy only if e is a valid expression, otherwise fail. - // - if(this == &e) return *this; - _flags = use_except; - fail(e.error_code()); - if(error_code() == 0) - set_expression(e._expression, e._expression + e._expression_len, e.flags() | regbase::use_except); - return *this; -} - -template -inline bool BOOST_REGEX_CALL reg_expression::operator==(const reg_expression& e)const -{ - return (_flags == e.flags()) - && (_expression_len == e._expression_len) - && (std::memcmp(_expression, e._expression, _expression_len * sizeof(charT)) == 0); -} - -template -bool BOOST_REGEX_CALL reg_expression::operator<(const reg_expression& e)const -{ - // - // we can't offer a diffinitive ordering, but we can be consistant: - if(_flags != e.flags()) return _flags < e.flags(); - if(_expression_len != e._expression_len) return _expression_len < e._expression_len; - return std::memcmp(expression(), e.expression(), _expression_len); -} - -template -Allocator BOOST_REGEX_CALL reg_expression::allocator()const -{ - return data.allocator(); -} - -template -Allocator BOOST_REGEX_CALL reg_expression::get_allocator()const -{ - return data.allocator(); -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::parse_inner_set(const charT*& first, const charT* last) -{ - // - // we have an inner [...] construct - // - jm_assert(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) == traits_type::syntax_open_set); - const charT* base = first; - while( (first != last) - && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) != traits_type::syntax_close_set) ) - ++first; - if(first == last) - return 0; - ++first; - if((first-base) < 5) - return 0; - if(*(base+1) != *(first-2)) - return 0; - unsigned int result = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); - if((result == traits_type::syntax_colon) && ((first-base) == 5)) - { - unsigned type = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); - if((type == traits_type::syntax_left_word) || (type == traits_type::syntax_right_word)) - return type; - } - return ((result == traits_type::syntax_colon) || (result == traits_type::syntax_dot) || (result == traits_type::syntax_equal)) ? result : 0; -} - - -template -bool BOOST_REGEX_CALL reg_expression::skip_space(const charT*& first, const charT* last) -{ - // - // returns true if we get to last: - // - while((first != last) && (traits_inst.is_class(*first, traits_type::char_class_space) == true)) - { - ++first; - } - return first == last; -} - -template -void BOOST_REGEX_CALL reg_expression::parse_range(const charT*& ptr, const charT* end, unsigned& min, unsigned& max) -{ - // - // we have {x} or {x,} or {x,y} NB no spaces inside braces - // anything else is illegal - // On input ptr points to "{" - // - ++ptr; - if(skip_space(ptr, end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_digit) - { - fail(REG_BADBR); - return; - } - min = traits_inst.toi(ptr, end, 10); - if(skip_space(ptr, end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_comma) - { - //we have a second interval: - ++ptr; - if(skip_space(ptr, end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_digit) - max = traits_inst.toi(ptr, end, 10); - else - max = (unsigned)-1; - } - else - max = min; - - // validate input: - if(skip_space(ptr, end)) - { - fail(REG_EBRACE); - return; - } - if(max < min) - { - fail(REG_ERANGE); - return; - } - if(_flags & bk_braces) - { - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_slash) - { - fail(REG_BADBR); - return; - } - else - { - // back\ is OK now check the } - ++ptr; - if((ptr == end) || (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_close_brace)) - { - fail(REG_BADBR); - return; - } - } - } - else if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_close_brace) - { - fail(REG_BADBR); - return; - } -} - -template -charT BOOST_REGEX_CALL reg_expression::parse_escape(const charT*& first, const charT* last) -{ - charT c(*first); - traits_size_type c_unsigned = (traits_size_type)(traits_uchar_type)*first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c_unsigned); - switch(syntax) - { - case traits_type::syntax_a: - c = '\a'; - ++first; - break; - case traits_type::syntax_f: - c = '\f'; - ++first; - break; - case traits_type::syntax_n: - c = '\n'; - ++first; - break; - case traits_type::syntax_r: - c = '\r'; - ++first; - break; - case traits_type::syntax_t: - c = '\t'; - ++first; - break; - case traits_type::syntax_v: - c = '\v'; - ++first; - break; - case traits_type::syntax_x: - ++first; - if(first == last) - { - fail(REG_EESCAPE); - break; - } - // maybe have \x{ddd} - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*first)) == traits_type::syntax_open_brace) - { - ++first; - if(first == last) - { - fail(REG_EESCAPE); - break; - } - if(traits_inst.is_class(*first, traits_type::char_class_xdigit) == false) - { - fail(REG_BADBR); - break; - } - c = (charT)traits_inst.toi(first, last, -16); - if((first == last) || (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*first)) != traits_type::syntax_close_brace)) - { - fail(REG_BADBR); - } - ++first; - break; - } - else - { - if(traits_inst.is_class(*first, traits_type::char_class_xdigit) == false) - { - fail(REG_BADBR); - break; - } - c = (charT)traits_inst.toi(first, last, -16); - } - break; - case traits_type::syntax_c: - ++first; - if(first == last) - { - fail(REG_EESCAPE); - break; - } - if(((traits_uchar_type)(*first) < (traits_uchar_type)'@') - || ((traits_uchar_type)(*first) > (traits_uchar_type)127) ) - { - fail(REG_EESCAPE); - return (charT)0; - } - c = (charT)((traits_uchar_type)(*first) - (traits_uchar_type)'@'); - ++first; - break; - case traits_type::syntax_e: - c = (charT)27; - ++first; - break; - case traits_type::syntax_digit: - c = (charT)traits_inst.toi(first, last, -8); - break; - default: - //c = *first; - ++first; - } - return c; -} - -template -void BOOST_REGEX_CALL reg_expression::compile_maps() -{ - re_detail::re_syntax_base* record = static_cast(data.data()); - // always compile the first _map: - std::memset(startmap, 0, 256); - record->can_be_null = 0; - compile_map(record, startmap, 0, re_detail::mask_all); - - while(record->type != re_detail::syntax_element_match) - { - if((record->type == re_detail::syntax_element_alt) || (record->type == re_detail::syntax_element_rep)) - { - std::memset(&(static_cast(record)->_map), 0, 256); - record->can_be_null = 0; - compile_map(record->next.p, static_cast(record)->_map, &(record->can_be_null), re_detail::mask_take, static_cast(record)->alt.p); - compile_map(static_cast(record)->alt.p, static_cast(record)->_map, &(record->can_be_null), re_detail::mask_skip); - if(record->type == re_detail::syntax_element_rep) - { - re_detail::re_repeat* rep = static_cast(record); - // set whether this is a singleton repeat or not: - if(rep->next.p->next.p->next.p == rep->alt.p) - { - rep->singleton = true; - } - else - rep->singleton = false; - } - } - else - { - record->can_be_null = 0; - compile_map(record, 0, &(record->can_be_null), re_detail::mask_all); - } - record = record->next.p; - } - record->can_be_null = re_detail::mask_all; -} - -template -bool BOOST_REGEX_CALL reg_expression::probe_start( - re_detail::re_syntax_base* node, charT cc, re_detail::re_syntax_base* terminal) const -{ - unsigned int c; - - switch(node->type) - { - case re_detail::syntax_element_startmark: - if(static_cast(node)->index == -1) - { - return probe_start(node->next.p->next.p, cc, terminal) - && probe_start(static_cast(node->next.p)->alt.p, cc, terminal); - } - // fall through: - case re_detail::syntax_element_endmark: - case re_detail::syntax_element_start_line: - case re_detail::syntax_element_word_boundary: - case re_detail::syntax_element_buffer_start: - case re_detail::syntax_element_restart_continue: - // doesn't tell us anything about the next character, so: - return probe_start(node->next.p, cc, terminal); - case re_detail::syntax_element_literal: - // only the first character of the literal can match: - // note these have already been translated: - if(*reinterpret_cast(static_cast(node)+1) == traits_inst.translate(cc, (_flags & regbase::icase))) - return true; - return false; - case re_detail::syntax_element_end_line: - // next character (if there is one!) must be a newline: - if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase)))) - return true; - return false; - case re_detail::syntax_element_wild: - return true; - case re_detail::syntax_element_match: - return true; - case re_detail::syntax_element_within_word: - case re_detail::syntax_element_word_start: - return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word); - case re_detail::syntax_element_word_end: - // what follows must not be a word character, - return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word) ? false : true; - case re_detail::syntax_element_buffer_end: - // we can be null, nothing must follow, - // NB we assume that this is followed by - // re_detail::syntax_element_match, if its not then we can - // never match anything anyway!! - return false; - case re_detail::syntax_element_soft_buffer_end: - // we can be null, only newlines must follow, - // NB we assume that this is followed by - // re_detail::syntax_element_match, if its not then we can - // never match anything anyway!! - return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase))); - case re_detail::syntax_element_backref: - // there's no easy way to determine this - // which is not to say it can't be done! - // for now: - return true; - case re_detail::syntax_element_long_set: - // we can not be null, - // we need to add already translated values in the set - // to values in the _map - return re_detail::re_maybe_set_member(cc, static_cast(node), *this) || (re_detail::re_is_set_member(static_cast(&cc), static_cast(&cc+1), static_cast(node), *this) != &cc); - case re_detail::syntax_element_set: - // set all the elements that are set in corresponding set: - c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regbase::icase)); - return static_cast(node)->_map[c] != 0; - case re_detail::syntax_element_jump: - if(static_cast(node)->alt.p < node) - { - // backwards jump, - // caused only by end of repeat section, we'll treat this - // the same as a match, because the sub-expression has matched. - if(node->next.p == terminal) - return true; // null repeat - we can always take this - else - { - // - // take the jump, add in fix for the fact that if the - // repeat that we're jumping to has non-zero minimum count - // then we need to add in the possiblity that we could still - // skip that repeat. - re_detail::re_syntax_base* next = static_cast(node)->alt.p; - bool b = probe_start(next, cc, terminal); - if((next->type == re_detail::syntax_element_rep) && (static_cast(next)->min != 0)) - { - b = b || probe_start(static_cast(next)->alt.p, cc, terminal); - } - return b; - } - } - else - // take the jump and compile: - return probe_start(static_cast(node)->alt.p, cc, terminal); - case re_detail::syntax_element_alt: - // we need to take the OR of the two alternatives: - return probe_start(static_cast(node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal); - case re_detail::syntax_element_rep: - // we need to take the OR of the two alternatives - if(static_cast(node)->min == 0) - return probe_start(node->next.p, cc, static_cast(node)->alt.p) || probe_start(static_cast(node)->alt.p, cc, terminal); - else - return probe_start(node->next.p, cc, static_cast(node)->alt.p); - case re_detail::syntax_element_combining: - return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regbase::icase))); - } - return false; -} - -template -bool BOOST_REGEX_CALL reg_expression::probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const -{ - switch(node->type) - { - case re_detail::syntax_element_startmark: - case re_detail::syntax_element_endmark: - case re_detail::syntax_element_start_line: - case re_detail::syntax_element_word_boundary: - case re_detail::syntax_element_buffer_start: - case re_detail::syntax_element_restart_continue: - case re_detail::syntax_element_end_line: - case re_detail::syntax_element_word_end: - // doesn't tell us anything about the next character, so: - return probe_start_null(node->next.p, terminal); - case re_detail::syntax_element_match: - case re_detail::syntax_element_buffer_end: - case re_detail::syntax_element_soft_buffer_end: - case re_detail::syntax_element_backref: - return true; - case re_detail::syntax_element_jump: - if(static_cast(node)->alt.p < node) - { - // backwards jump, - // caused only by end of repeat section, we'll treat this - // the same as a match, because the sub-expression has matched. - // this is only caused by NULL repeats as in "(a*)*" or "(\<)*" - // these are really nonsensence and make the matching code much - // harder, it would be nice to get rid of them altogether. - if(node->next.p == terminal) - return true; - else - return probe_start_null(static_cast(node)->alt.p, terminal); - } - else - // take the jump and compile: - return probe_start_null(static_cast(node)->alt.p, terminal); - case re_detail::syntax_element_alt: - // we need to take the OR of the two alternatives: - return probe_start_null(static_cast(node)->alt.p, terminal) || probe_start_null(node->next.p, terminal); - case re_detail::syntax_element_rep: - // only need to consider skipping the repeat: - return probe_start_null(static_cast(node)->alt.p, terminal); - default: - break; - } - return false; -} - -template -void BOOST_REGEX_CALL reg_expression::compile_map( - re_detail::re_syntax_base* node, unsigned char* _map, - unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal)const -{ - if(_map) - { - for(unsigned int i = 0; i < 256; ++i) - { - if(probe_start(node, (charT)i, terminal)) - _map[i] |= mask; - } - } - if(pnull && probe_start_null(node, terminal)) - *pnull |= mask; -} - -template -void BOOST_REGEX_CALL reg_expression::move_offsets(re_detail::re_syntax_base* j, unsigned size) -{ -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4127) -#endif - // move all offsets starting with j->link forward by size - // called after an insert: - j = reinterpret_cast(reinterpret_cast(data.data()) + j->next.i); - while(true) - { - switch(j->type) - { - case re_detail::syntax_element_rep: - static_cast(j)->alt.i += size; - j->next.i += size; - break; - case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - static_cast(j)->alt.i += size; - j->next.i += size; - break; - default: - j->next.i += size; - break; - } - if(j->next.i == size) - break; - j = reinterpret_cast(reinterpret_cast(data.data()) + j->next.i); - } -# ifdef BOOST_MSVC -# pragma warning(pop) -#endif -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot) -{ - typedef typename re_detail::is_byte::width_type width_type; - re_detail::jstack singles(64, data.allocator()); - re_detail::jstack ranges(64, data.allocator()); - re_detail::jstack classes(64, data.allocator()); - re_detail::jstack equivalents(64, data.allocator()); - classes.push(cls); - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - return compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type()); -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set(const charT*& first, const charT* last) -{ - re_detail::jstack singles(64, data.allocator()); - re_detail::jstack ranges(64, data.allocator()); - re_detail::jstack classes(64, data.allocator()); - re_detail::jstack equivalents(64, data.allocator()); - bool has_digraphs = false; - jm_assert(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) == traits_type::syntax_open_set); - ++first; - bool started = false; - bool done = false; - bool isnot = false; - - enum last_type - { - last_single, - last_none, - last_dash - }; - - unsigned l = last_none; - traits_string_type s; - - while((first != last) && !done) - { - traits_size_type c = (traits_size_type)(traits_uchar_type)*first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_caret: - if(!started && !isnot) - { - isnot = true; - } - else - { - s = (charT)c; - goto char_set_literal; - } - break; - case traits_type::syntax_open_set: - { - if((_flags & char_classes) == 0) - { - s = (charT)c; - goto char_set_literal; - } - // check to see if we really have a class: - const charT* base = first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - unsigned int inner_set = parse_inner_set(first, last); - switch(inner_set) - { - case traits_type::syntax_colon: - { - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - boost::uint_fast32_t id = traits_inst.lookup_classname(base+2, first-2); - if(_flags & regbase::icase) - { - if((id == traits_type::char_class_upper) || (id == traits_type::char_class_lower)) - { - id = traits_type::char_class_alpha; - } - } - if(id == 0) - { - fail(REG_ECTYPE); - return 0; - } - classes.push(id); - started = true; - l = last_none; - } - break; - case traits_type::syntax_dot: - // - // we have a collating element [.collating-name.] - // - if(traits_inst.lookup_collatename(s, base+2, first-2)) - { - --first; - if(s.size() > 1) - has_digraphs = true; - if(s.size())goto char_set_literal; - } - fail(REG_ECOLLATE); - return 0; - case traits_type::syntax_equal: - // - // we have an equivalence class [=collating-name=] - // - if(traits_inst.lookup_collatename(s, base+2, first-2)) - { - std::size_t len = s.size(); - if(len) - { - unsigned i = 0; - while(i < len) - { - s[i] = traits_inst.translate(s[i], (_flags & regbase::icase)); - ++i; - } - traits_string_type s2; - traits_inst.transform_primary(s2, s); - equivalents.push(s2); - started = true; - l = last_none; - break; - } - } - fail(REG_ECOLLATE); - return 0; - case traits_type::syntax_left_word: - if((started == false) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) == traits_type::syntax_close_set)) - { - ++first; - return add_simple(0, re_detail::syntax_element_word_start); - } - fail(REG_EBRACK); - return 0; - case traits_type::syntax_right_word: - if((started == false) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) == traits_type::syntax_close_set)) - { - ++first; - return add_simple(0, re_detail::syntax_element_word_end); - } - fail(REG_EBRACK); - return 0; - default: - if(started == false) - { - unsigned int t = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); - if((t != traits_type::syntax_colon) && (t != traits_type::syntax_dot) && (t != traits_type::syntax_equal)) - { - first = base; - s = (charT)c; - goto char_set_literal; - } - } - fail(REG_EBRACK); - return 0; - } - if(first == last) - { - fail(REG_EBRACK); - return 0; - } - continue; - } - case traits_type::syntax_close_set: - if(started == false) - { - s = (charT)c; - goto char_set_literal; - } - done = true; - break; - case traits_type::syntax_dash: - if(!started) - { - s = (charT)c; - goto char_set_literal; - } - ++first; - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*first) == traits_type::syntax_close_set) - { - --first; - s = (charT)c; - goto char_set_literal; - } - if((singles.empty() == true) || (l != last_single)) - { - fail(REG_ERANGE); - return 0; - } - ranges.push(singles.peek()); - if(singles.peek().size() <= 1) // leave digraphs and ligatures in place - singles.pop(); - l = last_dash; - continue; - case traits_type::syntax_slash: - if(_flags & regbase::escape_in_lists) - { - ++first; - if(first == last) - continue; - traits_size_type c = (traits_size_type)(traits_uchar_type)*first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_w: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_word); - started = true; - l = last_none; - ++first; - continue; - case traits_type::syntax_d: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_digit); - started = true; - l = last_none; - ++first; - continue; - case traits_type::syntax_s: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_space); - started = true; - l = last_none; - ++first; - continue; - case traits_type::syntax_l: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_lower); - started = true; - l = last_none; - ++first; - continue; - case traits_type::syntax_u: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_upper); - started = true; - l = last_none; - ++first; - continue; - case traits_type::syntax_W: - case traits_type::syntax_D: - case traits_type::syntax_S: - case traits_type::syntax_U: - case traits_type::syntax_L: - fail(REG_EESCAPE); - return 0; - default: - c = parse_escape(first, last); - --first; - s = (charT)c; - goto char_set_literal; - } - } - else - { - s = (charT)c; - goto char_set_literal; - } - default: - s = (charT)c; - char_set_literal: - unsigned i = 0; - // get string length to stop us going past the end of string (DWA) - std::size_t len = s.size(); - while(i < len) - { - s[i] = traits_inst.translate(s[i], (_flags & regbase::icase)); - ++i; - } - started = true; - if(l == last_dash) - { - ranges.push(s); - l = last_none; - if(s.size() > 1) // add ligatures to singles list as well - singles.push(s); - } - else - { - singles.push(s); - l = last_single; - } - } - ++first; - } - if(!done) - return 0; - - typedef typename re_detail::is_byte::width_type width_type; - - re_detail::re_syntax_base* result; - if(has_digraphs) - result = compile_set_aux(singles, ranges, classes, equivalents, isnot, re_detail::_wide_type()); - else - result = compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type()); - #ifdef __BORLANDC__ - // delayed throw: - if((result == 0) && (_flags & regbase::use_except)) - fail(error_code()); - #endif - return result; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_wide_type&) -{ - size_type base = data.size(); - data.extend(sizeof(re_detail::re_set_long)); - unsigned int csingles = 0; - unsigned int cranges = 0; - boost::uint_fast32_t cclasses = 0; - unsigned int cequivalents = 0; - bool nocollate_state = flags() & regbase::nocollate; - - while(singles.empty() == false) - { - ++csingles; - const traits_string_type& s = singles.peek(); - std::size_t len = (s.size() + 1) * sizeof(charT); - std::memcpy(reinterpret_cast(data.extend(len)), s.c_str(), len); - singles.pop(); - } - while(ranges.empty() == false) - { - traits_string_type c1, c2; - if(nocollate_state) - c1 = ranges.peek(); - else - traits_inst.transform(c1, ranges.peek()); - ranges.pop(); - if(nocollate_state) - c2 = ranges.peek(); - else - traits_inst.transform(c2, ranges.peek()); - ranges.pop(); - if(c1 < c2) - { - // for some reason bc5 crashes when throwing exceptions - // from here - probably an EH-compiler bug, but hard to - // be sure... - // delay throw to later: - #ifdef __BORLANDC__ - boost::uint_fast32_t f = _flags; - _flags &= ~regbase::use_except; - #endif - fail(REG_ERANGE); - #ifdef __BORLANDC__ - _flags = f; - #endif - return 0; - } - ++cranges; - std::size_t len = (re_detail::re_strlen(c1.c_str()) + 1) * sizeof(charT); - std::memcpy(data.extend(len), c1.c_str(), len); - len = (re_detail::re_strlen(c2.c_str()) + 1) * sizeof(charT); - std::memcpy(data.extend(len), c2.c_str(), len); - } - while(classes.empty() == false) - { - cclasses |= classes.peek(); - classes.pop(); - } - while(equivalents.empty() == false) - { - ++cequivalents; - const traits_string_type& s = equivalents.peek(); - std::size_t len = (re_detail::re_strlen(s.c_str()) + 1) * sizeof(charT); - std::memcpy(reinterpret_cast(data.extend(len)), s.c_str(), len); - equivalents.pop(); - } - - re_detail::re_set_long* dat = reinterpret_cast(reinterpret_cast(data.data()) + base); - dat->type = re_detail::syntax_element_long_set; - dat->csingles = csingles; - dat->cranges = cranges; - dat->cclasses = cclasses; - dat->cequivalents = cequivalents; - dat->isnot = isnot; - dat->next.i = 0; - return dat; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_narrow_type&) -{ - re_detail::re_set* dat = reinterpret_cast(data.extend(sizeof(re_detail::re_set))); - std::memset(dat, 0, sizeof(re_detail::re_set)); - - while(singles.empty() == false) - { - dat->_map[(traits_size_type)(traits_uchar_type)*(singles.peek().c_str())] = re_detail::mask_all; - singles.pop(); - } - while(ranges.empty() == false) - { - traits_string_type c1, c2, c3, c4; - - if(flags() & regbase::nocollate) - c1 = ranges.peek(); - else - traits_inst.transform(c1, ranges.peek()); - ranges.pop(); - if(flags() & regbase::nocollate) - c2 = ranges.peek(); - else - traits_inst.transform(c2, ranges.peek()); - ranges.pop(); - - if(c1 < c2) - { - // for some reason bc5 crashes when throwing exceptions - // from here - probably an EH-compiler bug, but hard to - // be sure... - // delay throw to later: - #ifdef __BORLANDC__ - boost::uint_fast32_t f = _flags; - _flags &= ~regbase::use_except; - #endif - fail(REG_ERANGE); - #ifdef __BORLANDC__ - _flags = f; - #endif - return 0; - } - for(unsigned int i = 0; i < 256; ++i) - { - c4 = (charT)i; - if(flags() & regbase::nocollate) - c3 = c4; - else - traits_inst.transform(c3, c4); - if((c3 <= c1) && (c3 >= c2)) - dat->_map[i] = re_detail::mask_all; - } - } - while(equivalents.empty() == false) - { - traits_string_type c1, c2; - for(unsigned int i = 0; i < 256; ++i) - { - c2 = (charT)i; - traits_inst.transform_primary(c1, c2); - if(c1 == equivalents.peek()) - dat->_map[i] = re_detail::mask_all; - } - equivalents.pop(); - } - - boost::uint_fast32_t flags = 0; - while(classes.empty() == false) - { - flags |= classes.peek(); - classes.pop(); - } - if(flags) - { - for(unsigned int i = 0; i < 256; ++i) - { - if(traits_inst.is_class(charT(i), flags)) - dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regbase::icase))] = re_detail::mask_all; - } - } - - if(isnot) - { - for(unsigned int i = 0; i < 256; ++i) - { - dat->_map[i] = !dat->_map[i]; - } - } - - dat->type = re_detail::syntax_element_set; - dat->next.i = 0; - return dat; -} - -#ifndef __CODEGUARD__ -// this must not be inline when Borland's codeguard support is turned -// on, otherwise we _will_ get surious codeguard errors... -inline -#endif - re_detail::re_syntax_base* add_offset(void* base, std::ptrdiff_t off) -{ - return reinterpret_cast(reinterpret_cast(base) + off); -} - - -template -void BOOST_REGEX_CALL reg_expression::fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces) -{ - typedef typename boost::detail::rebind_allocator::type b_alloc; - - register unsigned char* base = reinterpret_cast(b); - register re_detail::re_syntax_base* ptr = b; - bool* pb = 0; - b_alloc a(data.allocator()); -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - pb = a.allocate(cbraces); - BOOST_REGEX_NOEH_ASSERT(pb) - for(unsigned i = 0; i < cbraces; ++i) - pb[i] = false; - - repeats = 0; - - while(ptr->next.i) - { - switch(ptr->type) - { - case re_detail::syntax_element_rep: - jm_assert(data.size() > static_cast(ptr)->alt.i); - static_cast(ptr)->alt.p = add_offset(base, static_cast(ptr)->alt.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & reinterpret_cast(static_cast(ptr)->alt.p)) && (static_cast(ptr)->alt.p != b)) - { - jm_trace("padding mis-aligment in repeat jump to object type: " << static_cast(ptr)->alt.p->type) - //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); - } -#endif - static_cast(ptr)->id = repeats; - ++repeats; - goto rebase; - case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - jm_assert(data.size() > static_cast(ptr)->alt.i); - static_cast(ptr)->alt.p = add_offset(base, static_cast(ptr)->alt.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & reinterpret_cast(static_cast(ptr)->alt.p) && (static_cast(ptr)->alt.p != b))) - { - jm_trace("padding mis-aligment in alternation jump to object type: " << static_cast(ptr)->alt.p->type) - //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); - } -#endif - goto rebase; - case re_detail::syntax_element_backref: - if((static_cast(ptr)->index >= (int)cbraces) || (pb[static_cast(ptr)->index] == false) ) - { - fail(REG_ESUBREG); - a.deallocate(pb, cbraces); - return; - } - goto rebase; - case re_detail::syntax_element_endmark: - if(static_cast(ptr)->index > 0) - pb[static_cast(ptr)->index] = true; - goto rebase; - default: - rebase: - jm_assert(data.size() > ptr->next.i); - ptr->next.p = add_offset(base, ptr->next.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & (int)(ptr->next.p)) && (static_cast(ptr)->alt.p != b)) - { - jm_trace("padding mis-alignment in next record of type " << ptr->next.p->type) - jm_assert(0 == (re_detail::padding_mask & (int)(ptr->next.p))); - } -#endif - ptr = ptr->next.p; - } - } - a.deallocate(pb, cbraces); - pb = 0; -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - if(pb) - a.deallocate(pb, cbraces); - throw; - } -#endif -} - - -template -unsigned int BOOST_REGEX_CALL reg_expression::set_expression(const charT* p, const charT* end, flag_type f) -{ -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4127) -#endif -#ifdef __OpenBSD__ - // strxfrm not working on OpenBSD?? - f |= regbase::nocollate; -#endif - - if(p == expression()) - { - traits_string_type s(p, end); - return set_expression(s.c_str(), s.c_str() + s.size(), f); - } - typedef typename traits_type::sentry sentry_t; - sentry_t sent(traits_inst); - if(sent){ - - const charT* base = p; - data.clear(); - _flags = f; - fail(REG_NOERROR); // clear any error - - if(p >= end) - { - fail(REG_EMPTY); - return error_code(); - } - - const charT* ptr = p; - marks = 0; - re_detail::jstack mark(64, data.allocator()); - re_detail::jstack markid(64, data.allocator()); - std::size_t last_mark_popped = 0; - register traits_size_type c; - register re_detail::re_syntax_base* dat; - - unsigned rep_min = 0; - unsigned rep_max = 0; - - // - // set up header: - // - ++marks; - dat = 0; - - if(_flags & regbase::literal) - { - while(ptr != end) - { - dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regbase::icase))); - ++ptr; - } - } - - while (ptr < end) - { - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_open_bracket: - if(_flags & bk_parens) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - open_bracked_jump: - // extend: - dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace)); - markid.push(marks); - static_cast(dat)->index = marks++; - mark.push(data.index(dat)); - ++ptr; - // - // check for perl like (?...) extention syntax - c = (traits_size_type)(traits_uchar_type)*ptr; - if(((_flags & bk_parens) == 0) && (traits_type::syntax_question == traits_inst.syntax_type(c))) - { - ++ptr; - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_colon: - static_cast(dat)->index = 0; - --marks; - markid.pop(); - markid.push(0); - ++ptr; - continue; - case traits_type::syntax_equal: - static_cast(dat)->index = -1; - markid.pop(); - markid.push(-1); - common_forward_assert: - --marks; - ++ptr; - // extend: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - data.align(); - // - // we don't know what value to put here yet, - // use an arbitrarily large value for now - // and check it later: - static_cast(dat)->alt.i = INT_MAX/2; - mark.push(data.size() - re_detail::re_jump_size); - continue; - case traits_type::syntax_not: - static_cast(dat)->index = -2; - markid.pop(); - markid.push(-2); - goto common_forward_assert; - case traits_type::syntax_hash: - // comment just skip it: - static_cast(dat)->index = 0; - --marks; - markid.pop(); - mark.pop(); - do{ - ++ptr; - c = (traits_size_type)(traits_uchar_type)*ptr; - }while(traits_type::syntax_close_bracket != traits_inst.syntax_type(c)); - ++ptr; - continue; - default: - // - // error, return to standard parsing and let that handle the error: - --ptr; - continue; - } - } - break; - case traits_type::syntax_close_bracket: - if(_flags & bk_parens) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - - close_bracked_jump: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - - if(mark.empty()) - { - fail(REG_EPAREN); - return error_code(); - } - // see if we have an empty alternative: - if(mark.peek() == data.index(dat) ) - { - re_detail::re_syntax_base* para = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - if(para->type == re_detail::syntax_element_jump) - { - fail(REG_EMPTY); - return error_code(); - } - } - - // pop any pushed alternatives and set the target end destination: - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - while(dat->type == re_detail::syntax_element_jump) - { - static_cast(dat)->alt.i = data.size(); - mark.pop(); - if(mark.empty()) - { - fail(REG_EPAREN); - return error_code(); - } - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - } - - dat = add_simple(0, re_detail::syntax_element_endmark, sizeof(re_detail::re_brace)); - static_cast(dat)->index = markid.peek(); - markid.pop(); - last_mark_popped = mark.peek(); - mark.pop(); - ++ptr; - break; - case traits_type::syntax_char: - dat = add_literal(dat, (charT)c); - ++ptr; - break; - case traits_type::syntax_slash: - { - if(++ptr == end) - { - fail(REG_EESCAPE); - return error_code(); - } - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_open_bracket: - if(_flags & bk_parens) - goto open_bracked_jump; - break; - case traits_type::syntax_close_bracket: - if(_flags & bk_parens) - goto close_bracked_jump; - break; - case traits_type::syntax_plus: - if((_flags & bk_plus_qm) && ((_flags & limited_ops) == 0)) - { - rep_min = 1; - rep_max = (unsigned)-1; - goto repeat_jump; - } - break; - case traits_type::syntax_question: - if((_flags & bk_plus_qm) && ((_flags & limited_ops) == 0)) - { - rep_min = 0; - rep_max = 1; - goto repeat_jump; - } - break; - case traits_type::syntax_or: - if(((_flags & bk_vbar) == 0) || (_flags & limited_ops)) - break; - goto alt_string_jump; - case traits_type::syntax_open_brace: - if( ((_flags & bk_braces) == 0) || ((_flags & intervals) == 0)) - break; - - // we have {x} or {x,} or {x,y}: - parse_range(ptr, end, rep_min, rep_max); - goto repeat_jump; - - case traits_type::syntax_digit: - if(_flags & bk_refs) - { - // update previous: - int i = traits_inst.toi((charT)c); - if(i == 0) - { - // we can have \025 which means take char whose - // code is 25 (octal), so parse string: - c = traits_inst.toi(ptr, end, -8); - --ptr; - break; - } - dat = add_simple(dat, re_detail::syntax_element_backref, sizeof(re_detail::re_brace)); - static_cast(dat)->index = i; - ++ptr; - continue; - } - break; - case traits_type::syntax_b: // re_detail::syntax_element_word_boundary - dat = add_simple(dat, re_detail::syntax_element_word_boundary); - ++ptr; - continue; - case traits_type::syntax_B: - dat = add_simple(dat, re_detail::syntax_element_within_word); - ++ptr; - continue; - case traits_type::syntax_left_word: - dat = add_simple(dat, re_detail::syntax_element_word_start); - ++ptr; - continue; - case traits_type::syntax_right_word: - dat = add_simple(dat, re_detail::syntax_element_word_end); - ++ptr; - continue; - case traits_type::syntax_w: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_word); - ++ptr; - continue; - case traits_type::syntax_W: - dat = compile_set_simple(dat, traits_type::char_class_word, true); - ++ptr; - continue; - case traits_type::syntax_d: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_digit); - ++ptr; - continue; - case traits_type::syntax_D: - dat = compile_set_simple(dat, traits_type::char_class_digit, true); - ++ptr; - continue; - case traits_type::syntax_s: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_space); - ++ptr; - continue; - case traits_type::syntax_S: - dat = compile_set_simple(dat, traits_type::char_class_space, true); - ++ptr; - continue; - case traits_type::syntax_l: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_lower); - ++ptr; - continue; - case traits_type::syntax_L: - dat = compile_set_simple(dat, traits_type::char_class_lower, true); - ++ptr; - continue; - case traits_type::syntax_u: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_upper); - ++ptr; - continue; - case traits_type::syntax_U: - dat = compile_set_simple(dat, traits_type::char_class_upper, true); - ++ptr; - continue; - case traits_type::syntax_Q: - ++ptr; - while(true) - { - if(ptr == end) - { - fail(REG_EESCAPE); - return error_code(); - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_slash) - { - ++ptr; - if((ptr != end) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_E)) - break; - else - { - dat = add_literal(dat, *(ptr-1)); - continue; - } - } - dat = add_literal(dat, *ptr); - ++ptr; - } - ++ptr; - continue; - case traits_type::syntax_C: - dat = add_simple(dat, re_detail::syntax_element_wild); - ++ptr; - continue; - case traits_type::syntax_X: - dat = add_simple(dat, re_detail::syntax_element_combining); - ++ptr; - continue; - case traits_type::syntax_Z: - dat = add_simple(dat, re_detail::syntax_element_soft_buffer_end); - ++ptr; - continue; - case traits_type::syntax_G: - dat = add_simple(dat, re_detail::syntax_element_restart_continue); - ++ptr; - continue; - case traits_type::syntax_start_buffer: - dat = add_simple(dat, re_detail::syntax_element_buffer_start); - ++ptr; - continue; - case traits_type::syntax_end_buffer: - dat = add_simple(dat, re_detail::syntax_element_buffer_end); - ++ptr; - continue; - default: - c = (traits_size_type)(traits_uchar_type)parse_escape(ptr, end); - dat = add_literal(dat, (charT)c); - continue; - } - dat = add_literal(dat, (charT)c); - ++ptr; - break; - } - case traits_type::syntax_dollar: - dat = add_simple(dat, re_detail::syntax_element_end_line, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_caret: - dat = add_simple(dat, re_detail::syntax_element_start_line, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_dot: - dat = add_simple(dat, re_detail::syntax_element_wild, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_star: - rep_min = 0; - rep_max = (unsigned)-1; - - repeat_jump: - { - std::ptrdiff_t offset; - if(dat == 0) - { - fail(REG_BADRPT); - return error_code(); - } - switch(dat->type) - { - case re_detail::syntax_element_endmark: - offset = last_mark_popped; - break; - case re_detail::syntax_element_literal: - if(static_cast(dat)->length > 1) - { - // update previous: - charT lit = *reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_literal) + ((static_cast(dat)->length-1)*sizeof(charT))); - --static_cast(dat)->length; - dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); - static_cast(dat)->length = 1; - *reinterpret_cast(static_cast(dat)+1) = lit; - } - offset = reinterpret_cast(dat) - reinterpret_cast(data.data()); - break; - case re_detail::syntax_element_backref: - case re_detail::syntax_element_long_set: - case re_detail::syntax_element_set: - case re_detail::syntax_element_wild: - case re_detail::syntax_element_combining: - // we're repeating a single item: - offset = reinterpret_cast(dat) - reinterpret_cast(data.data()); - break; - default: - fail(REG_BADRPT); - return error_code(); - } - data.align(); - dat->next.i = data.size(); - //unsigned pos = (char*)dat - (char*)data.data(); - - // add the trailing jump: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - static_cast(dat)->alt.i = 0; - - // now insert the leading repeater: - dat = static_cast(data.insert(offset, re_detail::re_repeater_size)); - dat->next.i = (reinterpret_cast(dat) - reinterpret_cast(data.data())) + re_detail::re_repeater_size; - dat->type = re_detail::syntax_element_rep; - static_cast(dat)->alt.i = data.size(); - static_cast(dat)->min = rep_min; - static_cast(dat)->max = rep_max; - static_cast(dat)->leading = false; - static_cast(dat)->greedy = true; - move_offsets(dat, re_detail::re_repeater_size); - ++ptr; - // - // now check to see if we have a non-greedy repeat: - if((ptr != end) && (_flags & (limited_ops | bk_plus_qm | bk_braces)) == 0) - { - c = (traits_size_type)(traits_uchar_type)*ptr; - if(traits_type::syntax_question == traits_inst.syntax_type(c)) - { - // OK repeat is non-greedy: - static_cast(dat)->greedy = false; - ++ptr; - } - } - dat = reinterpret_cast(reinterpret_cast(data.data()) + data.size() - re_detail::re_jump_size); - static_cast(dat)->alt.i = offset; - continue; - } - case traits_type::syntax_plus: - if(_flags & (bk_plus_qm | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - rep_min = 1; - rep_max = (unsigned)-1; - goto repeat_jump; - case traits_type::syntax_question: - if(_flags & (bk_plus_qm | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - rep_min = 0; - rep_max = 1; - goto repeat_jump; - case traits_type::syntax_open_set: - // update previous: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - // extend: - dat = compile_set(ptr, end); - if(dat == 0) - { - if((_flags & regbase::failbit) == 0) - fail(REG_EBRACK); - return error_code(); - } - break; - case traits_type::syntax_or: - { - if(_flags & (bk_vbar | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - - alt_string_jump: - - // update previous: - if(dat == 0) - { - // start of pattern can't have empty "|" - fail(REG_EMPTY); - return error_code(); - } - // see if we have an empty alternative: - if(mark.empty() == false) - if(mark.peek() == data.index(dat)) - { - fail(REG_EMPTY); - return error_code(); - } - // extend: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - data.align(); - // - // we don't know what value to put here yet, - // use an arbitrarily large value for now - // and check it later (TODO!) - static_cast(dat)->alt.i = INT_MAX/2; - - // now work out where to insert: - std::size_t offset = 0; - if(mark.empty() == false) - { - // we have a '(' or '|' to go back to: - offset = mark.peek(); - re_detail::re_syntax_base* base = reinterpret_cast(reinterpret_cast(data.data()) + offset); - offset = base->next.i; - } - re_detail::re_jump* j = static_cast(data.insert(offset, re_detail::re_jump_size)); - j->type = re_detail::syntax_element_alt; - j->next.i = offset + re_detail::re_jump_size; - j->alt.i = data.size(); - move_offsets(j, re_detail::re_jump_size); - dat = reinterpret_cast(reinterpret_cast(data.data()) + data.size() - re_detail::re_jump_size); - mark.push(data.size() - re_detail::re_jump_size); - ++ptr; - break; - } - case traits_type::syntax_open_brace: - if((_flags & bk_braces) || ((_flags & intervals) == 0)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - // we have {x} or {x,} or {x,y}: - parse_range(ptr, end, rep_min, rep_max); - goto repeat_jump; - case traits_type::syntax_newline: - if(_flags & newline_alt) - goto alt_string_jump; - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - case traits_type::syntax_close_brace: - if(_flags & bk_braces) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - fail(REG_BADPAT); - return error_code(); - default: - dat = add_literal(dat, (charT)c); - ++ptr; - break; - } // switch - } // while - - // - // update previous: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - - // see if we have an empty alternative: - if(mark.empty() == false) - if(mark.peek() == data.index(dat) ) - { - re_detail::re_syntax_base* para = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - if(para->type == re_detail::syntax_element_jump) - { - fail(REG_EMPTY); - return error_code(); - } - } - // - // set up tail: - // - if(mark.empty() == false) - { - // pop any pushed alternatives and set the target end destination: - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - while(dat->type == re_detail::syntax_element_jump) - { - static_cast(dat)->alt.i = data.size(); - mark.pop(); - if(mark.empty() == true) - break; - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - } - } - - dat = static_cast(data.extend(sizeof(re_detail::re_syntax_base))); - dat->type = re_detail::syntax_element_match; - dat->next.i = 0; - - if(mark.empty() == false) - { - fail(REG_EPAREN); - return error_code(); - } - - // - // allocate space for start _map: - startmap = reinterpret_cast(data.extend(256 + ((end - base + 1) * sizeof(charT)))); - // - // and copy the expression we just compiled: - _expression = reinterpret_cast(reinterpret_cast(startmap) + 256); - _expression_len = end - base; - std::memcpy(_expression, base, _expression_len * sizeof(charT)); - *(_expression + _expression_len) = charT(0); - - // - // now we need to apply fixups to the array - // so that we can use pointers and not indexes - fixup_apply(static_cast(data.data()), marks); - - // check for error during fixup: - if(_flags & regbase::failbit) - return error_code(); - - // - // finally compile the maps so that we can make intelligent choices - // whenever we encounter an alternative: - compile_maps(); - if(pkmp) - { - re_detail::kmp_free(pkmp, data.allocator()); - pkmp = 0; - } - re_detail::re_syntax_base* sbase = static_cast(data.data()); - _restart_type = probe_restart(sbase); - _leading_len = fixup_leading_rep(sbase, 0); - if((sbase->type == re_detail::syntax_element_literal) && (sbase->next.p->type == re_detail::syntax_element_match)) - { - _restart_type = restart_fixed_lit; - if(0 == pkmp) - { - charT* p1 = reinterpret_cast(reinterpret_cast(sbase) + sizeof(re_detail::re_literal)); - charT* p2 = p1 + static_cast(sbase)->length; - pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator(_flags®base::icase, &traits_inst), data.allocator()); - } - } - return error_code(); - - } // sentry - return REG_EMPTY; - -# ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size) -{ - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - if(size < sizeof(re_detail::re_syntax_base)) - size = sizeof(re_detail::re_syntax_base); - dat = static_cast(data.extend(size)); - dat->type = type; - dat->next.i = 0; - return dat; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_literal(re_detail::re_syntax_base* dat, charT c) -{ - if(dat && (dat->type == re_detail::syntax_element_literal)) - { - // add another charT to the list: - std::ptrdiff_t pos = reinterpret_cast(dat) - reinterpret_cast(data.data()); - *reinterpret_cast(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regbase::icase)); - dat = reinterpret_cast(reinterpret_cast(data.data()) + pos); - ++(static_cast(dat)->length); - } - else - { - // extend: - dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); - static_cast(dat)->length = 1; - *reinterpret_cast(reinterpret_cast(dat)+1) = traits_inst.translate(c, (_flags & regbase::icase)); - } - return dat; -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::probe_restart(re_detail::re_syntax_base* dat) -{ - switch(dat->type) - { - case re_detail::syntax_element_startmark: - case re_detail::syntax_element_endmark: - if(static_cast(dat)->index == -2) - return regbase::restart_any; - return probe_restart(dat->next.p); - case re_detail::syntax_element_start_line: - return regbase::restart_line; - case re_detail::syntax_element_word_start: - return regbase::restart_word; - case re_detail::syntax_element_buffer_start: - return regbase::restart_buf; - case re_detail::syntax_element_restart_continue: - return regbase::restart_continue; - default: - return regbase::restart_any; - } -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end) -{ - unsigned int len = 0; - bool leading_lit = end ? false : true; - while(dat != end) - { - switch(dat->type) - { - case re_detail::syntax_element_literal: - len += static_cast(dat)->length; - if((leading_lit) && (static_cast(dat)->length > 2)) - { - // we can do a literal search for the leading literal string - // using Knuth-Morris-Pratt (or whatever), and only then check for - // matches. We need a decent length string though to make it - // worth while. - _leading_string = reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_literal)); - _leading_string_len = static_cast(dat)->length; - _restart_type = restart_lit; - leading_lit = false; - const charT* p1 = _leading_string; - const charT* p2 = _leading_string + _leading_string_len; - pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator(_flags®base::icase, &traits_inst), data.allocator()); - } - leading_lit = false; - break; - case re_detail::syntax_element_wild: - ++len; - leading_lit = false; - break; - case re_detail::syntax_element_match: - return len; - case re_detail::syntax_element_backref: - //case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - case re_detail::syntax_element_combining: - return 0; - case re_detail::syntax_element_long_set: - { - // we need to verify that there are no multi-character - // collating elements inside the repeat: - const charT* p = reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_set_long)); - unsigned int csingles = static_cast(dat)->csingles; - for(unsigned int i = 0; i < csingles; ++i) - { - if(re_detail::re_strlen(p) > 1) - return 0; - while(*p)++p; - ++p; - } - ++len; - leading_lit = false; - break; - } - case re_detail::syntax_element_set: - ++len; - leading_lit = false; - break; - case re_detail::syntax_element_rep: - if((len == 0) && (1 == fixup_leading_rep(dat->next.p, static_cast(dat)->alt.p) )) - { - static_cast(dat)->leading = leading_lit; - return len; - } - return len; - case re_detail::syntax_element_startmark: - if(static_cast(dat)->index == -2) - return 0; - // fall through: - default: - break; - } - dat = dat->next.p; - } - return len; -} - -template -void BOOST_REGEX_CALL reg_expression::fail(unsigned int err) -{ - error_code_ = err; - if(err) - { - _flags |= regbase::failbit; -#ifndef BOOST_NO_EXCEPTIONS - if(_flags & regbase::use_except) - { - throw bad_expression(traits_inst.error_string(err)); - } -#endif - } - else - _flags &= ~regbase::failbit; -} - - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - - -#endif // BOOST_REGEX_COMPILE_HPP - - - - - - - - - - - diff --git a/include/boost/regex/v3/regex_cstring.hpp b/include/boost/regex/v3/regex_cstring.hpp deleted file mode 100644 index 82fd5d02..00000000 --- a/include/boost/regex/v3/regex_cstring.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_cstring.hpp - * VERSION see - * DESCRIPTION: This is an internal header file, do not include directly. - * String support and helper functions, for regular - * expression library. - */ - -#ifndef BOOST_REGEX_CSTRING_HPP -#define BOOST_REGEX_CSTRING_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#include - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -// -// start by defining some template function aliases for C API functions: -// - -template -std::size_t BOOST_REGEX_CALL re_strlen(const charT *s) -{ - std::size_t len = 0; - while(*s) - { - ++s; - ++len; - } - return len; -} - -inline std::size_t BOOST_REGEX_CALL re_strlen(const char *s) -{ - return std::strlen(s); -} - -#ifndef BOOST_NO_WREGEX - -inline std::size_t BOOST_REGEX_CALL re_strlen(const wchar_t *s) -{ - return std::wcslen(s); -} - -#endif - -#ifndef BOOST_NO_WREGEX -BOOST_REGEX_DECL void BOOST_REGEX_CALL re_transform(std::basic_string& out, const std::basic_string& in); -#endif -BOOST_REGEX_DECL void BOOST_REGEX_CALL re_transform(std::string& out, const std::string& in); - -template -void BOOST_REGEX_CALL re_trunc_primary(std::basic_string& s) -{ - for(unsigned int i = 0; i < s.size(); ++i) - { - if(s[i] <= 1) - { - s.erase(i); - break; - } - } -} - -inline char* BOOST_REGEX_CALL re_strcpy(char *s1, const char *s2) -{ - #if defined(__BORLANDC__) && defined(strcpy) - return ::strcpy(s1, s2); - #else - return std::strcpy(s1, s2); - #endif -} - -#ifndef BOOST_NO_WREGEX - -inline wchar_t* BOOST_REGEX_CALL re_strcpy(wchar_t *s1, const wchar_t *s2) -{ - return std::wcscpy(s1, s2); -} - -#endif - - -template -charT* BOOST_REGEX_CALL re_strdup(const charT* p) -{ - charT* buf = new charT[re_strlen(p) + 1]; - re_strcpy(buf, p); - return buf; -} - -template -inline void BOOST_REGEX_CALL re_strfree(charT* p) -{ - delete[] p; -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace re_detail -} // namespace boost - -#endif // BOOST_REGEX_CSTRING_HPP - - - - - - diff --git a/include/boost/regex/v3/regex_format.hpp b/include/boost/regex/v3/regex_format.hpp deleted file mode 100644 index 0d2c691b..00000000 --- a/include/boost/regex/v3/regex_format.hpp +++ /dev/null @@ -1,576 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_format.hpp - * VERSION see - * DESCRIPTION: Provides formatting output routines for search and replace - * operations. Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_FORMAT_HPP -#define BOOST_REGEX_FORMAT_HPP - - -namespace boost{ - -enum format_flags_t{ - format_all = 0, // enable all extentions to sytax - format_sed = match_max << 1, // sed style replacement. - format_perl = format_sed << 1, // perl style replacement. - format_no_copy = format_perl << 1, // don't copy non-matching segments. - format_first_only = format_no_copy << 1, // Only replace first occurance. - format_is_if = format_first_only << 1 // internal use only. -}; - -namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -w-8037 -#endif - -template -O BOOST_REGEX_CALL re_copy_out(O out, I first, I last) -{ - while(first != last) - { - *out = *first; - ++out; - ++first; - } - return out; -} - -template -void BOOST_REGEX_CALL re_skip_format(const charT*& fmt, const traits_type& traits_inst) -{ - // dwa 9/13/00 - suppress incorrect unused parameter warning for MSVC - (void)traits_inst; - - typedef typename traits_type::size_type traits_size_type; - typedef typename traits_type::uchar_type traits_uchar_type; - typedef typename traits_type::string_type traits_string_type; - - unsigned int parens = 0; - unsigned int c; - while(*fmt) - { - c = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)); - if((c == traits_type::syntax_colon) && (parens == 0)) - { - ++fmt; - return; - } - else if(c == traits_type::syntax_close_bracket) - { - if(parens == 0) - { - ++fmt; - return; - } - --parens; - } - else if(c == traits_type::syntax_open_bracket) - ++parens; - else if(c == traits_type::syntax_slash) - { - ++fmt; - if(*fmt == 0) - return; - } - ++fmt; - } -} - -#ifdef BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN - -// -// ugly hack for buggy output iterators - -template -inline void oi_assign(T* p, T v) -{ - ::boost::re_detail::pointer_destroy(p); - pointer_construct(p, v); -} - -#else - -template -inline void oi_assign(T* p, T v) -{ - // - // if you get a compile time error in here then you either - // need to rewrite your output iterator to make it assignable - // (as is required by the standard), or define - // BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN to use the ugly hack above - *p = v; -} - -#endif - - -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -// -// Ugly ugly hack, -// template don't merge if they contain switch statements so declare these -// templates in unnamed namespace (ie with internal linkage), each translation -// unit then gets its own local copy, it works seemlessly but bloats the app. -namespace{ -#endif - -// -// algorithm reg_format: -// takes the result of a match and a format string -// and merges them to produce a new string which -// is sent to an OutputIterator, -// _reg_format_aux does the actual work: -// -template -OutputIterator BOOST_REGEX_CALL _reg_format_aux(OutputIterator out, - const match_results& m, - const charT*& fmt, - unsigned flags, const traits_type& traits_inst) -{ - const charT* fmt_end = fmt; - while(*fmt_end) ++ fmt_end; - - typedef typename traits_type::size_type traits_size_type; - typedef typename traits_type::uchar_type traits_uchar_type; - typedef typename traits_type::string_type traits_string_type; - - while(*fmt) - { - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) - { - case traits_type::syntax_dollar: - if(flags & format_sed) - { - // no perl style replacement, - // $ is an ordinary character: - goto default_opt; - } - ++fmt; - if(*fmt == 0) // oops trailing $ - { - --fmt; - *out = *fmt; - ++out; - return out; - } - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) - { - case traits_type::syntax_start_buffer: - oi_assign(&out, re_copy_out(out, Iterator(m[-1].first), Iterator(m[-1].second))); - ++fmt; - continue; - case traits_type::syntax_end_buffer: - oi_assign(&out, re_copy_out(out, Iterator(m[-2].first), Iterator(m[-2].second))); - ++fmt; - continue; - case traits_type::syntax_digit: - { -expand_sub: - unsigned int index = traits_inst.toi(fmt, fmt_end, 10); - oi_assign(&out, re_copy_out(out, Iterator(m[index].first), Iterator(m[index].second))); - continue; - } - } - // anything else: - if(*fmt == '&') - { - oi_assign(&out, re_copy_out(out, Iterator(m[0].first), Iterator(m[0].second))); - ++fmt; - } - else - { - // probably an error, treat as a literal '$' - --fmt; - *out = *fmt; - ++out; - ++fmt; - } - continue; - case traits_type::syntax_slash: - { - // escape sequence: - ++fmt; - charT c(*fmt); - if(*fmt == 0) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - return out; - } - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) - { - case traits_type::syntax_a: - c = '\a'; - ++fmt; - break; - case traits_type::syntax_f: - c = '\f'; - ++fmt; - break; - case traits_type::syntax_n: - c = '\n'; - ++fmt; - break; - case traits_type::syntax_r: - c = '\r'; - ++fmt; - break; - case traits_type::syntax_t: - c = '\t'; - ++fmt; - break; - case traits_type::syntax_v: - c = '\v'; - ++fmt; - break; - case traits_type::syntax_x: - ++fmt; - if(fmt == fmt_end) - { - *out = *--fmt; - ++out; - return out; - } - // maybe have \x{ddd} - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) == traits_type::syntax_open_brace) - { - ++fmt; - if(fmt == fmt_end) - { - fmt -= 2; - *out = *fmt; - ++out; - ++fmt; - continue; - } - if(traits_inst.is_class(*fmt, traits_type::char_class_xdigit) == false) - { - fmt -= 2; - *out = *fmt; - ++out; - ++fmt; - continue; - } - c = (charT)traits_inst.toi(fmt, fmt_end, -16); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_close_brace) - { - while(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_slash) - --fmt; - ++fmt; - *out = *fmt; - ++out; - ++fmt; - continue; - } - ++fmt; - break; - } - else - { - if(traits_inst.is_class(*fmt, traits_type::char_class_xdigit) == false) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - continue; - } - c = (charT)traits_inst.toi(fmt, fmt_end, -16); - } - break; - case traits_type::syntax_c: - ++fmt; - if(fmt == fmt_end) - { - --fmt; - *out = *fmt; - ++out; - return out; - } - if(((typename traits_type::uchar_type)(*fmt) < (typename traits_type::uchar_type)'@') - || ((typename traits_type::uchar_type)(*fmt) > (typename traits_type::uchar_type)127) ) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - break; - } - c = (charT)((typename traits_type::uchar_type)(*fmt) - (typename traits_type::uchar_type)'@'); - ++fmt; - break; - case traits_type::syntax_e: - c = (charT)27; - ++fmt; - break; - case traits_type::syntax_digit: - if(flags & format_sed) - goto expand_sub; - else - c = (charT)traits_inst.toi(fmt, fmt_end, -8); - break; - default: - //c = *fmt; - ++fmt; - } - *out = c; - ++out; - continue; - } - case traits_type::syntax_open_bracket: - if(flags & (format_sed|format_perl)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; // recurse - oi_assign(&out, _reg_format_aux(out, m, fmt, flags, traits_inst)); - continue; - } - case traits_type::syntax_close_bracket: - if(flags & (format_sed|format_perl)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; // return from recursion - return out; - } - case traits_type::syntax_colon: - if(flags & format_is_if) - { - ++fmt; - return out; - } - *out = *fmt; - ++out; - ++fmt; - continue; - case traits_type::syntax_question: - { - if(flags & (format_sed|format_perl)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; - if(*fmt == 0) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - return out; - } - unsigned int id = traits_inst.toi(fmt, fmt_end, 10); - if(m[id].matched) - { - oi_assign(&out, _reg_format_aux(out, m, fmt, flags | format_is_if, traits_inst)); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon) - re_skip_format(fmt, traits_inst); - } - else - { - re_skip_format(fmt, traits_inst); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon) - oi_assign(&out, _reg_format_aux(out, m, fmt, flags | format_is_if, traits_inst)); - } - return out; - } - } - default: -default_opt: - if((flags & format_sed) && (*fmt == '&')) - { - oi_assign(&out, re_copy_out(out, Iterator(m[0].first), Iterator(m[0].second))); - ++fmt; - continue; - } - *out = *fmt; - ++out; - ++fmt; - } - } - - return out; -} - -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -} // namespace -#endif - -template -class string_out_iterator -{ - S* out; -public: - string_out_iterator(S& s) : out(&s) {} - string_out_iterator& operator++() { return *this; } - string_out_iterator& operator++(int) { return *this; } - string_out_iterator& operator*() { return *this; } - string_out_iterator& operator=(typename S::value_type v) - { - out->append(1, v); - return *this; - } -}; - -template -class merge_out_predicate -{ - OutputIterator* out; - Iterator* last; - const charT* fmt; - unsigned flags; - const traits_type* pt; - -public: - merge_out_predicate(OutputIterator& o, Iterator& pi, const charT* f, unsigned format_flags, const traits_type& p) - : out(&o), last(&pi), fmt(f), flags(format_flags), pt(&p){} - - ~merge_out_predicate() {} - bool BOOST_REGEX_CALL operator()(const boost::match_results& m) - { - const charT* f = fmt; - if(0 == (flags & format_no_copy)) - oi_assign(out, re_copy_out(*out, Iterator(m[-1].first), Iterator(m[-1].second))); - oi_assign(out, _reg_format_aux(*out, m, f, flags, *pt)); - *last = m[-2].first; - return flags & format_first_only ? false : true; - } -}; - -} // namespace re_detail - -template -OutputIterator regex_format(OutputIterator out, - const match_results& m, - const charT* fmt, - unsigned flags = 0 - ) -{ - regex_traits t; - return re_detail::_reg_format_aux(out, m, fmt, flags, t); -} - -template -OutputIterator regex_format(OutputIterator out, - const match_results& m, - const std::basic_string& fmt, - unsigned flags = 0 - ) -{ - regex_traits t; - const charT* start = fmt.c_str(); - return re_detail::_reg_format_aux(out, m, start, flags, t); -} - -template -std::basic_string regex_format(const match_results& m, const charT* fmt, unsigned flags = 0) -{ - std::basic_string result; - re_detail::string_out_iterator > i(result); - regex_format(i, m, fmt, flags); - return result; -} - -template -std::basic_string regex_format(const match_results& m, const std::basic_string& fmt, unsigned flags = 0) -{ - std::basic_string result; - re_detail::string_out_iterator > i(result); - regex_format(i, m, fmt.c_str(), flags); - return result; -} - -template -OutputIterator regex_merge(OutputIterator out, - Iterator first, - Iterator last, - const reg_expression& e, - const charT* fmt, - unsigned int flags = match_default) -{ - Iterator l = first; - re_detail::merge_out_predicate oi(out, l, fmt, flags, e.get_traits()); - regex_grep(oi, first, last, e, flags); - return (flags & format_no_copy) ? out : re_detail::re_copy_out(out, l, last); -} - -template -inline OutputIterator regex_merge(OutputIterator out, - Iterator first, - Iterator last, - const reg_expression& e, - const std::basic_string& fmt, - unsigned int flags = match_default) -{ - return regex_merge(out, first, last, e, fmt.c_str(), flags); -} - -template -std::basic_string regex_merge(const std::basic_string& s, - const reg_expression& e, - const charT* fmt, - unsigned int flags = match_default) -{ - std::basic_string result; - re_detail::string_out_iterator > i(result); - regex_merge(i, s.begin(), s.end(), e, fmt, flags); - return result; -} - -template -std::basic_string regex_merge(const std::basic_string& s, - const reg_expression& e, - const std::basic_string& fmt, - unsigned int flags = match_default) -{ - std::basic_string result; - re_detail::string_out_iterator > i(result); - regex_merge(i, s.begin(), s.end(), e, fmt.c_str(), flags); - return result; -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#endif // BOOST_REGEX_FORMAT_HPP - - - - - - diff --git a/include/boost/regex/v3/regex_fwd.hpp b/include/boost/regex/v3/regex_fwd.hpp deleted file mode 100644 index b163adb6..00000000 --- a/include/boost/regex/v3/regex_fwd.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_fwd.cpp - * VERSION see - * DESCRIPTION: Forward declares boost::reg_expression<> and - * associated typedefs. - */ - -#ifndef BOOST_REGEX_FWD_HPP_INCLUDED -#define BOOST_REGEX_FWD_HPP_INCLUDED - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif -#include - -// -// define BOOST_REGEX_NO_FWD if this -// header doesn't work! -// -#ifdef BOOST_REGEX_NO_FWD -# ifndef BOOST_RE_REGEX_HPP -# include -# endif -#else - -// -// If there isn't good enough wide character support then there will -// be no wide character regular expressions: -// -#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) && !defined(BOOST_NO_WREGEX) -# define BOOST_NO_WREGEX -#endif - -namespace boost{ - -template -class regex_traits; - -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > -class reg_expression; - -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(char) > regex; -#ifndef BOOST_NO_WREGEX -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(wchar_t) > wregex; -#endif - -} // namespace boost - -#endif // BOOST_REGEX_NO_FWD - -#endif - - - - diff --git a/include/boost/regex/v3/regex_kmp.hpp b/include/boost/regex/v3/regex_kmp.hpp deleted file mode 100644 index 55403f64..00000000 --- a/include/boost/regex/v3/regex_kmp.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_kmp.hpp - * VERSION see - * DESCRIPTION: Provides Knuth Morris Pratt search operations. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_KMP_HPP -#define BOOST_REGEX_KMP_HPP - -#ifdef BOOST_REGEX_CONFIG_HPP -#include -#endif - - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -template -struct kmp_info -{ - unsigned int size; - unsigned int len; - const charT* pstr; - int kmp_next[1]; -}; - -template -void kmp_free(kmp_info* pinfo, const Allocator& a) -{ - typedef typename boost::detail::rebind_allocator::type atype; - atype(a).deallocate(reinterpret_cast(pinfo), pinfo->size); -} - -template -kmp_info* kmp_compile(iterator first, iterator last, charT, Trans translate, const Allocator& a) -{ - typedef typename boost::detail::rebind_allocator::type atype; - int i, j, m; - i = 0; - m = static_cast(boost::re_detail::distance(first, last)); - ++m; - unsigned int size = sizeof(kmp_info) + sizeof(int)*m + sizeof(charT)*m; - --m; - // - // allocate struct and fill it in: - // - kmp_info* pinfo = reinterpret_cast*>(atype(a).allocate(size)); - BOOST_REGEX_NOEH_ASSERT(pinfo) - pinfo->size = size; - pinfo->len = m; - charT* p = reinterpret_cast(reinterpret_cast(pinfo) + sizeof(kmp_info) + sizeof(int)*(m+1)); - pinfo->pstr = p; - while(first != last) - { - *p = translate(*first); - ++first; - ++p; - } - *p = 0; - // - // finally do regular kmp compile: - // - j = pinfo->kmp_next[0] = -1; - while (i < m) - { - while ((j > -1) && (pinfo->pstr[i] != pinfo->pstr[j])) - j = pinfo->kmp_next[j]; - ++i; - ++j; - if (pinfo->pstr[i] == pinfo->pstr[j]) - pinfo->kmp_next[i] = pinfo->kmp_next[j]; - else - pinfo->kmp_next[i] = j; - } - - return pinfo; -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - - } // namepsace re_detail -} // namespace boost - -#endif // BOOST_REGEX_KMP_HPP - - - - diff --git a/include/boost/regex/v3/regex_library_include.hpp b/include/boost/regex/v3/regex_library_include.hpp deleted file mode 100644 index d054ec2e..00000000 --- a/include/boost/regex/v3/regex_library_include.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_libary_include.hpp - * VERSION see - * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -/************************************************************************* - -Libraries for Borland and Microsoft compilers are automatically -selected here, the name of the lib is selected according to the following -formula: - -BOOST_LIB_NAME - + "_" - + BOOST_LIB_TOOLSET - + "_" - + BOOST_LIB_THREAD_OPT - + BOOST_LIB_RT_OPT - + BOOST_LIB_LINK_OPT - + BOOST_LIB_DEBUG_OPT - -These are defined as: - -BOOST_LIB_NAME: The base name of the lib (boost_regex). - -BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). - -BOOST_LIB_THREAD_OPT: "s" for single thread builds, - "m" for multithread builds. - -BOOST_LIB_RT_OPT: "s" for static runtime, - "d" for dynamic runtime. - -BOOST_LIB_LINK_OPT: "s" for static link, - "i" for dynamic link. - -BOOST_LIB_DEBUG_OPT: nothing for release builds, - "d" for debug builds, - "dd" for debug-diagnostic builds (_STLP_DEBUG). - -***************************************************************************/ - -#if !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_REGEX_NO_LIB) -#define BOOST_REGEX_LIBRARY_INCLUDE_HPP - -#define BOOST_LIB_NAME "boost_regex" - -// -// select toolset: -// -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) - - // vc6-stlport: -# define BOOST_LIB_TOOLSET "vc6-stlport" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1200) - - // vc6: -# define BOOST_LIB_TOOLSET "vc6" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) - - // vc7: -# define BOOST_LIB_TOOLSET "vc7" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb6" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb5" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x540) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb4" - -#endif - -// -// select thread opt: -// -#if defined(_MT) || defined(__MT__) -# define BOOST_LIB_THREAD_OPT "m" -#else -# define BOOST_LIB_THREAD_OPT "s" -#endif - -// -// select runtime opt: -// -#if defined(_DLL) || defined(_RTLDLL) -# define BOOST_LIB_RT_OPT "d" -#else -# define BOOST_LIB_RT_OPT "s" -#endif - -// -// select linkage opt: -// -#if (defined(_DLL) || defined(_RTLDLL)) && !defined(BOOST_REGEX_STATIC_LINK) -# define BOOST_LIB_LINK_OPT "i" -#else -# define BOOST_LIB_LINK_OPT "s" -#endif - -// -// select debug opt: -// -#if defined(BOOST_MSVC) && defined(_DEBUG) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG)) -# define BOOST_LIB_DEBUG_OPT "dd" -#elif defined(BOOST_MSVC) && defined(_DEBUG) -# define BOOST_LIB_DEBUG_OPT "d" -#elif defined(__BORLANDC__) && (__BORLANDC__ == 0x560) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG)) -# define BOOST_LIB_DEBUG_OPT "dd" -#else -# define BOOST_LIB_DEBUG_OPT -#endif - -// -// now include the lib: -// -#if defined(BOOST_LIB_NAME) \ - && defined(BOOST_LIB_TOOLSET) \ - && defined(BOOST_LIB_THREAD_OPT) \ - && defined(BOOST_LIB_RT_OPT) \ - && defined(BOOST_LIB_LINK_OPT) \ - && defined(BOOST_LIB_DEBUG_OPT) - -# pragma comment(lib, BOOST_LIB_NAME "_" BOOST_LIB_TOOLSET "_" BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_LINK_OPT BOOST_LIB_DEBUG_OPT ".lib") - -#endif - -// -// finally undef any macros we may have set: -// -#if defined(BOOST_LIB_NAME) -# undef BOOST_LIB_NAME -#endif -#if defined(BOOST_LIB_TOOLSET) -# undef BOOST_LIB_TOOLSET -#endif -#if defined(BOOST_LIB_THREAD_OPT) -# undef BOOST_LIB_THREAD_OPT -#endif -#if defined(BOOST_LIB_RT_OPT) -# undef BOOST_LIB_RT_OPT -#endif -#if defined(BOOST_LIB_LINK_OPT) -# undef BOOST_LIB_LINK_OPT -#endif -#if defined(BOOST_LIB_DEBUG_OPT) -# undef BOOST_LIB_DEBUG_OPT -#endif - - -#endif // BOOST_REGEX_LIBRARY_INCLUDE_HPP - - - - - - - diff --git a/include/boost/regex/v3/regex_match.hpp b/include/boost/regex/v3/regex_match.hpp deleted file mode 100644 index 8fae9c9d..00000000 --- a/include/boost/regex/v3/regex_match.hpp +++ /dev/null @@ -1,2013 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_match.hpp - * VERSION see - * DESCRIPTION: Regular expression matching algorithms. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - - -#ifndef BOOST_REGEX_MATCH_HPP -#define BOOST_REGEX_MATCH_HPP - -#ifndef BOOST_REGEX_MAX_STATE_COUNT -# define BOOST_REGEX_MAX_STATE_COUNT 100000000 -#endif - -#include - - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -w-8026 -w-8027 -#endif - -// -// Unfortunately Rogue Waves standard library appears to have a bug -// in std::basic_string::compare that results in eroneous answers -// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version -// 0x020101) the test case was: -// {39135,0} < {0xff,0} -// which succeeds when it should not. -// -#ifndef _RWSTD_VER -# define STR_COMP(s,p) s.compare(p) -#else -template -inline int string_compare(const std::basic_string& s, const C* p) -{ return s.compare(p); } -inline int string_compare(const std::string& s, const char* p) -{ return std::strcmp(s.c_str(), p); } -# ifndef BOOST_NO_WREGEX -inline int string_compare(const std::wstring& s, const wchar_t* p) -{ return std::wcscmp(s.c_str(), p); } -# endif -# define STR_COMP(s,p) string_compare(s,p) -#endif - -template -inline const charT* re_skip_past_null(const charT* p) -{ - while (*p != 0) ++p; - return ++p; -} - -template -iterator BOOST_REGEX_CALL re_is_set_member(iterator next, - iterator last, - const re_set_long* set_, - const reg_expression& e) -{ - const charT* p = reinterpret_cast(set_+1); - iterator ptr; - unsigned int i; - bool icase = e.flags() & regbase::icase; - - if(next == last) return next; - - typedef typename traits_type::string_type traits_string_type; - const traits_type& traits_inst = e.get_traits(); - - // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never - // referenced - (void)traits_inst; - - // try and match a single character, could be a multi-character - // collating element... - for(i = 0; i < set_->csingles; ++i) - { - ptr = next; - if(*p == 0) - { - // treat null string as special case: - if(traits_inst.translate(*ptr, icase) != *p) - { - while(*p == 0)++p; - continue; - } - return set_->isnot ? next : (ptr == next) ? ++next : ptr; - } - else - { - while(*p && (ptr != last)) - { - if(traits_inst.translate(*ptr, icase) != *p) - break; - ++p; - ++ptr; - } - - if(*p == 0) // if null we've matched - return set_->isnot ? next : (ptr == next) ? ++next : ptr; - - p = re_skip_past_null(p); // skip null - } - } - - charT col = traits_inst.translate(*next, icase); - - - if(set_->cranges || set_->cequivalents) - { - traits_string_type s2(1, col); - traits_string_type s1; - // - // try and match a range, NB only a single character can match - if(set_->cranges) - { - if(e.flags() & regbase::nocollate) - s1 = s2; - else - traits_inst.transform(s1, s2); - for(i = 0; i < set_->cranges; ++i) - { - if(STR_COMP(s1, p) <= 0) - { - while(*p)++p; - ++p; - if(STR_COMP(s1, p) >= 0) - return set_->isnot ? next : ++next; - } - else - { - // skip first string - while(*p)++p; - ++p; - } - // skip second string - while(*p)++p; - ++p; - } - } - // - // try and match an equivalence class, NB only a single character can match - if(set_->cequivalents) - { - traits_inst.transform_primary(s1, s2); - for(i = 0; i < set_->cequivalents; ++i) - { - if(STR_COMP(s1, p) == 0) - return set_->isnot ? next : ++next; - // skip string - while(*p)++p; - ++p; - } - } - } - if(traits_inst.is_class(col, set_->cclasses) == true) - return set_->isnot ? next : ++next; - return set_->isnot ? ++next : next; -} - -template -class _priv_match_data -{ -public: - typedef typename boost::detail::rebind_allocator::type i_alloc; - typedef typename boost::detail::rebind_allocator::type it_alloc; - typedef typename regex_iterator_traits::difference_type difference_type; - - match_results_base temp_match; - // failure stacks: - jstack, Allocator> matches; - jstack prev_pos; - jstack prev_record; - jstack prev_acc; - int* accumulators; - unsigned int caccumulators; - difference_type state_count; - difference_type max_state_count; - iterator* loop_starts; - - _priv_match_data(const match_results_base&, iterator, iterator, std::size_t); - - ~_priv_match_data() - { - m_free(); - } - void m_free(); - void set_accumulator_size(unsigned int size); - int* get_accumulators() - { - return accumulators; - } - iterator* get_loop_starts() - { - return loop_starts; - } - void estimate_max_state_count(iterator a, iterator b, std::size_t states, std::random_access_iterator_tag*) - { - difference_type dist = boost::re_detail::distance(a,b); - states *= states; - difference_type lim = std::numeric_limits::max() - 1000 - states; - if(dist > (difference_type)(lim / states)) - max_state_count = lim; - else - max_state_count = 1000 + states * dist; - } - void estimate_max_state_count(iterator a, iterator b, std::size_t states, void*) - { - // we don't know how long the sequence is: - max_state_count = BOOST_REGEX_MAX_STATE_COUNT; - } -}; - -template -_priv_match_data::_priv_match_data(const match_results_base& m, iterator a, iterator b, std::size_t states) - : temp_match(m), matches(64, m.allocator()), prev_pos(64, m.allocator()), prev_record(64, m.allocator()) -{ - typedef typename regex_iterator_traits::iterator_category category; - - accumulators = 0; - caccumulators = 0; - loop_starts = 0; - state_count = 0; - estimate_max_state_count(a, b, states, static_cast(0)); -} - -template -void _priv_match_data::set_accumulator_size(unsigned int size) -{ - if(size > caccumulators) - { - m_free(); - caccumulators = size; - accumulators = i_alloc(temp_match.allocator()).allocate(caccumulators); - BOOST_REGEX_NOEH_ASSERT(accumulators) - loop_starts = it_alloc(temp_match.allocator()).allocate(caccumulators); - BOOST_REGEX_NOEH_ASSERT(loop_starts) - for(unsigned i = 0; i < caccumulators; ++i) - new (loop_starts + i) iterator(); - } -} - -template -void _priv_match_data::m_free() -{ - if(caccumulators) - { - i_alloc temp1(temp_match.allocator()); - temp1.deallocate(accumulators, caccumulators); - for(unsigned i = 0; i < caccumulators; ++i) - ::boost::re_detail::pointer_destroy(loop_starts + i); - it_alloc temp2(temp_match.allocator()); - temp2.deallocate(loop_starts, caccumulators); - } -} - -template -struct access_t : public reg_expression -{ - typedef typename is_byte::width_type width_type; - typedef reg_expression base_type; - typedef charT char_type; - typedef traits traits_type; - typedef Allocator alloc_type; - - static int repeat_count(const base_type& b) - { return base_type::repeat_count(b); } - static unsigned int restart_type(const base_type& b) - { return base_type::restart_type(b); } - static const re_syntax_base* first(const base_type& b) - { return base_type::first(b); } - static const unsigned char* get_map(const base_type& b) - { return base_type::get_map(b); } - static std::size_t leading_length(const base_type& b) - { return base_type::leading_length(b); } - static const kmp_info* get_kmp(const base_type& b) - { return base_type::get_kmp(b); } - static bool can_start(char_type c, const unsigned char* _map, unsigned char mask) - { - return reg_expression::can_start(c, _map, mask, width_type()); - } -}; - - -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -// -// Ugly ugly hack, -// template don't merge if they contain switch statements so declare these -// templates in unnamed namespace (ie with internal linkage), each translation -// unit then gets its own local copy, it works seemlessly but bloats the app. -namespace{ -#endif - -template -bool query_match_aux(iterator first, - iterator last, - match_results& m, - const reg_expression& e, - unsigned flags, - _priv_match_data& pd, - iterator* restart) -{ - typedef access_t access; - - if(e.flags() & regbase::failbit) - return false; - - typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; - typedef typename is_byte::width_type width_type; - typedef typename re_detail::regex_iterator_traits::difference_type difference_type; - - // declare some local aliases to reduce pointer loads - // good optimising compilers should make this unnecessary!! - jstack, Allocator>& matches = pd.matches; - jstack& prev_pos = pd.prev_pos; - jstack& prev_record = pd.prev_record; - jstack& prev_acc = pd.prev_acc; - match_results_base& temp_match = pd.temp_match; - temp_match.set_first(first); - difference_type& state_count = pd.state_count; - - const re_syntax_base* ptr = access::first(e); - bool match_found = false; - bool have_partial_match = false; - bool unwind_stack = false; - bool need_push_match = (e.mark_count() > 1); - int cur_acc = -1; // no active accumulator - pd.set_accumulator_size(access::repeat_count(e)); - int* accumulators = pd.get_accumulators(); - iterator* start_loop = pd.get_loop_starts(); - int k; // for loops - bool icase = e.flags() & regbase::icase; - *restart = first; - iterator base = first; - const traits& traits_inst = e.get_traits(); - // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never - // referenced - (void)traits_inst; - - // prepare m for failure: - /* - if((flags & match_init) == 0) - { - m.init_fail(first, last); - } */ - - retry: - - while(first != last) - { - jm_assert(ptr); - ++state_count; - switch(ptr->type) - { - case syntax_element_match: - match_jump: - { - // match found, save then fallback in case we missed a - // longer one. - if((flags & match_not_null) && (first == temp_match[0].first)) - goto failure; - if((flags & match_all) && (first != last)) - goto failure; - temp_match.set_second(first); - m.maybe_assign(temp_match); - match_found = true; - if(((flags & match_any) && ((first == last) || !(flags & match_all))) || ((first == last) && (need_push_match == false))) - { - // either we don't care what we match or we've matched - // the whole string and can't match anything longer. - while(matches.empty() == false) - matches.pop(); - while(prev_pos.empty() == false) - prev_pos.pop(); - while(prev_record.empty() == false) - prev_record.pop(); - while(prev_acc.empty() == false) - prev_acc.pop(); - return true; - } - } - goto failure; - case syntax_element_startmark: - start_mark_jump: - if(static_cast(ptr)->index > 0) - { - temp_match.set_first(first, static_cast(ptr)->index); - } - else if( - (static_cast(ptr)->index == -1) - || (static_cast(ptr)->index == -2) - ) - { - matches.push(temp_match); - for(k = 0; k <= cur_acc; ++k) - prev_pos.push(start_loop[k]); - prev_pos.push(first); - prev_record.push(ptr); - for(k = 0; k <= cur_acc; ++k) - prev_acc.push(accumulators[k]); - prev_acc.push(cur_acc); - prev_acc.push(match_found); - match_found = false; - // skip next jump and fall through: - ptr = ptr->next.p; - } - ptr = ptr->next.p; - break; - case syntax_element_endmark: - end_mark_jump: - if(static_cast(ptr)->index > 0) - { - temp_match.set_second(first, static_cast(ptr)->index); - } - else if( - (static_cast(ptr)->index == -1) - || (static_cast(ptr)->index == -2) - ) - { - match_found = true; - unwind_stack = true; - goto failure; - } - ptr = ptr->next.p; - break; - case syntax_element_literal: - { - unsigned int len = static_cast(ptr)->length; - const charT* what = reinterpret_cast(static_cast(ptr) + 1); - // - // compare string with what we stored in - // our records: - for(unsigned int i = 0; i < len; ++i, ++first) - { - if((first == last) || (traits_inst.translate(*first, icase) != what[i])) - goto failure; - } - ptr = ptr->next.p; - break; - } - case syntax_element_start_line: - outer_line_check: - if(first == temp_match[0].first) - { - // we're at the start of the buffer - if(flags & match_prev_avail) - { - inner_line_check: - // check the previous value even though its before - // the start of our "buffer". - iterator t(first); - --t; - if(traits::is_separator(*t) && !((*t == '\r') && (*first == '\n')) ) - { - ptr = ptr->next.p; - continue; - } - goto failure; - } - if((flags & match_not_bol) == 0) - { - ptr = ptr->next.p; - continue; - } - goto failure; - } - // we're in the middle of the string - goto inner_line_check; - case syntax_element_end_line: - // we're not yet at the end so *first is always valid: - if(traits::is_separator(*first)) - { - if((first != base) || (flags & match_prev_avail)) - { - // check that we're not in the middle of \r\n sequence - iterator t(first); - --t; - if((*t == '\r') && (*first == '\n')) - { - goto failure; - } - } - ptr = ptr->next.p; - continue; - } - goto failure; - case syntax_element_wild: - // anything except possibly NULL or \n: - if(traits::is_separator(*first)) - { - if(flags & match_not_dot_newline) - goto failure; - ptr = ptr->next.p; - ++first; - continue; - } - if(*first == charT(0)) - { - if(flags & match_not_dot_null) - goto failure; - ptr = ptr->next.p; - ++first; - continue; - } - ptr = ptr->next.p; - ++first; - break; - case syntax_element_word_boundary: - { - // prev and this character must be opposites: -#if defined(BOOST_REGEX_USE_C_LOCALE) && defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) - bool b = traits::is_class(*first, traits::char_class_word); -#else - bool b = traits_inst.is_class(*first, traits::char_class_word); -#endif - if((first == temp_match[0].first) && ((flags & match_prev_avail) == 0)) - { - if(flags & match_not_bow) - b ^= true; - else - b ^= false; - } - else - { - --first; - b ^= traits_inst.is_class(*first, traits::char_class_word); - ++first; - } - if(b) - { - ptr = ptr->next.p; - continue; - } - goto failure; - } - case syntax_element_within_word: - // both prev and this character must be traits::char_class_word: - if(traits_inst.is_class(*first, traits::char_class_word)) - { - bool b; - if((first == temp_match[0].first) && ((flags & match_prev_avail) == 0)) - b = false; - else - { - --first; - b = traits_inst.is_class(*first, traits::char_class_word); - ++first; - } - if(b) - { - ptr = ptr->next.p; - continue; - } - } - goto failure; - case syntax_element_word_start: - if((first == temp_match[0].first) && ((flags & match_prev_avail) == 0)) - { - // start of buffer: - if(flags & match_not_bow) - goto failure; - if(traits_inst.is_class(*first, traits::char_class_word)) - { - ptr = ptr->next.p; - continue; - } - goto failure; - } - // otherwise inside buffer: - if(traits_inst.is_class(*first, traits::char_class_word)) - { - iterator t(first); - --t; - if(traits_inst.is_class(*t, traits::char_class_word) == false) - { - ptr = ptr->next.p; - continue; - } - } - goto failure; // if we fall through to here then we've failed - case syntax_element_word_end: - if((first == temp_match[0].first) && ((flags & match_prev_avail) == 0)) - goto failure; // start of buffer can't be end of word - - // otherwise inside buffer: - if(traits_inst.is_class(*first, traits::char_class_word) == false) - { - iterator t(first); - --t; - if(traits_inst.is_class(*t, traits::char_class_word)) - { - ptr = ptr->next.p; - continue; - } - } - goto failure; // if we fall through to here then we've failed - case syntax_element_buffer_start: - if((first != temp_match[0].first) || (flags & match_not_bob)) - goto failure; - // OK match: - ptr = ptr->next.p; - break; - case syntax_element_buffer_end: - if((first != last) || (flags & match_not_eob)) - goto failure; - // OK match: - ptr = ptr->next.p; - break; - case syntax_element_backref: - { - // compare with what we previously matched: - iterator i = temp_match[static_cast(ptr)->index].first; - iterator j = temp_match[static_cast(ptr)->index].second; - while(i != j) - { - if((first == last) || (traits_inst.translate(*first, icase) != traits_inst.translate(*i, icase))) - goto failure; - ++i; - ++first; - } - ptr = ptr->next.p; - break; - } - case syntax_element_long_set: - { - // let the traits class do the work: - iterator t = re_is_set_member(first, last, static_cast(ptr), e); - if(t != first) - { - ptr = ptr->next.p; - first = t; - continue; - } - goto failure; - } - case syntax_element_set: - // lookup character in table: - if(static_cast(ptr)->_map[(traits_uchar_type)traits_inst.translate(*first, icase)]) - { - ptr = ptr->next.p; - ++first; - continue; - } - goto failure; - case syntax_element_jump: - ptr = static_cast(ptr)->alt.p; - continue; - case syntax_element_alt: - { - // alt_jump: - if(access::can_start(*first, static_cast(ptr)->_map, (unsigned char)mask_take)) - { - // we can take the first alternative, - // see if we need to push next alternative: - if(access::can_start(*first, static_cast(ptr)->_map, mask_skip)) - { - if(need_push_match) - matches.push(temp_match); - for(k = 0; k <= cur_acc; ++k) - prev_pos.push(start_loop[k]); - prev_pos.push(first); - prev_record.push(ptr); - for(k = 0; k <= cur_acc; ++k) - prev_acc.push(accumulators[k]); - prev_acc.push(cur_acc); - } - ptr = ptr->next.p; - continue; - } - if(access::can_start(*first, static_cast(ptr)->_map, mask_skip)) - { - ptr = static_cast(ptr)->alt.p; - continue; - } - goto failure; // neither option is possible - } - case syntax_element_rep: - { - // repeater_jump: - // if we're moving to a higher id (nested repeats etc) - // zero out our accumualtors: - if(cur_acc < static_cast(ptr)->id) - { - cur_acc = static_cast(ptr)->id; - accumulators[cur_acc] = 0; - start_loop[cur_acc] = first; - } - - cur_acc = static_cast(ptr)->id; - - if(static_cast(ptr)->leading) - *restart = first; - - //charT c = traits_inst.translate(*first); - - // first of all test for special case where this is last element, - // if that is the case then repeat as many times as possible, - // as long as the repeat is greedy: - - if((static_cast(ptr)->alt.p->type == syntax_element_match) - && (static_cast(ptr)->greedy == true)) - { - // see if we can take the repeat: - if(((unsigned int)accumulators[cur_acc] < static_cast(ptr)->max) - && access::can_start(*first, static_cast(ptr)->_map, mask_take)) - { - // push terminating match as fallback: - if((unsigned int)accumulators[cur_acc] >= static_cast(ptr)->min) - { - if((prev_record.empty() == false) && (prev_record.peek() == static_cast(ptr)->alt.p)) - { - // we already have the required fallback - // don't add any more, just update this one: - if(need_push_match) - matches.peek() = temp_match; - prev_pos.peek() = first; - } - else - { - if(need_push_match) - matches.push(temp_match); - prev_pos.push(first); - prev_record.push(static_cast(ptr)->alt.p); - } - } - // move to next item in list: - if((first != start_loop[cur_acc]) || !accumulators[cur_acc]) - { - ++accumulators[cur_acc]; - ptr = ptr->next.p; - start_loop[cur_acc] = first; - continue; - } - else if((unsigned int)accumulators[cur_acc] < static_cast(ptr)->min) - { - // the repeat was null, and we haven't gone round min times yet, - // since all subsequent repeats will be null as well, just update - // our repeat count and skip out. - accumulators[cur_acc] = static_cast(ptr)->min; - ptr = static_cast(ptr)->alt.p; - continue; - } - goto failure; - } - // see if we can skip the repeat: - if(((unsigned int)accumulators[cur_acc] >= static_cast(ptr)->min) - && access::can_start(*first, static_cast(ptr)->_map, mask_skip)) - { - ptr = static_cast(ptr)->alt.p; - continue; - } - // otherwise fail: - goto failure; - } - - // OK if we get to here then the repeat is either non-terminal or non-greedy, - // see if we can skip the repeat: - if(((unsigned int)accumulators[cur_acc] >= static_cast(ptr)->min) - && access::can_start(*first, static_cast(ptr)->_map, mask_skip)) - { - // see if we can push failure info: - if(((unsigned int)accumulators[cur_acc] < static_cast(ptr)->max) - && access::can_start(*first, static_cast(ptr)->_map, mask_take)) - { - // check to see if the last loop matched a NULL string - // if so then we really don't want to loop again: - if(((unsigned int)accumulators[cur_acc] == static_cast(ptr)->min) - || (first != start_loop[cur_acc])) - { - if(need_push_match) - matches.push(temp_match); - prev_pos.push(first); - prev_record.push(ptr); - for(k = 0; k <= cur_acc; ++k) - prev_acc.push(accumulators[k]); - // for non-greedy repeats save whether we have a match already: - if(static_cast(ptr)->greedy == false) - { - prev_acc.push(match_found); - match_found = false; - } - } - } - ptr = static_cast(ptr)->alt.p; - continue; - } - - // otherwise see if we can take the repeat: - if(((unsigned int)accumulators[cur_acc] < static_cast(ptr)->max) - && access::can_start(*first, static_cast(ptr)->_map, mask_take) && - ((first != start_loop[cur_acc]) || !accumulators[cur_acc])) - { - // move to next item in list: - ++accumulators[cur_acc]; - ptr = ptr->next.p; - start_loop[cur_acc] = first; - continue; - } - else if((first == start_loop[cur_acc]) && accumulators[cur_acc] && ((unsigned int)accumulators[cur_acc] < static_cast(ptr)->min)) - { - // the repeat was null, and we haven't gone round min times yet, - // since all subsequent repeats will be null as well, just update - // our repeat count and skip out. - accumulators[cur_acc] = static_cast(ptr)->min; - ptr = static_cast(ptr)->alt.p; - continue; - } - - // if we get here then neither option is allowed so fail: - goto failure; - - } - case syntax_element_combining: - if(traits_inst.is_combining(traits_inst.translate(*first, icase))) - goto failure; - ++first; - while((first != last) && traits_inst.is_combining(traits_inst.translate(*first, icase)))++first; - ptr = ptr->next.p; - continue; - case syntax_element_soft_buffer_end: - { - if(flags & match_not_eob) - goto failure; - iterator p(first); - while((p != last) && traits_inst.is_separator(traits_inst.translate(*p, icase)))++p; - if(p != last) - goto failure; - ptr = ptr->next.p; - continue; - } - case syntax_element_restart_continue: - if(first != temp_match[-1].first) - goto failure; - ptr = ptr->next.p; - continue; - default: - jm_assert(0); // should never get to here!! - return false; - } - } - - // - // if we get to here then we've run out of characters to match against, - // we could however still have non-character regex items left - if((ptr->can_be_null == 0) && ((flags & match_partial) == 0)) - goto failure; - while(true) - { - jm_assert(ptr); - ++state_count; - switch(ptr->type) - { - case syntax_element_match: - goto match_jump; - case syntax_element_startmark: - goto start_mark_jump; - case syntax_element_endmark: - goto end_mark_jump; - case syntax_element_start_line: - goto outer_line_check; - case syntax_element_end_line: - // we're at the end so *first is never valid: - if((flags & match_not_eol) == 0) - { - ptr = ptr->next.p; - continue; - } - goto failure; - case syntax_element_word_boundary: - case syntax_element_word_end: - if(((flags & match_not_eow) == 0) && (first != temp_match[0].first)) - { - iterator t(first); - --t; - if(traits_inst.is_class(*t, traits::char_class_word)) - { - ptr = ptr->next.p; - continue; - } - } - goto failure; - case syntax_element_buffer_end: - case syntax_element_soft_buffer_end: - if(flags & match_not_eob) - goto failure; - // OK match: - ptr = ptr->next.p; - break; - case syntax_element_jump: - ptr = static_cast(ptr)->alt.p; - continue; - case syntax_element_alt: - if(ptr->can_be_null & mask_take) - { - // we can test the first alternative, - // see if we need to push next alternative: - if(ptr->can_be_null & mask_skip) - { - if(need_push_match) - matches.push(temp_match); - for(k = 0; k <= cur_acc; ++k) - prev_pos.push(start_loop[k]); - prev_pos.push(first); - prev_record.push(ptr); - for(k = 0; k <= cur_acc; ++k) - prev_acc.push(accumulators[k]); - prev_acc.push(cur_acc); - } - ptr = ptr->next.p; - continue; - } - if(ptr->can_be_null & mask_skip) - { - ptr = static_cast(ptr)->alt.p; - continue; - } - goto failure; // neither option is possible - case syntax_element_rep: - // if we're moving to a higher id (nested repeats etc) - // zero out our accumualtors: - if(cur_acc < static_cast(ptr)->id) - { - cur_acc = static_cast(ptr)->id; - accumulators[cur_acc] = 0; - start_loop[cur_acc] = first; - } - - cur_acc = static_cast(ptr)->id; - - // see if we can skip the repeat: - if(((unsigned int)accumulators[cur_acc] >= static_cast(ptr)->min) - && ((ptr->can_be_null & mask_skip) || (flags & match_partial))) - { - // don't push failure info, there's no point: - ptr = static_cast(ptr)->alt.p; - continue; - } - - // otherwise see if we can take the repeat: - if(((unsigned int)accumulators[cur_acc] < static_cast(ptr)->max) - && (((ptr->can_be_null & (mask_take | mask_skip)) == (mask_take | mask_skip))) || (flags & match_partial)) - { - // move to next item in list: - ++accumulators[cur_acc]; - ptr = ptr->next.p; - start_loop[cur_acc] = first; - continue; - } - - // if we get here then neither option is allowed so fail: - goto failure; - case syntax_element_restart_continue: - if(first != temp_match[-1].first) - goto failure; - ptr = ptr->next.p; - continue; - case syntax_element_backref: - if(temp_match[static_cast(ptr)->index].first - != temp_match[static_cast(ptr)->index].second) - goto failure; - ptr = ptr->next.p; - continue; - default: - goto failure; - } - } - - failure: - - // - // check to see if we've been searching too many states: - // - if(state_count >= pd.max_state_count) - { -#ifndef BOOST_NO_EXCEPTIONS - throw std::runtime_error("Max regex search depth exceeded."); -#else - while(matches.empty() == false) - matches.pop(); - while(prev_pos.empty() == false) - prev_pos.pop(); - while(prev_record.empty() == false) - prev_record.pop(); - while(prev_acc.empty() == false) - prev_acc.pop(); - return false; -#endif - } - - // - // check for possible partial match: - // - if((flags & match_partial) - && !match_found // no full match already - && (base != first) // some charcters have been consumed - && (first == last)) // end of input has been reached - { - have_partial_match = true; - temp_match.set_second(first, 0, false); - m.maybe_assign(temp_match); - } - - if(prev_record.empty() == false) - { - ptr = prev_record.peek(); - switch(ptr->type) - { - case syntax_element_alt: - // get next alternative: - ptr = static_cast(ptr)->alt.p; - if(need_push_match) - matches.pop(temp_match); - prev_acc.pop(cur_acc); - for(k = cur_acc; k >= 0; --k) - prev_acc.pop(accumulators[k]); - prev_pos.pop(first); - for(k = cur_acc; k >= 0; --k) - prev_pos.pop(start_loop[k]); - prev_record.pop(); - if(unwind_stack) goto failure; // unwinding forward assert - goto retry; - case syntax_element_rep: - { - // we're doing least number of repeats first, - // increment count and repeat again: - bool saved_matched = match_found; - if(need_push_match) - matches.pop(temp_match); - prev_pos.pop(first); - cur_acc = static_cast(ptr)->id; - if(static_cast(ptr)->greedy == false) - { - saved_matched = prev_acc.peek(); - prev_acc.pop(); - } - for(k = cur_acc; k >= 0; --k) - prev_acc.pop(accumulators[k]); - prev_record.pop(); - if(unwind_stack) goto failure; // unwinding forward assert - if((unsigned int)++accumulators[cur_acc] > static_cast(ptr)->max) - goto failure; // repetions exhausted. - // - // if the repeat is non-greedy, and we found a match then fail again: - if((static_cast(ptr)->greedy == false) && (match_found == true)) - { - goto failure; - } - else if (match_found == false) - match_found = saved_matched; - ptr = ptr->next.p; - start_loop[cur_acc] = first; - goto retry; - } - case syntax_element_startmark: - { - bool saved_matched = match_found; - matches.pop(temp_match); - match_found = prev_acc.peek(); - prev_acc.pop(); - prev_acc.pop(cur_acc); - for(k = cur_acc; k >= 0; --k) - prev_acc.pop(accumulators[k]); - prev_pos.pop(first); - for(k = cur_acc; k >= 0; --k) - prev_pos.pop(start_loop[k]); - prev_record.pop(); - unwind_stack = false; - if(static_cast(ptr)->index == -1) - { - if (saved_matched == false) - goto failure; - ptr = static_cast(ptr->next.p)->alt.p->next.p; - goto retry; - } - if(static_cast(ptr)->index == -2) - { - if (saved_matched == true) - goto failure; - ptr = static_cast(ptr->next.p)->alt.p->next.p; - goto retry; - } - else goto failure; - } - case syntax_element_match: - if(need_push_match) - matches.pop(temp_match); - prev_pos.pop(first); - prev_record.pop(); - if(unwind_stack) goto failure; // unwinding forward assert - goto retry; - default: - jm_assert(0); - // mustn't get here!! - } - } - - if(match_found || have_partial_match) - { - pd.state_count = 0; - return true; - } - - // if we get to here then everything has failed - // and no match was found: - return false; -} -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -} // namespace -#endif - - -template -void _skip_and_inc(unsigned int& clines, iterator& last_line, iterator& first, const iterator last) -{ - while(first != last) - { - if(*first == '\n') - { - last_line = ++first; - ++clines; - } - else - ++first; - } -} - -template -void _skip_and_dec(unsigned int& clines, iterator& last_line, iterator& first, iterator base, std::size_t len) -{ - bool need_line = false; - for(std::size_t i = 0; i < len; ++i) - { - --first; - if(*first == '\n') - { - need_line = true; - --clines; - } - } - - if(need_line) - { - last_line = first; - - if(last_line != base) - --last_line; - else - return; - - while((last_line != base) && (*last_line != '\n')) - --last_line; - if(*last_line == '\n') - ++last_line; - } -} - -template -inline void _inc_one(unsigned int& clines, iterator& last_line, iterator& first) -{ - if(*first == '\n') - { - last_line = ++first; - ++clines; - } - else - ++first; -} - -template -struct grep_search_predicate -{ - match_results* pm; - grep_search_predicate(match_results* p) : pm(p) {} - bool operator()(const match_results& m) - { - *pm = static_cast&>(m); - return false; - } -}; - -#if !defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - -template -inline const match_results_base& grep_out_type(const grep_search_predicate& o, const Allocator&) -{ - return *(o.pm); -} - -#endif - -template -inline const Allocator& grep_out_type(const T&, const Allocator& a) -{ - return a; -} - -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -// -// Ugly ugly hack, -// template don't merge if they contain switch statements so declare these -// templates in unnamed namespace (ie with internal linkage), each translation -// unit then gets its own local copy, it works seemlessly but bloats the app. -namespace{ -#endif - -// -// reg_grep2: -// find all non-overlapping matches within the sequence first last: -// -template -unsigned int reg_grep2(Predicate foo, I first, I last, const reg_expression& e, unsigned flags, A2 a) -{ - typedef access_t access; - - if(e.flags() & regbase::failbit) - return 0; - - typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; - typedef typename is_byte::width_type width_type; - - match_results m(grep_out_type(foo, a)); - I restart; - m.set_size(e.mark_count(), first, last); - m.set_line(1, first); - m.set_base(first); - - unsigned int clines = 1; - unsigned int cmatches = 0; - I last_line = first; - I next_base; - I base = first; - bool need_init; - bool leading_match = false; - const traits& traits_inst = e.get_traits(); - // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never - // referenced - (void)traits_inst; - - flags |= match_init; - - _priv_match_data pd(m, first, last, e.size()); - - const unsigned char* _map = access::get_map(e); - unsigned int type; - - if(first == last) - { - // special case, only test if can_be_null, - // don't dereference any pointers!! - if(access::first(e)->can_be_null) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - foo(m); - ++cmatches; - } - } - return cmatches; - } - - // try one time whatever: - if( access::can_start(*first, _map, (unsigned char)mask_any) ) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - ++cmatches; - leading_match = true; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - // trying to match again with match_not_null set if this - // is a null match... - need_init = true; - if(first == m[0].second) - { - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - if(query_match_aux(first, last, m, e, flags | match_not_null, pd, &restart)) - { - ++cmatches; - if(foo(m) == false) - return cmatches; - } - else - { - need_init = false; - leading_match = false; - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - if(need_init) - { - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - } - } - else - { - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - else - _inc_one(clines, last_line, first); - flags |= match_prev_avail | match_not_bob; - - - // depending on what the first record is we may be able to - // optimise the search: - type = (flags & match_continuous) ? - static_cast(regbase::restart_continue) - : static_cast(access::restart_type(e)); - - if(type == regbase::restart_buf) - return cmatches; - - switch(type) - { - case regbase::restart_lit: - case regbase::restart_fixed_lit: - { - const kmp_info* info = access::get_kmp(e); - int len = info->len; - const charT* x = info->pstr; - int j = 0; - bool icase = e.flags() & regbase::icase; - while (first != last) - { - while((j > -1) && (x[j] != traits_inst.translate(*first, icase))) - j = info->kmp_next[j]; - _inc_one(clines, last_line, first); - ++j; - if(j >= len) - { - if(type == regbase::restart_fixed_lit) - { - _skip_and_dec(clines, last_line, first, base, j); - restart = first; - std::advance(restart, len); - m.set_first(first); - m.set_second(restart); - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - _skip_and_inc(clines, last_line, first, restart); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - j = 0; - } - else - { - restart = first; - _skip_and_dec(clines, last_line, first, base, j); - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - j = 0; - } - else - { - for(int k = 0; (restart != first) && (k < j); ++k, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - j = 0; //we could do better than this... - } - } - } - } - break; - } - case regbase::restart_any: - { - while(first != last) - { - if( access::can_start(*first, _map, (unsigned char)mask_any) ) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - // trying to match again with match_not_null set if this - // is a null match... - need_init = true; - if(first == m[0].second) - { - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - if(query_match_aux(first, last, m, e, flags | match_not_null, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - } - else - { - need_init = false; - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - if(need_init) - { - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - } - continue; - } - else - { - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - else - _inc_one(clines, last_line, first); - } - } - break; - case regbase::restart_word: - { - // do search optimised for word starts: - while(first != last) - { - --first; - if(*first == '\n') - --clines; - // skip the word characters: - while((first != last) && traits_inst.is_class(*first, traits::char_class_word)) - ++first; - // now skip the white space: - while((first != last) && (traits_inst.is_class(*first, traits::char_class_word) == false)) - { - #ifdef __GNUC__ - // - // hack to work around gcc optimisation bug - // just expand the contents of _inc_one here: - if(*first == '\n') - { - last_line = ++first; - ++clines; - } - else - ++first; - #else - _inc_one(clines, last_line, first); - #endif - } - if(first == last) - break; - - if( access::can_start(*first, _map, (unsigned char)mask_any) ) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - // trying to match again with match_not_null set if this - // is a null match... - need_init = true; - if(first == m[0].second) - { - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - if(query_match_aux(first, last, m, e, flags | match_not_null, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - } - else - { - need_init = false; - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - if(need_init) - { - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - } - } - else - { - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - else - _inc_one(clines, last_line, first); - } - } - break; - case regbase::restart_line: - { - // do search optimised for line starts: - while(first != last) - { - // find first charcter after a line break: - --first; - if(*first == '\n') - --clines; - while((first != last) && (*first != '\n')) - ++first; - if(first == last) - break; - ++first; - if(first == last) - break; - - ++clines; - last_line = first; - - if( access::can_start(*first, _map, (unsigned char)mask_any) ) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - // trying to match again with match_not_null set if this - // is a null match... - need_init = true; - if(first == m[0].second) - { - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - if(query_match_aux(first, last, m, e, flags | match_not_null, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - } - else - { - need_init = false; - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - if(need_init) - { - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - } - } - else - { - for(unsigned int i = 0; (restart != first) && (i < access::leading_length(e)); ++i, --restart) - {} // dwa 10/20/2000 - warning suppression for MWCW - if(restart != last) - ++restart; - _skip_and_inc(clines, last_line, first, restart); - } - } - else - _inc_one(clines, last_line, first); - } - } - break; - case regbase::restart_continue: - { - if(!leading_match) - return cmatches; - while(first != last) - { - if( access::can_start(*first, _map, (unsigned char)mask_any) ) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - if(m[0].second == last) - return cmatches; - // update to end of what matched - // trying to match again with match_not_null set if this - // is a null match... - if(first == m[0].second) - { - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - if(query_match_aux(first, last, m, e, flags | match_not_null, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - } - else - return cmatches; // can't continue from null match - } - _skip_and_inc(clines, last_line, first, m[0].second); - next_base = m[0].second; - pd.temp_match.init_fail(next_base, last); - m.init_fail(next_base, last); - continue; - } - } - return cmatches; - } - } - break; - } - - - // finally check trailing null string: - if(access::first(e)->can_be_null) - { - if(query_match_aux(first, last, m, e, flags, pd, &restart)) - { - m.set_line(clines, last_line); - ++cmatches; - if(foo(m) == false) - return cmatches; - } - } - - return cmatches; -} -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -} // namespace {anon} -#endif - -} // namespace re_detail - -// -// proc regex_match -// returns true if the specified regular expression matches -// the whole of the input. Fills in what matched in m. -// -template -bool regex_match(iterator first, iterator last, match_results& m, const reg_expression& e, unsigned flags = match_default) -{ - // prepare m for failure: - if((flags & match_init) == 0) - { - m.set_size(e.mark_count(), first, last); - m.set_base(first); - m.set_line(1, first); - } - flags |= match_all; // must match all of input. - re_detail::_priv_match_data pd(m, first, last, e.size()); - iterator restart; - bool result = re_detail::query_match_aux(first, last, m, e, flags, pd, &restart); - return result; -} -template -bool regex_match(iterator first, iterator last, const reg_expression& e, unsigned flags = match_default) -{ - match_results m; - return regex_match(first, last, m, e, flags); -} -// -// query_match convenience interfaces: -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -// -// this isn't really a partial specialisation, but template function -// overloading - if the compiler doesn't support partial specialisation -// then it really won't support this either: -template -inline bool regex_match(const charT* str, - match_results& m, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_match(str, str + traits::length(str), m, e, flags); -} - -template -inline bool regex_match(const std::basic_string& s, - match_results::const_iterator, Allocator>& m, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_match(s.begin(), s.end(), m, e, flags); -} -template -inline bool regex_match(const charT* str, - const reg_expression& e, - unsigned flags = match_default) -{ - match_results m; - return regex_match(str, str + traits::length(str), m, e, flags); -} - -template -inline bool regex_match(const std::basic_string& s, - const reg_expression& e, - unsigned flags = match_default) -{ - typedef typename std::basic_string::const_iterator iterator; - match_results m; - return regex_match(s.begin(), s.end(), m, e, flags); -} -#else // partial ordering -inline bool regex_match(const char* str, - cmatch& m, - const regex& e, - unsigned flags = match_default) -{ - return regex_match(str, str + regex::traits_type::length(str), m, e, flags); -} -inline bool regex_match(const char* str, - const regex& e, - unsigned flags = match_default) -{ - match_results m; - return regex_match(str, str + regex::traits_type::length(str), m, e, flags); -} -#ifndef BOOST_NO_WREGEX -inline bool regex_match(const wchar_t* str, - wcmatch& m, - const wregex& e, - unsigned flags = match_default) -{ - return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); -} -inline bool regex_match(const wchar_t* str, - const wregex& e, - unsigned flags = match_default) -{ - match_results m; - return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); -} -#endif -inline bool regex_match(const std::string& s, - match_results& m, - const regex& e, - unsigned flags = match_default) -{ - return regex_match(s.begin(), s.end(), m, e, flags); -} -inline bool regex_match(const std::string& s, - const regex& e, - unsigned flags = match_default) -{ - match_results m; - return regex_match(s.begin(), s.end(), m, e, flags); -} -#if !defined(BOOST_NO_WREGEX) -inline bool regex_match(const std::basic_string& s, - match_results::const_iterator, wregex::allocator_type>& m, - const wregex& e, - unsigned flags = match_default) -{ - return regex_match(s.begin(), s.end(), m, e, flags); -} -inline bool regex_match(const std::basic_string& s, - const wregex& e, - unsigned flags = match_default) -{ - match_results::const_iterator, wregex::allocator_type> m; - return regex_match(s.begin(), s.end(), m, e, flags); -} -#endif - -#endif - -template -bool regex_search(iterator first, iterator last, match_results& m, const reg_expression& e, unsigned flags = match_default) -{ - if(e.flags() & regbase::failbit) - return false; - - typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; - - return re_detail::reg_grep2(re_detail::grep_search_predicate(&m), first, last, e, flags, m.allocator()); -} - -// -// regex_search convenience interfaces: -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -// -// this isn't really a partial specialisation, but template function -// overloading - if the compiler doesn't support partial specialisation -// then it really won't support this either: -template -inline bool regex_search(const charT* str, - match_results& m, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_search(str, str + traits::length(str), m, e, flags); -} - -template -inline bool regex_search(const std::basic_string& s, - match_results::const_iterator, Allocator>& m, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_search(s.begin(), s.end(), m, e, flags); -} -#else // partial specialisation -inline bool regex_search(const char* str, - cmatch& m, - const regex& e, - unsigned flags = match_default) -{ - return regex_search(str, str + regex::traits_type::length(str), m, e, flags); -} -#ifndef BOOST_NO_WREGEX -inline bool regex_search(const wchar_t* str, - wcmatch& m, - const wregex& e, - unsigned flags = match_default) -{ - return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); -} -#endif -inline bool regex_search(const std::string& s, - match_results& m, - const regex& e, - unsigned flags = match_default) -{ - return regex_search(s.begin(), s.end(), m, e, flags); -} -#if !defined(BOOST_NO_WREGEX) -inline bool regex_search(const std::basic_string& s, - match_results::const_iterator, wregex::allocator_type>& m, - const wregex& e, - unsigned flags = match_default) -{ - return regex_search(s.begin(), s.end(), m, e, flags); -} -#endif - -#endif - - -// -// regex_grep: -// find all non-overlapping matches within the sequence first last: -// -template -inline unsigned int regex_grep(Predicate foo, iterator first, iterator last, const reg_expression& e, unsigned flags = match_default) -{ - return re_detail::reg_grep2(foo, first, last, e, flags, e.allocator()); -} - -// -// regex_grep convenience interfaces: -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -// -// this isn't really a partial specialisation, but template function -// overloading - if the compiler doesn't support partial specialisation -// then it really won't support this either: -template -inline unsigned int regex_grep(Predicate foo, const charT* str, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_grep(foo, str, str + traits::length(str), e, flags); -} - -template -inline unsigned int regex_grep(Predicate foo, const std::basic_string& s, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_grep(foo, s.begin(), s.end(), e, flags); -} -#else // partial specialisation -inline unsigned int regex_grep(bool (*foo)(const cmatch&), const char* str, - const regex& e, - unsigned flags = match_default) -{ - return regex_grep(foo, str, str + regex::traits_type::length(str), e, flags); -} -#ifndef BOOST_NO_WREGEX -inline unsigned int regex_grep(bool (*foo)(const wcmatch&), const wchar_t* str, - const wregex& e, - unsigned flags = match_default) -{ - return regex_grep(foo, str, str + wregex::traits_type::length(str), e, flags); -} -#endif -inline unsigned int regex_grep(bool (*foo)(const match_results&), const std::string& s, - const regex& e, - unsigned flags = match_default) -{ - return regex_grep(foo, s.begin(), s.end(), e, flags); -} -#if !defined(BOOST_NO_WREGEX) -inline unsigned int regex_grep(bool (*foo)(const match_results::const_iterator, wregex::allocator_type>&), - const std::basic_string& s, - const wregex& e, - unsigned flags = match_default) -{ - return regex_grep(foo, s.begin(), s.end(), e, flags); -} -#endif - -#endif - - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#endif // BOOST_REGEX_MATCH_HPP - - - - - - - - - - - - - - - - - - diff --git a/include/boost/regex/v3/regex_raw_buffer.hpp b/include/boost/regex/v3/regex_raw_buffer.hpp deleted file mode 100644 index 71f912ce..00000000 --- a/include/boost/regex/v3/regex_raw_buffer.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_raw_buffer.hpp - * VERSION see - * DESCRIPTION: Raw character buffer for regex code. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_RAW_BUFFER_HPP -#define BOOST_REGEX_RAW_BUFFER_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -struct empty_padding{}; - -union padding -{ - void* p; - unsigned int i; -}; - -template -struct padding3 -{ - enum{ - padding_size = 8, - padding_mask = 7 - }; -}; - -template<> -struct padding3<2> -{ - enum{ - padding_size = 2, - padding_mask = 1 - }; -}; - -template<> -struct padding3<4> -{ - enum{ - padding_size = 4, - padding_mask = 3 - }; -}; - -template<> -struct padding3<8> -{ - enum{ - padding_size = 8, - padding_mask = 7 - }; -}; - -template<> -struct padding3<16> -{ - enum{ - padding_size = 16, - padding_mask = 15 - }; -}; - -enum{ - padding_size = padding3::padding_size, - padding_mask = padding3::padding_mask -}; - -// -// class raw_storage -// basically this is a simplified vector -// this is used by reg_expression for expression storage -// - -template -class raw_storage -{ -public: - typedef Allocator allocator_type; - typedef typename boost::detail::rebind_allocator::type alloc_inst_type; - typedef typename alloc_inst_type::size_type size_type; - typedef typename alloc_inst_type::pointer pointer; -private: - // - // empty member optimisation: - struct alloc_data : public alloc_inst_type - { - typename alloc_inst_type::pointer last; - alloc_data(const Allocator& a) : alloc_inst_type(a){} - } alloc_inst; - pointer start, end; -public: - - raw_storage(const Allocator& a = Allocator()); - raw_storage(size_type n, const Allocator& a = Allocator()); - - ~raw_storage() - { - alloc_inst.deallocate(start, (alloc_inst.last - start)); - } - - void BOOST_REGEX_CALL resize(size_type n); - - void* BOOST_REGEX_CALL extend(size_type n) - { - if(size_type(alloc_inst.last - end) < n) - resize(n + (end - start)); - register void* result = end; - end += n; - return result; - } - - void* BOOST_REGEX_CALL insert(size_type pos, size_type n); - - size_type BOOST_REGEX_CALL size() - { - return end - start; - } - - size_type BOOST_REGEX_CALL capacity() - { - return alloc_inst.last - start; - } - - void* BOOST_REGEX_CALL data()const - { - return start; - } - - size_type BOOST_REGEX_CALL index(void* ptr) - { - return reinterpret_cast(ptr) - reinterpret_cast(data()); - } - - void BOOST_REGEX_CALL clear() - { - end = start; - } - - void BOOST_REGEX_CALL align() - { - // move end up to a boundary: - end = reinterpret_cast(start) + (((reinterpret_cast(end) - reinterpret_cast(start)) + padding_mask) & ~padding_mask); - } - - Allocator BOOST_REGEX_CALL allocator()const; -}; - -template -raw_storage::raw_storage(const Allocator& a) - : alloc_inst(a) -{ - start = end = alloc_inst.allocate(1024); - BOOST_REGEX_NOEH_ASSERT(start) - alloc_inst.last = start + 1024; -} - -template -raw_storage::raw_storage(size_type n, const Allocator& a) - : alloc_inst(a) -{ - start = end = alloc_inst.allocate(n); - BOOST_REGEX_NOEH_ASSERT(start) - alloc_inst.last = start + n; -} - -template -Allocator BOOST_REGEX_CALL raw_storage::allocator()const -{ - return alloc_inst; -} - -template -void BOOST_REGEX_CALL raw_storage::resize(size_type n) -{ - register size_type newsize = (alloc_inst.last - start) * 2; - register size_type datasize = end - start; - if(newsize < n) - newsize = n; - // extend newsize to WORD/DWORD boundary: - newsize = (newsize + padding_mask) & ~(padding_mask); - - // allocate and copy data: - register unsigned char* ptr = alloc_inst.allocate(newsize); - BOOST_REGEX_NOEH_ASSERT(ptr) - std::memcpy(ptr, start, datasize); - - // get rid of old buffer: - alloc_inst.deallocate(start, (alloc_inst.last - start)); - - // and set up pointers: - start = ptr; - end = ptr + datasize; - alloc_inst.last = ptr + newsize; -} - -template -void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) -{ - jm_assert(pos <= size_type(end - start)); - if(size_type(alloc_inst.last - end) < n) - resize(n + (end - start)); - register void* result = start + pos; - std::memmove(start + pos + n, start + pos, (end - start) - pos); - end += n; - return result; -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace re_detail -} // namespace boost - -#endif - - - - - - diff --git a/include/boost/regex/v3/regex_split.hpp b/include/boost/regex/v3/regex_split.hpp deleted file mode 100644 index ee94e30f..00000000 --- a/include/boost/regex/v3/regex_split.hpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_split.hpp - * VERSION see - * DESCRIPTION: Implements regex_split and associated functions. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_SPLIT_HPP -#define BOOST_REGEX_SPLIT_HPP - -namespace boost{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -namespace re_detail{ - -template -const reg_expression& get_default_expression(charT) -{ - static const charT expression_text[4] = { '\\', 's', '+', '\00', }; - static const reg_expression e(expression_text); - return e; -} - -template -class split_pred -{ - typedef std::basic_string string_type; - typedef typename string_type::const_iterator iterator_type; - iterator_type* p_last; - OutputIterator* p_out; - std::size_t* p_max; - std::size_t initial_max; -public: - split_pred(iterator_type* a, OutputIterator* b, std::size_t* c) - : p_last(a), p_out(b), p_max(c), initial_max(*c) {} - - bool operator()(const match_results& what); -}; - -template -bool split_pred::operator() - (const match_results& what) -{ - *p_last = what[0].second; - if(what.size() > 1) - { - // output sub-expressions only: - for(unsigned i = 1; i < what.size(); ++i) - { - *(*p_out) = static_cast(what[i]); - ++(*p_out); - if(0 == --*p_max) return false; - } - return *p_max != 0; - } - else - { - // output $` only if it's not-null or not at the start of the input: - const sub_match& sub = what[-1]; - if((sub.first != sub.second) || (*p_max != initial_max)) - { - *(*p_out) = static_cast(sub); - ++(*p_out); - return --*p_max; - } - } - // - // initial null, do nothing: - return true; -} - -} // namespace re_detail - -template -std::size_t regex_split(OutputIterator out, - std::basic_string& s, - const reg_expression& e, - unsigned flags, - std::size_t max_split) -{ - typedef typename std::basic_string::const_iterator ci_t; - ci_t last = s.begin(); - std::size_t init_size = max_split; - re_detail::split_pred pred(&last, &out, &max_split); - ci_t i, j; - i = s.begin(); - j = s.end(); - regex_grep(pred, i, j, e, flags); - // - // if there is still input left, do a final push as long as max_split - // is not exhausted, and we're not splitting sub-expressions rather - // than whitespace: - if(max_split && (last != s.end()) && (e.mark_count() == 1)) - { - *out = std::basic_string((ci_t)last, (ci_t)s.end()); - ++out; - last = s.end(); - --max_split; - } - // - // delete from the string everything that has been processed so far: - s.erase(0, last - s.begin()); - // - // return the number of new records pushed: - return init_size - max_split; -} - -template -inline std::size_t regex_split(OutputIterator out, - std::basic_string& s, - const reg_expression& e, - unsigned flags = match_default) -{ - return regex_split(out, s, e, flags, UINT_MAX); -} - -template -inline std::size_t regex_split(OutputIterator out, - std::basic_string& s) -{ - return regex_split(out, s, re_detail::get_default_expression(charT(0)), match_default, UINT_MAX); -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#endif - - - diff --git a/include/boost/regex/v3/regex_stack.hpp b/include/boost/regex/v3/regex_stack.hpp deleted file mode 100644 index 58e3ef1d..00000000 --- a/include/boost/regex/v3/regex_stack.hpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_stack.hpp - * VERSION see - * DESCRIPTION: Implements customised internal regex stacks. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_STACK_HPP -#define BOOST_REGEX_STACK_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif -#ifndef BOOST_REGEX_RAW_BUFFER_HPP -#include -#endif - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -// -// class jstack -// simplified stack optimised for push/peek/pop -// operations, we could use std::stack> instead... -// -template -class jstack -{ -private: - typedef typename boost::detail::rebind_allocator::type allocator_type; - typedef typename boost::detail::rebind_allocator::type T_alloc_type; - typedef typename T_alloc_type::size_type size_type; - typedef T value_type; - struct node - { - node* next; - T* start; // first item - T* end; // last item - T* last; // end of storage - }; - - // - // empty base member optimisation: - struct data : public allocator_type - { - padding buf[(sizeof(T) * 16 + sizeof(padding) - 1) / sizeof(padding)]; - data(const Allocator& a) : allocator_type(a){} - }; - - data alloc_inst; - mutable node* m_stack; - mutable node* unused; - node base; - size_type block_size; - - void BOOST_REGEX_CALL pop_aux()const; - void BOOST_REGEX_CALL push_aux(); - -public: - jstack(size_type n = 64, const Allocator& a = Allocator()); - - ~jstack(); - - node* BOOST_REGEX_CALL get_node() - { - node* new_stack = reinterpret_cast(alloc_inst.allocate(sizeof(node) + sizeof(T) * block_size)); - BOOST_REGEX_NOEH_ASSERT(new_stack) - new_stack->last = reinterpret_cast(new_stack+1); - new_stack->start = new_stack->end = new_stack->last + block_size; - new_stack->next = 0; - return new_stack; - } - - bool BOOST_REGEX_CALL empty() - { - return (m_stack->start == m_stack->end) && (m_stack->next == 0); - } - - bool BOOST_REGEX_CALL good() - { - return (m_stack->start != m_stack->end) || (m_stack->next != 0); - } - - T& BOOST_REGEX_CALL peek() - { - if(m_stack->start == m_stack->end) - pop_aux(); - return *m_stack->end; - } - - const T& BOOST_REGEX_CALL peek()const - { - if(m_stack->start == m_stack->end) - pop_aux(); - return *m_stack->end; - } - - void BOOST_REGEX_CALL pop() - { - if(m_stack->start == m_stack->end) - pop_aux(); - ::boost::re_detail::pointer_destroy(m_stack->end); - ++(m_stack->end); - } - - void BOOST_REGEX_CALL pop(T& t) - { - if(m_stack->start == m_stack->end) - pop_aux(); - t = *m_stack->end; - ::boost::re_detail::pointer_destroy(m_stack->end); - ++(m_stack->end); - } - - void BOOST_REGEX_CALL push(const T& t) - { - if(m_stack->end == m_stack->last) - push_aux(); - --(m_stack->end); - pointer_construct(m_stack->end, t); - } - -}; - -template -jstack::jstack(size_type n, const Allocator& a) - : alloc_inst(a) -{ - unused = 0; - block_size = n; - m_stack = &base; - base.last = reinterpret_cast(alloc_inst.buf); - base.end = base.start = base.last + 16; - base.next = 0; -} - -template -void BOOST_REGEX_CALL jstack::push_aux() -{ - // make sure we have spare space on TOS: - register node* new_node; - if(unused) - { - new_node = unused; - unused = new_node->next; - new_node->next = m_stack; - m_stack = new_node; - } - else - { - new_node = get_node(); - new_node->next = m_stack; - m_stack = new_node; - } -} - -template -void BOOST_REGEX_CALL jstack::pop_aux()const -{ - // make sure that we have a valid item - // on TOS: - jm_assert(m_stack->next); - register node* p = m_stack; - m_stack = p->next; - p->next = unused; - unused = p; -} - -template -jstack::~jstack() -{ - node* condemned; - while(good()) - pop(); - while(unused) - { - condemned = unused; - unused = unused->next; - alloc_inst.deallocate(reinterpret_cast(condemned), sizeof(node) + sizeof(T) * block_size); - } - while(m_stack != &base) - { - condemned = m_stack; - m_stack = m_stack->next; - alloc_inst.deallocate(reinterpret_cast(condemned), sizeof(node) + sizeof(T) * block_size); - } -} - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace re_detail -} // namespace boost - -#endif - - - - - - - - - - - diff --git a/include/boost/regex/v3/regex_synch.hpp b/include/boost/regex/v3/regex_synch.hpp deleted file mode 100644 index 3d9faafa..00000000 --- a/include/boost/regex/v3/regex_synch.hpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_synch.hpp - * VERSION see - * DESCRIPTION: Thread synchronisation for regex code. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_SYNCH_HPP -#define BOOST_REGEX_SYNCH_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#if defined(BOOST_HAS_THREADS) -# if defined(BOOST_HAS_WINTHREADS) -# include -# elif defined(BOOST_HAS_BETHREADS) -# include -# include -# elif defined(BOOST_HAS_PTHREADS) -# include -# else -# error "Unknown threading API" -# endif -#endif - - -namespace boost{ - namespace re_detail{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -void BOOST_REGEX_CALL re_init_threads(); -void BOOST_REGEX_CALL re_free_threads(); - -#ifdef BOOST_HAS_THREADS - -# ifdef BOOST_HAS_BETHREADS - -typedef sem_id CRITICAL_SECTION; - -inline void BOOST_REGEX_CALL InitializeCriticalSection(CRITICAL_SECTION* ps) -{ - *ps = create_sem(1, "regex++"); - assert(*ps > 0); -} - -inline void BOOST_REGEX_CALL DeleteCriticalSection(CRITICAL_SECTION* ps) -{ - int t = delete_sem(*ps); - assert(t == B_NO_ERROR); -} - -inline void BOOST_REGEX_CALL EnterCriticalSection(CRITICAL_SECTION* ps) -{ - status_t t = acquire_sem(*ps); - assert(t == B_NO_ERROR); -} - -inline void BOOST_REGEX_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) -{ - status_t t = release_sem(*ps); - assert(t == B_NO_ERROR); -} - -# elif defined(BOOST_HAS_PTHREADS) - -typedef pthread_mutex_t CRITICAL_SECTION; - -inline void BOOST_REGEX_CALL InitializeCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_init(ps, 0); -} - -inline void BOOST_REGEX_CALL DeleteCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_destroy(ps); -} - -inline void BOOST_REGEX_CALL EnterCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_lock(ps); -} - -inline void BOOST_REGEX_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_unlock(ps); -} - -# elif !defined(BOOST_HAS_WINTHREADS) -# error "Unknown threading API" -# endif - -template -class lock_guard -{ - typedef Lock lock_type; -public: - lock_guard(lock_type& m, bool aq = true) - : mut(m), owned(false){ acquire(aq); } - - ~lock_guard() - { acquire(false); } - - void BOOST_REGEX_CALL acquire(bool aq = true) - { - if(aq && !owned) - { - mut.acquire(true); - owned = true; - } - else if(!aq && owned) - { - mut.acquire(false); - owned = false; - } - } -private: - lock_type& mut; - bool owned; - // VC6 warning suppression: - lock_guard& operator=(const lock_guard&); -}; - - -class critical_section -{ -public: - critical_section() - { InitializeCriticalSection(&hmutex);} - - critical_section(const critical_section&) - { InitializeCriticalSection(&hmutex);} - - const critical_section& BOOST_REGEX_CALL operator=(const critical_section&) - {return *this;} - - ~critical_section() - {DeleteCriticalSection(&hmutex);} - -private: - - void BOOST_REGEX_CALL acquire(bool aq) - { if(aq) EnterCriticalSection(&hmutex); - else LeaveCriticalSection(&hmutex); - } - - CRITICAL_SECTION hmutex; - -public: - typedef lock_guard ro_guard; - typedef lock_guard rw_guard; - - friend class lock_guard; -}; - -inline bool BOOST_REGEX_CALL operator==(const critical_section&, const critical_section&) -{ - return false; -} - -inline bool BOOST_REGEX_CALL operator<(const critical_section&, const critical_section&) -{ - return true; -} - -typedef lock_guard cs_guard; - -BOOST_REGEX_DECL extern critical_section* p_re_lock; -BOOST_REGEX_DECL extern unsigned int re_lock_count; - -#define BOOST_REGEX_GUARD(inst) boost::re_detail::critical_section::rw_guard g(inst); - -#else // BOOST_HAS_THREADS - -#define BOOST_REGEX_GUARD(inst) - -#endif // BOOST_HAS_THREADS - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace re_detail -} // namespace boost - -#endif // sentry - - - - - - - diff --git a/include/boost/regex/v3/regex_traits.hpp b/include/boost/regex/v3/regex_traits.hpp deleted file mode 100644 index 8f7f3b78..00000000 --- a/include/boost/regex/v3/regex_traits.hpp +++ /dev/null @@ -1,815 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr 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 regex_traits.hpp - * VERSION see - * DESCRIPTION: Declares regular expression traits classes. - */ - -#ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED -#define BOOST_REGEX_TRAITS_HPP_INCLUDED - -#ifndef BOOST_RE_CREGEX_HPP -#include -#endif -#ifndef BOOST_REGEX_CSTRING_HPP -#include -#endif - -namespace boost{ - -#ifdef __BORLANDC__ - #pragma option push -a8 -b -Vx -Ve -pc -#endif - -template -class c_regex_traits; - -namespace re_detail{ - -struct mss -{ - unsigned int id; - const char* what; -}; - -BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name); -BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf, std::size_t len, std::size_t id); -extern BOOST_REGEX_DECL const char *re_default_error_messages[]; - -#ifndef BOOST_NO_WREGEX -extern BOOST_REGEX_DECL wchar_t wide_lower_case_map[]; -extern BOOST_REGEX_DECL unsigned short wide_unicode_classes[]; -BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(wchar_t c); -#endif - - -struct BOOST_REGEX_DECL regex_traits_base -{ - enum char_syntax_type - { - syntax_char = 0, - syntax_open_bracket = 1, // ( - syntax_close_bracket = 2, // ) - syntax_dollar = 3, // $ - syntax_caret = 4, // ^ - syntax_dot = 5, // . - syntax_star = 6, // * - syntax_plus = 7, // + - syntax_question = 8, // ? - syntax_open_set = 9, // [ - syntax_close_set = 10, // ] - syntax_or = 11, // | - syntax_slash = 12, // - syntax_hash = 13, // # - syntax_dash = 14, // - - syntax_open_brace = 15, // { - syntax_close_brace = 16, // } - syntax_digit = 17, // 0-9 - syntax_b = 18, // for \b - syntax_B = 19, // for \B - syntax_left_word = 20, // for \< - syntax_right_word = 21, // for \> - syntax_w = 22, // for \w - syntax_W = 23, // for \W - syntax_start_buffer = 24, // for \` - syntax_end_buffer = 25, // for \' - syntax_newline = 26, // for newline alt - syntax_comma = 27, // for {x,y} - - syntax_a = 28, // for \a - syntax_f = 29, // for \f - syntax_n = 30, // for \n - syntax_r = 31, // for \r - syntax_t = 32, // for \t - syntax_v = 33, // for \v - syntax_x = 34, // for \xdd - syntax_c = 35, // for \cx - syntax_colon = 36, // for [:...:] - syntax_equal = 37, // for [=...=] - - // perl ops: - syntax_e = 38, // for \e - syntax_l = 39, // for \l - syntax_L = 40, // for \L - syntax_u = 41, // for \u - syntax_U = 42, // for \U - syntax_s = 43, // for \s - syntax_S = 44, // for \S - syntax_d = 45, // for \d - syntax_D = 46, // for \D - syntax_E = 47, // for \Q\E - syntax_Q = 48, // for \Q\E - syntax_X = 49, // for \X - syntax_C = 50, // for \C - syntax_Z = 51, // for \Z - syntax_G = 52, // for \G - - // new extentions: - syntax_not = 53, // for (?!...) - - syntax_max = 54 - }; -#ifdef __BORLANDC__ -private: - char dummy_member; -#endif -}; - -struct BOOST_REGEX_DECL c_traits_base : public regex_traits_base -{ -public: - enum{ - char_class_none = 0, - char_class_alpha = 0x0001, - char_class_cntrl = 0x0002, - char_class_digit = 0x0004, - char_class_lower = 0x0008, - char_class_punct = 0x0010, - char_class_space = 0x0020, - char_class_upper = 0x0040, - char_class_xdigit = 0x0080, - char_class_blank = 0x0100, - char_class_underscore = 0x4000, - char_class_unicode = 0x8000, - - char_class_alnum = char_class_alpha | char_class_digit, - char_class_graph = char_class_alpha | char_class_digit | char_class_punct | char_class_underscore, - char_class_print = char_class_alpha | char_class_digit | char_class_punct | char_class_underscore | char_class_blank, - char_class_word = char_class_alpha | char_class_digit | char_class_underscore - }; - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: -#if defined(__MWERKS__) && __MWERKS__ <= 0x6000 - friend class c_regex_traits; - friend class c_regex_traits; -#endif - - static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; - enum syntax_map_size - { - map_size = UCHAR_MAX + 1 - }; - - static unsigned char syntax_map[map_size]; - static unsigned short class_map[map_size]; - static char lower_case_map[map_size]; - - static boost::uint_fast32_t BOOST_REGEX_CALL do_lookup_class(const char* p); - static bool BOOST_REGEX_CALL do_lookup_collate(std::string& buf, const char* p); - static void BOOST_REGEX_CALL do_update_ctype(); - static void BOOST_REGEX_CALL do_update_collate(); -public: - static std::string BOOST_REGEX_CALL error_string(unsigned id); - static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; } -}; - -} // namespace re_detail - - -template<> -class BOOST_REGEX_DECL c_regex_traits : public re_detail::c_traits_base -{ - typedef re_detail::c_traits_base base_type; -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef int locale_type; - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return syntax_map[c]; - } - static char BOOST_REGEX_CALL translate(char c, bool icase) - { - return icase ? lower_case_map[(size_type)(uchar_type)c] : c; - } - static void BOOST_REGEX_CALL transform(std::string& out, const std::string& in); - - static void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in); - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - static bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(class_map[(size_type)(uchar_type)c] & f); - } - - static int BOOST_REGEX_CALL toi(char c); - static int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_class(s.c_str()); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::string& buf, const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_collate(buf, s.c_str()); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - c_regex_traits() - { - init(); - } - ~c_regex_traits() - { - m_free(); - } - struct sentry - { - sentry(const c_regex_traits&) - { c_regex_traits::update(); } - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); -private: - static void BOOST_REGEX_CALL init(); - static void BOOST_REGEX_CALL m_free(); - static c_regex_traits i; - - static unsigned sort_type; - static char sort_delim; -}; - -#ifndef BOOST_NO_WREGEX -template<> -class BOOST_REGEX_DECL c_regex_traits : public re_detail::c_traits_base -{ - typedef re_detail::c_traits_base base_type; -public: - typedef wchar_t char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c); - static wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool icase) - { - return icase ? ((c < 256) ? re_detail::wide_lower_case_map[(uchar_type)c] : std::towlower(c)) : c; - } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in); - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in); - - static bool BOOST_REGEX_CALL is_separator(wchar_t c) - { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (wchar_t)0x2028) || (c == (wchar_t)0x2029)); - } - - static bool BOOST_REGEX_CALL is_combining(wchar_t c) - { return re_detail::is_combining(c); } - - static bool BOOST_REGEX_CALL is_class(wchar_t c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(((uchar_type)c < 256) ? (re_detail::wide_unicode_classes[(size_type)(uchar_type)c] & f) : do_iswclass(c, f)); - } - - static int BOOST_REGEX_CALL toi(wchar_t c); - static int BOOST_REGEX_CALL toi(const wchar_t*& first, const wchar_t* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last); - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const wchar_t* first, const wchar_t* last); - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - c_regex_traits() - { init(); } - ~c_regex_traits() - { m_free(); } - struct sentry - { - sentry(const c_regex_traits&) - { c_regex_traits::update(); } - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const wchar_t *s2); - static std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2); -private: - static bool BOOST_REGEX_CALL do_iswclass(wchar_t c, boost::uint_fast32_t f); - static void BOOST_REGEX_CALL m_free(); - static void BOOST_REGEX_CALL init(); - static bool BOOST_REGEX_CALL do_lookup_collate(std::basic_string& out, const wchar_t* first, const wchar_t* last); - static c_regex_traits init_; - - static unsigned sort_type; - static wchar_t sort_delim; -}; -#endif - -#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) - -namespace re_detail{ - -struct BOOST_REGEX_DECL w32_traits_base : public regex_traits_base -{ - enum{ - char_class_none = 0, - char_class_alnum = C1_ALPHA | C1_DIGIT, - char_class_alpha = C1_ALPHA, - char_class_cntrl = C1_CNTRL, - char_class_digit = C1_DIGIT, - char_class_graph = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA, - char_class_lower = C1_LOWER, - char_class_print = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_BLANK | C1_ALPHA, - char_class_punct = C1_PUNCT, - char_class_space = C1_SPACE, - char_class_upper = C1_UPPER, - char_class_xdigit = C1_XDIGIT, - char_class_blank = C1_BLANK, - char_class_underscore = 0x4000, - char_class_word = C1_ALPHA | C1_DIGIT | char_class_underscore, - char_class_unicode = 0x8000, - char_class_win = 0x01FF - }; - - -public: - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: - static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; - enum syntax_map_size - { - map_size = UCHAR_MAX + 1 - }; - - static unsigned char syntax_map[map_size]; - static unsigned short class_map[map_size]; - static char lower_case_map[map_size]; - - static boost::uint_fast32_t BOOST_REGEX_CALL do_lookup_class(const char* p); - static bool BOOST_REGEX_CALL do_lookup_collate(std::string& buf, const char* p); - static void BOOST_REGEX_CALL do_free(); - static void BOOST_REGEX_CALL do_init(); -public: - static std::string BOOST_REGEX_CALL error_string(unsigned id); - static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; } -}; - - -} // namespace re_detail - -template -class w32_regex_traits; - -template<> -class BOOST_REGEX_DECL w32_regex_traits : public re_detail::w32_traits_base -{ - typedef re_detail::w32_traits_base base_type; -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef int locale_type; - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return syntax_map[c]; - } - static char BOOST_REGEX_CALL translate(char c, bool icase) - { - return icase ? lower_case_map[(size_type)(uchar_type)c] : c; - } - static void BOOST_REGEX_CALL transform(std::string& out, const std::string& in); - - static void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in); - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - static bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(class_map[(size_type)(uchar_type)c] & f); - } - - static int BOOST_REGEX_CALL toi(char c); - static int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_class(s.c_str()); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::string& buf, const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_collate(buf, s.c_str()); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const w32_regex_traits&) - { w32_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - w32_regex_traits(); - ~w32_regex_traits(); -private: - static w32_regex_traits i; -}; - -#ifndef BOOST_NO_WREGEX -template<> -class BOOST_REGEX_DECL w32_regex_traits : public re_detail::w32_traits_base -{ - typedef re_detail::w32_traits_base base_type; -public: - typedef wchar_t char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c); - static wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool icase) - { - return icase ? ((c < 256) ? re_detail::wide_lower_case_map[(uchar_type)c] : wtolower(c)) : c; - } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in); - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in); - - static bool BOOST_REGEX_CALL is_separator(wchar_t c) - { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (wchar_t)0x2028) || (c == (wchar_t)0x2029)); - } - - static bool BOOST_REGEX_CALL is_combining(wchar_t c) - { return re_detail::is_combining(c); } - - static bool BOOST_REGEX_CALL is_class(wchar_t c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(((uchar_type)c < 256) ? (wide_unicode_classes[(size_type)(uchar_type)c] & f) : do_iswclass(c, f)); - } - - static int BOOST_REGEX_CALL toi(wchar_t c); - static int BOOST_REGEX_CALL toi(const wchar_t*& first, const wchar_t* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last); - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const wchar_t* first, const wchar_t* last); - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const w32_regex_traits&) - { w32_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - w32_regex_traits(); - ~w32_regex_traits(); - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const wchar_t *s2); - static std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2); - -private: - static bool BOOST_REGEX_CALL do_iswclass(wchar_t c, boost::uint_fast32_t f); - static bool BOOST_REGEX_CALL do_lookup_collate(std::basic_string& out, const wchar_t* first, const wchar_t* last); - static w32_regex_traits init_; - static wchar_t BOOST_REGEX_CALL wtolower(wchar_t c); - static unsigned short wide_unicode_classes[]; -}; -#endif // Wide strings -#endif // Win32 - -#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_WSTREAMBUF) - -} // namspace boost - -#ifdef __BORLANDC__ - #pragma option pop -#endif -#include -#ifdef __BORLANDC__ - #pragma option push -a4 -b -Ve -pc -#endif - -namespace boost{ - -namespace re_detail -{ - -template -struct message_data; - -template <> -struct message_data; - -template <> -struct message_data; - -struct BOOST_REGEX_DECL cpp_regex_traits_base : public regex_traits_base -{ - enum char_class_type - { - char_class_none = 0, - char_class_alnum = std::ctype_base::alnum, - char_class_alpha = std::ctype_base::alpha, - char_class_cntrl = std::ctype_base::cntrl, - char_class_digit = std::ctype_base::digit, - char_class_graph = std::ctype_base::graph, - char_class_lower = std::ctype_base::lower, - char_class_print = std::ctype_base::print, - char_class_punct = std::ctype_base::punct, - char_class_space = std::ctype_base::space, - char_class_upper = std::ctype_base::upper, - char_class_xdigit = std::ctype_base::xdigit, - char_class_blank = 1<<12, - char_class_underscore = 1<<13, - char_class_word = std::ctype_base::alnum | char_class_underscore, - char_class_unicode = 1<<14, - char_class_all_base = char_class_alnum | char_class_alpha | char_class_cntrl - | char_class_digit | char_class_graph | char_class_lower - | char_class_print | char_class_punct | char_class_space - | char_class_upper | char_class_xdigit - }; - - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: - static char regex_message_cat[BOOST_REGEX_MAX_PATH]; -}; - -} // namespace re_detail - -template -class cpp_regex_traits; - -template<> -class BOOST_REGEX_DECL cpp_regex_traits : public re_detail::cpp_regex_traits_base -{ - typedef re_detail::cpp_regex_traits_base base_type; -private: - re_detail::message_data* pmd; - const unsigned char* psyntax; - char* lower_map; - const std::ctype* pctype; - const std::collate* pcollate; - std::locale locale_inst; - unsigned sort_type; - char sort_delim; - - cpp_regex_traits(const cpp_regex_traits&); - cpp_regex_traits& operator=(const cpp_regex_traits&); - -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef std::locale locale_type; - - cpp_regex_traits(); - ~cpp_regex_traits(); - - void swap(cpp_regex_traits&); - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - unsigned int BOOST_REGEX_CALL syntax_type(size_type c)const - { - return psyntax[c]; - } - char BOOST_REGEX_CALL translate(char c, bool icase)const - { - return icase ? lower_map[(size_type)(uchar_type)c] : c; - } - void BOOST_REGEX_CALL transform(std::string& out, const std::string& in)const - { - out = pcollate->transform(in.c_str(), in.c_str() + in.size()).c_str(); - } - - void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in)const; - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f)const - { - if(pctype->is((std::ctype::mask)(f & char_class_all_base), c)) - return true; - if((f & char_class_underscore) && (c == '_')) - return true; - if((f & char_class_blank) && ((c == ' ') || (c == '\t'))) - return true; - return false; - } - - int BOOST_REGEX_CALL toi(char c)const; - int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix)const; - - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last)const; - bool BOOST_REGEX_CALL lookup_collatename(std::string& s, const char* first, const char* last)const; - - std::string BOOST_REGEX_CALL error_string(unsigned id)const; - locale_type BOOST_REGEX_CALL imbue(locale_type l); - locale_type BOOST_REGEX_CALL getloc()const{ return locale_inst; } - - struct sentry - { - sentry(const cpp_regex_traits&){} - operator void*() { return this; } - }; -}; - -#ifndef BOOST_NO_WREGEX -template<> -class BOOST_REGEX_DECL cpp_regex_traits : public re_detail::cpp_regex_traits_base -{ - typedef re_detail::cpp_regex_traits_base base_type; -public: - typedef wchar_t char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef std::locale locale_type; - -private: - re_detail::message_data* pmd; - const unsigned char* psyntax; - wchar_t* lower_map; - const std::ctype* pctype; - const std::collate* pcollate; - const std::codecvt* pcdv; - std::locale locale_inst; - unsigned int BOOST_REGEX_CALL do_syntax_type(size_type c)const; - unsigned sort_type; - wchar_t sort_delim; - - cpp_regex_traits(const cpp_regex_traits&); - cpp_regex_traits& operator=(const cpp_regex_traits&); - -public: - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } - unsigned int BOOST_REGEX_CALL syntax_type(size_type c)const - { - return (c < UCHAR_MAX) ? psyntax[c] : do_syntax_type(c); - } - wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool icase)const - { - return icase ? (((uchar_type)c) <= UCHAR_MAX) ? lower_map[c] : pctype->tolower(c) : c; - } - void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in)const - { - out = pcollate->transform(in.c_str(), in.c_str() + in.size()); - } - - void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in)const; - - static bool BOOST_REGEX_CALL is_separator(wchar_t c) - { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (wchar_t)0x2028) || (c == (wchar_t)0x2029)); - } - - static bool BOOST_REGEX_CALL is_combining(wchar_t c) - { return re_detail::is_combining(c); } - - bool BOOST_REGEX_CALL is_class(wchar_t c, boost::uint_fast32_t f)const - { - if(pctype->is((std::ctype::mask)(f & char_class_all_base), c)) - return true; - if((f & char_class_underscore) && (c == '_')) - return true; - if((f & char_class_blank) && ((c == ' ') || (c == '\t'))) - return true; - if((f & char_class_unicode) && ((uchar_type)c > (uchar_type)255)) - return true; - return false; - } - - int BOOST_REGEX_CALL toi(wchar_t c)const; - int BOOST_REGEX_CALL toi(const wchar_t*& first, const wchar_t* last, int radix)const; - - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const; - bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const wchar_t* first, const wchar_t* last)const; - - std::string BOOST_REGEX_CALL error_string(unsigned id)const; - cpp_regex_traits(); - ~cpp_regex_traits(); - locale_type BOOST_REGEX_CALL imbue(locale_type l); - locale_type BOOST_REGEX_CALL getloc()const{ return locale_inst; } - std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2)const; - void swap(cpp_regex_traits&); - - struct sentry - { - sentry(const cpp_regex_traits&){} - operator void*() { return this; } - }; -}; -#endif // BOOST_NO_WREGEX - -#endif // BOOST_NO_STD_LOCALE - -#ifdef BOOST_REGEX_USE_WIN32_LOCALE - -template -class regex_traits : public w32_regex_traits -{ -}; - -#elif defined(BOOST_REGEX_USE_C_LOCALE) - -template -class regex_traits : public c_regex_traits -{ -}; - -#elif defined(BOOST_REGEX_USE_CPP_LOCALE) - -template -class regex_traits : public cpp_regex_traits -{ -}; - -#else -#error No default localisation model defined -#endif - -#ifdef __BORLANDC__ - #pragma option pop -#endif - -} // namespace boost - -#endif // include - - - - - - -