mirror of
https://github.com/boostorg/regex.git
synced 2025-07-17 06:12:10 +02:00
merged changes in regex5 branch
[SVN r26692]
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,559 +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: c_regex_traits_common.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Implements common code and data for the
|
||||
* c_regex_traits<charT> traits classes.
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <clocale>
|
||||
#include <cstdio>
|
||||
#include <list>
|
||||
#include <cctype>
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
//
|
||||
// these are the POSIX collating names:
|
||||
//
|
||||
BOOST_REGEX_DECL const char* def_coll_names[] = {
|
||||
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
|
||||
"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
|
||||
"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
|
||||
"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
|
||||
"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
|
||||
"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
|
||||
"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
|
||||
"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
|
||||
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
|
||||
"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
|
||||
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
|
||||
"vertical-line", "right-curly-bracket", "tilde", "DEL", "",
|
||||
};
|
||||
|
||||
// these multi-character collating elements
|
||||
// should keep most Western-European locales
|
||||
// happy - we should really localise these a
|
||||
// little more - but this will have to do for
|
||||
// now:
|
||||
|
||||
BOOST_REGEX_DECL const char* def_multi_coll[] = {
|
||||
"ae",
|
||||
"Ae",
|
||||
"AE",
|
||||
"ch",
|
||||
"Ch",
|
||||
"CH",
|
||||
"ll",
|
||||
"Ll",
|
||||
"LL",
|
||||
"ss",
|
||||
"Ss",
|
||||
"SS",
|
||||
"nj",
|
||||
"Nj",
|
||||
"NJ",
|
||||
"dz",
|
||||
"Dz",
|
||||
"DZ",
|
||||
"lj",
|
||||
"Lj",
|
||||
"LJ",
|
||||
"",
|
||||
};
|
||||
|
||||
|
||||
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int i = 0;
|
||||
while(*def_coll_names[i])
|
||||
{
|
||||
if(std::strcmp(def_coll_names[i], name) == 0)
|
||||
{
|
||||
buf = (char)i;
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
i = 0;
|
||||
while(*def_multi_coll[i])
|
||||
{
|
||||
if(std::strcmp(def_multi_coll[i], name) == 0)
|
||||
{
|
||||
buf = def_multi_coll[i];
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// messages:
|
||||
BOOST_REGEX_DECL const char * re_default_error_messages[] =
|
||||
{ "Success", /* REG_NOERROR */
|
||||
"No match", /* REG_NOMATCH */
|
||||
"Invalid regular expression", /* REG_BADPAT */
|
||||
"Invalid collation character", /* REG_ECOLLATE */
|
||||
"Invalid character class name", /* REG_ECTYPE */
|
||||
"Trailing backslash", /* REG_EESCAPE */
|
||||
"Invalid back reference", /* REG_ESUBREG */
|
||||
"Unmatched [ or [^", /* REG_EBRACK */
|
||||
"Unmatched ( or \\(", /* REG_EPAREN */
|
||||
"Unmatched \\{", /* REG_EBRACE */
|
||||
"Invalid content of \\{\\}", /* REG_BADBR */
|
||||
"Invalid range end", /* REG_ERANGE */
|
||||
"Memory exhausted", /* REG_ESPACE */
|
||||
"Invalid preceding regular expression", /* REG_BADRPT */
|
||||
"Premature end of regular expression", /* REG_EEND */
|
||||
"Regular expression too big", /* REG_ESIZE */
|
||||
"Unmatched ) or \\)", /* REG_ERPAREN */
|
||||
"Empty expression", /* REG_EMPTY */
|
||||
"Unknown error", /* REG_E_UNKNOWN */
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
const mss default_messages[] = {
|
||||
{ 100+ c_regex_traits<char>::syntax_open_bracket, "(", },
|
||||
{ 100+ c_regex_traits<char>::syntax_close_bracket, ")", },
|
||||
{ 100+ c_regex_traits<char>::syntax_dollar, "$", },
|
||||
{ 100+ c_regex_traits<char>::syntax_caret, "^", },
|
||||
{ 100+ c_regex_traits<char>::syntax_dot, ".", },
|
||||
{ 100+ c_regex_traits<char>::syntax_star, "*", },
|
||||
{ 100+ c_regex_traits<char>::syntax_plus, "+", },
|
||||
{ 100+ c_regex_traits<char>::syntax_question, "?", },
|
||||
{ 100+ c_regex_traits<char>::syntax_open_set, "[", },
|
||||
{ 100+ c_regex_traits<char>::syntax_close_set, "]", },
|
||||
{ 100+ c_regex_traits<char>::syntax_or, "|", },
|
||||
{ 100+ c_regex_traits<char>::syntax_slash, "\\", },
|
||||
{ 100+ c_regex_traits<char>::syntax_hash, "#", },
|
||||
{ 100+ c_regex_traits<char>::syntax_dash, "-", },
|
||||
{ 100+ c_regex_traits<char>::syntax_open_brace, "{", },
|
||||
{ 100+ c_regex_traits<char>::syntax_close_brace, "}", },
|
||||
{ 100+ c_regex_traits<char>::syntax_digit, "0123456789", },
|
||||
{ 100+ c_regex_traits<char>::syntax_b, "b", },
|
||||
{ 100+ c_regex_traits<char>::syntax_B, "B", },
|
||||
{ 100+ c_regex_traits<char>::syntax_left_word, "<", },
|
||||
{ 100+ c_regex_traits<char>::syntax_right_word, ">", },
|
||||
{ 100+ c_regex_traits<char>::syntax_w, "w", },
|
||||
{ 100+ c_regex_traits<char>::syntax_W, "W", },
|
||||
{ 100+ c_regex_traits<char>::syntax_start_buffer, "`A", },
|
||||
{ 100+ c_regex_traits<char>::syntax_end_buffer, "'z", },
|
||||
{ 100+ c_regex_traits<char>::syntax_newline, "\n", },
|
||||
{ 100+ c_regex_traits<char>::syntax_comma, ",", },
|
||||
{ 100+ c_regex_traits<char>::syntax_a, "a", },
|
||||
{ 100+ c_regex_traits<char>::syntax_f, "f", },
|
||||
{ 100+ c_regex_traits<char>::syntax_n, "n", },
|
||||
{ 100+ c_regex_traits<char>::syntax_r, "r", },
|
||||
{ 100+ c_regex_traits<char>::syntax_t, "t", },
|
||||
{ 100+ c_regex_traits<char>::syntax_v, "v", },
|
||||
{ 100+ c_regex_traits<char>::syntax_x, "x", },
|
||||
{ 100+ c_regex_traits<char>::syntax_c, "c", },
|
||||
{ 100+ c_regex_traits<char>::syntax_colon, ":", },
|
||||
{ 100+ c_regex_traits<char>::syntax_equal, "=", },
|
||||
|
||||
{ 100 + c_regex_traits<char>::syntax_e, "e", },
|
||||
{ 100 + c_regex_traits<char>::syntax_l, "l", },
|
||||
{ 100 + c_regex_traits<char>::syntax_L, "L", },
|
||||
{ 100 + c_regex_traits<char>::syntax_u, "u", },
|
||||
{ 100 + c_regex_traits<char>::syntax_U, "U", },
|
||||
{ 100 + c_regex_traits<char>::syntax_s, "s", },
|
||||
{ 100 + c_regex_traits<char>::syntax_S, "S", },
|
||||
{ 100 + c_regex_traits<char>::syntax_d, "d", },
|
||||
{ 100 + c_regex_traits<char>::syntax_D, "D", },
|
||||
{ 100 + c_regex_traits<char>::syntax_E, "E", },
|
||||
{ 100 + c_regex_traits<char>::syntax_Q, "Q", },
|
||||
{ 100 + c_regex_traits<char>::syntax_X, "X", },
|
||||
{ 100 + c_regex_traits<char>::syntax_C, "C", },
|
||||
{ 100 + c_regex_traits<char>::syntax_Z, "Z", },
|
||||
{ 100 + c_regex_traits<char>::syntax_G, "G", },
|
||||
|
||||
{ 100 + c_regex_traits<char>::syntax_not, "!", },
|
||||
|
||||
{ 0, "", },
|
||||
};
|
||||
|
||||
BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf, std::size_t len, std::size_t id)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
const mss* pm = default_messages;
|
||||
while(pm->id)
|
||||
{
|
||||
if(pm->id == id)
|
||||
{
|
||||
std::size_t size = re_strlen(pm->what) + 1;
|
||||
if(size > len)
|
||||
return size;
|
||||
re_strcpy(buf, pm->what);
|
||||
return size;
|
||||
}
|
||||
++pm;
|
||||
}
|
||||
if(buf && len)
|
||||
*buf = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
const regex_wchar_type combining_ranges[] = { 0x0300, 0x0361,
|
||||
0x0483, 0x0486,
|
||||
0x0903, 0x0903,
|
||||
0x093E, 0x0940,
|
||||
0x0949, 0x094C,
|
||||
0x0982, 0x0983,
|
||||
0x09BE, 0x09C0,
|
||||
0x09C7, 0x09CC,
|
||||
0x09D7, 0x09D7,
|
||||
0x0A3E, 0x0A40,
|
||||
0x0A83, 0x0A83,
|
||||
0x0ABE, 0x0AC0,
|
||||
0x0AC9, 0x0ACC,
|
||||
0x0B02, 0x0B03,
|
||||
0x0B3E, 0x0B3E,
|
||||
0x0B40, 0x0B40,
|
||||
0x0B47, 0x0B4C,
|
||||
0x0B57, 0x0B57,
|
||||
0x0B83, 0x0B83,
|
||||
0x0BBE, 0x0BBF,
|
||||
0x0BC1, 0x0BCC,
|
||||
0x0BD7, 0x0BD7,
|
||||
0x0C01, 0x0C03,
|
||||
0x0C41, 0x0C44,
|
||||
0x0C82, 0x0C83,
|
||||
0x0CBE, 0x0CBE,
|
||||
0x0CC0, 0x0CC4,
|
||||
0x0CC7, 0x0CCB,
|
||||
0x0CD5, 0x0CD6,
|
||||
0x0D02, 0x0D03,
|
||||
0x0D3E, 0x0D40,
|
||||
0x0D46, 0x0D4C,
|
||||
0x0D57, 0x0D57,
|
||||
0x0F7F, 0x0F7F,
|
||||
0x20D0, 0x20E1,
|
||||
0x3099, 0x309A,
|
||||
0xFE20, 0xFE23,
|
||||
0xffff, 0xffff, };
|
||||
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(regex_wchar_type c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
const regex_wchar_type* p = combining_ranges + 1;
|
||||
while(*p < c) p += 2;
|
||||
--p;
|
||||
if((c >= *p) && (c <= *(p+1)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL unsigned short wide_unicode_classes[] = {
|
||||
c_traits_base::char_class_cntrl, // '' 0
|
||||
c_traits_base::char_class_cntrl, // '' 1
|
||||
c_traits_base::char_class_cntrl, // '' 2
|
||||
c_traits_base::char_class_cntrl, // '' 3
|
||||
c_traits_base::char_class_cntrl, // '' 4
|
||||
c_traits_base::char_class_cntrl, // '' 5
|
||||
c_traits_base::char_class_cntrl, // '' 6
|
||||
c_traits_base::char_class_cntrl, // '' 7
|
||||
c_traits_base::char_class_cntrl, // '' 8
|
||||
c_traits_base::char_class_cntrl | c_traits_base::char_class_space | c_traits_base::char_class_blank, // '' 9
|
||||
c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 10
|
||||
c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 11
|
||||
c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 12
|
||||
c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 13
|
||||
c_traits_base::char_class_cntrl, // '.' 14
|
||||
c_traits_base::char_class_cntrl, // '.' 15
|
||||
c_traits_base::char_class_cntrl, // '.' 16
|
||||
c_traits_base::char_class_cntrl, // '.' 17
|
||||
c_traits_base::char_class_cntrl, // '.' 18
|
||||
c_traits_base::char_class_cntrl, // '.' 19
|
||||
c_traits_base::char_class_cntrl, // '.' 20
|
||||
c_traits_base::char_class_cntrl, // '.' 21
|
||||
c_traits_base::char_class_cntrl, // '.' 22
|
||||
c_traits_base::char_class_cntrl, // '.' 23
|
||||
c_traits_base::char_class_cntrl, // '.' 24
|
||||
c_traits_base::char_class_cntrl, // '' 25
|
||||
c_traits_base::char_class_cntrl, // '' 26
|
||||
c_traits_base::char_class_cntrl, // '' 27
|
||||
c_traits_base::char_class_cntrl, // '.' 28
|
||||
c_traits_base::char_class_cntrl, // '.' 29
|
||||
c_traits_base::char_class_cntrl, // '.' 30
|
||||
c_traits_base::char_class_cntrl, // '.' 31
|
||||
c_traits_base::char_class_space | c_traits_base::char_class_blank, // ' ' 32
|
||||
c_traits_base::char_class_punct, // '!' 33
|
||||
c_traits_base::char_class_punct, // '"' 34
|
||||
c_traits_base::char_class_punct, // '#' 35
|
||||
c_traits_base::char_class_punct, // '$' 36
|
||||
c_traits_base::char_class_punct, // '%' 37
|
||||
c_traits_base::char_class_punct, // '&' 38
|
||||
c_traits_base::char_class_punct, // ''' 39
|
||||
c_traits_base::char_class_punct, // '(' 40
|
||||
c_traits_base::char_class_punct, // ')' 41
|
||||
c_traits_base::char_class_punct, // '*' 42
|
||||
c_traits_base::char_class_punct, // '+' 43
|
||||
c_traits_base::char_class_punct, // ',' 44
|
||||
c_traits_base::char_class_punct, // '-' 45
|
||||
c_traits_base::char_class_punct, // '.' 46
|
||||
c_traits_base::char_class_punct, // '/' 47
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '0' 48
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '1' 49
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '2' 50
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '3' 51
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '4' 52
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '5' 53
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '6' 54
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '7' 55
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '8' 56
|
||||
c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '9' 57
|
||||
c_traits_base::char_class_punct, // ':' 58
|
||||
c_traits_base::char_class_punct, // ';' 59
|
||||
c_traits_base::char_class_punct, // '<' 60
|
||||
c_traits_base::char_class_punct, // '=' 61
|
||||
c_traits_base::char_class_punct, // '>' 62
|
||||
c_traits_base::char_class_punct, // '?' 63
|
||||
c_traits_base::char_class_punct, // '@' 64
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'A' 65
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'B' 66
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'C' 67
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'D' 68
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'E' 69
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'F' 70
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'G' 71
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'H' 72
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'I' 73
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'J' 74
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'K' 75
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'L' 76
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'M' 77
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'N' 78
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'O' 79
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'P' 80
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Q' 81
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'R' 82
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'S' 83
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'T' 84
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'U' 85
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'V' 86
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'W' 87
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'X' 88
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Y' 89
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Z' 90
|
||||
c_traits_base::char_class_punct, // '[' 91
|
||||
c_traits_base::char_class_punct, // '\' 92
|
||||
c_traits_base::char_class_punct, // ']' 93
|
||||
c_traits_base::char_class_punct, // '^' 94
|
||||
c_traits_base::char_class_punct | c_traits_base::char_class_underscore, // '_' 95
|
||||
c_traits_base::char_class_punct, // '`' 96
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'a' 97
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'b' 98
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'c' 99
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'd' 100
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'e' 101
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'f' 102
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'g' 103
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'h' 104
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'i' 105
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'j' 106
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'k' 107
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'l' 108
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'm' 109
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'n' 110
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'o' 111
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'p' 112
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'q' 113
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'r' 114
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 's' 115
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 't' 116
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'u' 117
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'v' 118
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'w' 119
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'x' 120
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'y' 121
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'z' 122
|
||||
c_traits_base::char_class_punct, // '{' 123
|
||||
c_traits_base::char_class_punct, // '|' 124
|
||||
c_traits_base::char_class_punct, // '}' 125
|
||||
c_traits_base::char_class_punct, // '~' 126
|
||||
|
||||
c_traits_base::char_class_cntrl, // '' 127
|
||||
c_traits_base::char_class_cntrl, // '<27>' 128
|
||||
c_traits_base::char_class_cntrl, // '<27>' 129
|
||||
c_traits_base::char_class_cntrl, // '<27>' 130
|
||||
c_traits_base::char_class_cntrl, // '<27>' 131
|
||||
c_traits_base::char_class_cntrl, // '<27>' 132
|
||||
c_traits_base::char_class_cntrl, // '<27>' 133
|
||||
c_traits_base::char_class_cntrl, // '<27>' 134
|
||||
c_traits_base::char_class_cntrl, // '<27>' 135
|
||||
c_traits_base::char_class_cntrl, // '<27>' 136
|
||||
c_traits_base::char_class_cntrl, // '<27>' 137
|
||||
c_traits_base::char_class_cntrl, // '<27>' 138
|
||||
c_traits_base::char_class_cntrl, // '<27>' 139
|
||||
c_traits_base::char_class_cntrl, // '<27>' 140
|
||||
c_traits_base::char_class_cntrl, // '<27>' 141
|
||||
c_traits_base::char_class_cntrl, // '<27>' 142
|
||||
c_traits_base::char_class_cntrl, // '<27>' 143
|
||||
c_traits_base::char_class_cntrl, // '<27>' 144
|
||||
c_traits_base::char_class_cntrl, // '<27>' 145
|
||||
c_traits_base::char_class_cntrl, // '<27>' 146
|
||||
c_traits_base::char_class_cntrl, // '<27>' 147
|
||||
c_traits_base::char_class_cntrl, // '<27>' 148
|
||||
c_traits_base::char_class_cntrl, // '<27>' 149
|
||||
c_traits_base::char_class_cntrl, // '<27>' 150
|
||||
c_traits_base::char_class_cntrl, // '<27>' 151
|
||||
c_traits_base::char_class_cntrl, // '<27>' 152
|
||||
c_traits_base::char_class_cntrl, // '<27>' 153
|
||||
c_traits_base::char_class_cntrl, // '<27>' 154
|
||||
c_traits_base::char_class_cntrl, // '<27>' 155
|
||||
c_traits_base::char_class_cntrl, // '<27>' 156
|
||||
c_traits_base::char_class_cntrl, // '<27>' 157
|
||||
c_traits_base::char_class_cntrl, // '<27>' 158
|
||||
c_traits_base::char_class_cntrl, // '<27>' 159
|
||||
c_traits_base::char_class_space | c_traits_base::char_class_blank, // '<27>' 160
|
||||
c_traits_base::char_class_punct, // '<27>' 161
|
||||
c_traits_base::char_class_punct, // '<27>' 162
|
||||
c_traits_base::char_class_punct, // '<27>' 163
|
||||
c_traits_base::char_class_punct, // '<27>' 164
|
||||
c_traits_base::char_class_punct, // '<27>' 165
|
||||
c_traits_base::char_class_punct, // '<27>' 166
|
||||
c_traits_base::char_class_punct, // '<27>' 167
|
||||
c_traits_base::char_class_punct, // '<27>' 168
|
||||
c_traits_base::char_class_punct, // '<27>' 169
|
||||
c_traits_base::char_class_punct, // '<27>' 170
|
||||
c_traits_base::char_class_punct, // '<27>' 171
|
||||
c_traits_base::char_class_punct, // '<27>' 172
|
||||
c_traits_base::char_class_punct, // '<27>' 173
|
||||
c_traits_base::char_class_punct, // '<27>' 174
|
||||
c_traits_base::char_class_punct, // '<27>' 175
|
||||
c_traits_base::char_class_punct, // '<27>' 176
|
||||
c_traits_base::char_class_punct, // '<27>' 177
|
||||
c_traits_base::char_class_punct, // '<27>' 178
|
||||
c_traits_base::char_class_punct, // '<27>' 179
|
||||
c_traits_base::char_class_punct, // '<27>' 180
|
||||
c_traits_base::char_class_punct, // '<27>' 181
|
||||
c_traits_base::char_class_punct, // '<27>' 182
|
||||
c_traits_base::char_class_punct, // '<27>' 183
|
||||
c_traits_base::char_class_punct, // '<27>' 184
|
||||
c_traits_base::char_class_punct, // '<27>' 185
|
||||
c_traits_base::char_class_punct, // '<27>' 186
|
||||
c_traits_base::char_class_punct, // '<27>' 187
|
||||
c_traits_base::char_class_punct, // '<27>' 188
|
||||
c_traits_base::char_class_punct, // '<27>' 189
|
||||
c_traits_base::char_class_punct, // '<27>' 190
|
||||
c_traits_base::char_class_punct, // '<27>' 191
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 192
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 193
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 194
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 195
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 196
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 197
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 198
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 199
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 200
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 201
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 202
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 203
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 204
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 205
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 206
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 207
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 208
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 209
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 210
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 211
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 212
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 213
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 214
|
||||
c_traits_base::char_class_punct, // '<27>' 215
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 216
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 217
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 218
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 219
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 220
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 221
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '<27>' 222
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 223
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 224
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 225
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 226
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 227
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 228
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 229
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 230
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 231
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 232
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 233
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 234
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 235
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 236
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 237
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 238
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 239
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 240
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 241
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 242
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 243
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 244
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 245
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 246
|
||||
c_traits_base::char_class_punct, // '<27>' 247
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 248
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 249
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 250
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 251
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 252
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 253
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 254
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 255
|
||||
};
|
||||
|
||||
BOOST_REGEX_DECL regex_wchar_type wide_lower_case_map[] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
};
|
||||
#endif // BOOST_NO_WREGEX
|
||||
|
||||
} // namespace re_detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
@ -11,897 +11,103 @@
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE: c_regex_traits.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Implements the cpp_regex_traits<charT> traits class
|
||||
* FILE cpp_regex_traits.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Implements cpp_regex_traits<char> (and associated helper classes).
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <boost/config.hpp>
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#if defined(BOOST_REGEX_HAS_SHORT_WCHAR_T) && !defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
# pragma message ("disabling support for class cpp_regex_traits<wchar_t> - rebuild with /Zc:wchar_t if you really need this")
|
||||
# define BOOST_NO_WREGEX
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{
|
||||
using ::memset;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4786 4702 4127 4244)
|
||||
# endif
|
||||
|
||||
#include <clocale>
|
||||
#include <locale>
|
||||
#include <cstdio>
|
||||
#include <list>
|
||||
#include <cctype>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
#include "primary_transform.hpp"
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4786 4702 4127 4244)
|
||||
# endif
|
||||
|
||||
namespace{
|
||||
const unsigned int re_classes_max = 14;
|
||||
const unsigned int char_set_size = CHAR_MAX - CHAR_MIN + 1;
|
||||
|
||||
boost::uint_fast32_t re_char_class_id[] = {
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_alnum,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_alpha,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_cntrl,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_digit,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_graph,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_lower,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_print,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_punct,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_space,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_upper,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_xdigit,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_blank,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_word,
|
||||
boost::re_detail::cpp_regex_traits_base::char_class_unicode,
|
||||
};
|
||||
|
||||
const char* re_char_class_names[] = {
|
||||
"alnum",
|
||||
"alpha",
|
||||
"cntrl",
|
||||
"digit",
|
||||
"graph",
|
||||
"lower",
|
||||
"print",
|
||||
"punct",
|
||||
"space",
|
||||
"upper",
|
||||
"xdigit",
|
||||
"blank",
|
||||
"word",
|
||||
"unicode",
|
||||
};
|
||||
|
||||
template <class charT,
|
||||
class traits = ::std::char_traits<charT> >
|
||||
class parser_buf : public ::std::basic_streambuf<charT, traits>
|
||||
void cpp_regex_traits_char_layer<char>::init()
|
||||
{
|
||||
typedef ::std::basic_streambuf<charT, traits> base_type;
|
||||
typedef typename base_type::int_type int_type;
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::pos_type pos_type;
|
||||
typedef ::std::streamsize streamsize;
|
||||
typedef typename base_type::off_type off_type;
|
||||
public:
|
||||
parser_buf() : base_type() { setbuf(0, 0); }
|
||||
const charT* getnext() { return this->gptr(); }
|
||||
protected:
|
||||
std::basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n);
|
||||
typename parser_buf<charT, traits>::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which);
|
||||
typename parser_buf<charT, traits>::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which);
|
||||
private:
|
||||
parser_buf& operator=(const parser_buf&);
|
||||
parser_buf(const parser_buf&);
|
||||
};
|
||||
|
||||
template<class charT, class traits>
|
||||
std::basic_streambuf<charT, traits>*
|
||||
parser_buf<charT, traits>::setbuf(char_type* s, streamsize n)
|
||||
{
|
||||
this->setg(s, s, s + n);
|
||||
return this;
|
||||
}
|
||||
|
||||
template<class charT, class traits>
|
||||
typename parser_buf<charT, traits>::pos_type
|
||||
parser_buf<charT, traits>::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which)
|
||||
{
|
||||
if(which & ::std::ios_base::out)
|
||||
return pos_type(off_type(-1));
|
||||
std::ptrdiff_t size = this->egptr() - this->eback();
|
||||
std::ptrdiff_t pos = this->gptr() - this->eback();
|
||||
charT* g = this->eback();
|
||||
switch(way)
|
||||
{
|
||||
case ::std::ios_base::beg:
|
||||
if((off < 0) || (off > size))
|
||||
return pos_type(off_type(-1));
|
||||
else
|
||||
this->setg(g, g + off, g + size);
|
||||
break;
|
||||
case ::std::ios_base::end:
|
||||
if((off < 0) || (off > size))
|
||||
return pos_type(off_type(-1));
|
||||
else
|
||||
this->setg(g, g + size - off, g + size);
|
||||
break;
|
||||
case ::std::ios_base::cur:
|
||||
{
|
||||
std::ptrdiff_t newpos = pos + off;
|
||||
if((newpos < 0) || (newpos > size))
|
||||
return pos_type(off_type(-1));
|
||||
else
|
||||
this->setg(g, g + newpos, g + size);
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
}
|
||||
return static_cast<pos_type>(this->gptr() - this->eback());
|
||||
}
|
||||
|
||||
template<class charT, class traits>
|
||||
typename parser_buf<charT, traits>::pos_type
|
||||
parser_buf<charT, traits>::seekpos(pos_type sp, ::std::ios_base::openmode which)
|
||||
{
|
||||
if(which & ::std::ios_base::out)
|
||||
return pos_type(off_type(-1));
|
||||
off_type size = this->egptr() - this->eback();
|
||||
charT* g = this->eback();
|
||||
if(off_type(sp) <= size)
|
||||
{
|
||||
this->setg(g, g + off_type(sp), g + size);
|
||||
}
|
||||
return pos_type(off_type(-1));
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
template <>
|
||||
struct message_data<char>
|
||||
{
|
||||
unsigned char syntax_map[CHAR_MAX-CHAR_MIN];
|
||||
std::map<std::string, std::string, std::less<std::string> > collating_elements;
|
||||
std::map<std::string, std::size_t, std::less<std::string> > classes;
|
||||
//std::string _zero;
|
||||
//std::string _ten;
|
||||
parser_buf<char> sbuf;
|
||||
std::istream is;
|
||||
std::string error_strings[boost::REG_E_UNKNOWN+1];
|
||||
|
||||
message_data(const std::locale& l, std::string regex_message_catalogue);
|
||||
private:
|
||||
message_data(const message_data&);
|
||||
message_data& operator=(const message_data&);
|
||||
};
|
||||
|
||||
|
||||
message_data<char>::message_data(const std::locale& l, std::string regex_message_catalogue)
|
||||
: is(&sbuf)
|
||||
{
|
||||
is.imbue(l);
|
||||
// we need to start by initialising our syntax map so we know which
|
||||
// character is used for which purpose:
|
||||
std::memset(m_char_map, 0, sizeof(m_char_map));
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
|
||||
const std::messages<char>* pm = 0;
|
||||
#ifndef __IBMCPP__
|
||||
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
|
||||
#endif
|
||||
if(regex_message_catalogue.size())
|
||||
std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
|
||||
if(cat_name.size())
|
||||
{
|
||||
pm = &BOOST_USE_FACET(std::messages<char>, l);
|
||||
cat = pm->open(regex_message_catalogue, l);
|
||||
if(cat < 0)
|
||||
cat = this->m_pmessages->open(
|
||||
cat_name,
|
||||
this->m_locale);
|
||||
if((int)cat < 0)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
std::runtime_error err(m + regex_message_catalogue);
|
||||
boost::throw_exception(err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
std::memset(syntax_map, cpp_regex_traits<char>::syntax_char, 256);
|
||||
unsigned i;
|
||||
scoped_array<char> a;
|
||||
std::size_t array_size = 0;
|
||||
std::size_t new_size;
|
||||
for(i = 1; i < cpp_regex_traits<char>::syntax_max; ++i)
|
||||
{
|
||||
new_size = re_get_default_message(0, 0, i+100);
|
||||
if(new_size > array_size)
|
||||
{
|
||||
a.reset(new char[new_size]);
|
||||
array_size = new_size;
|
||||
}
|
||||
re_get_default_message(a.get(), array_size, i+100);
|
||||
std::string s = a.get();
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
if((int)cat >= 0)
|
||||
s = pm->get(cat, 0, i+100, s);
|
||||
#endif
|
||||
for(std::size_t j = 0; j < s.size(); ++j)
|
||||
{
|
||||
syntax_map[(unsigned char)s[j]] = (unsigned char)(i);
|
||||
std::runtime_error err(m + cat_name);
|
||||
boost::re_detail::raise_runtime_error(err);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
// load any custom collate names:
|
||||
//
|
||||
// for some reason Borland C++ Builder 6 won't let us use
|
||||
// std::isspace(char, std::locale) unless we call it
|
||||
// unqualifed - weird. This seems to be affecting other
|
||||
// STLport users as well (gcc3.1+STLport5), so enable the
|
||||
// workaround for all STLport users...
|
||||
// if we have a valid catalog then load our messages:
|
||||
//
|
||||
#if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && !defined(BOOST_MSVC)
|
||||
using namespace std;
|
||||
using stlport::isspace;
|
||||
# define BOOST_REGEX_STD
|
||||
#else
|
||||
# define BOOST_REGEX_STD std::
|
||||
#endif
|
||||
|
||||
std::string c1, c2;
|
||||
i = 400;
|
||||
if((int)cat >= 0)
|
||||
{
|
||||
c2 = pm->get(cat, 0, i, c1);
|
||||
while(c2.size())
|
||||
{
|
||||
const char* p1, *p2, *p3, *p4;;
|
||||
p1 = c2.c_str();
|
||||
while(*p1 && BOOST_REGEX_STD isspace((char)*p1, l))++p1;
|
||||
p2 = p1;
|
||||
while(*p2 && !BOOST_REGEX_STD isspace((char)*p2, l))++p2;
|
||||
p3 = p2;
|
||||
while(*p3 && BOOST_REGEX_STD isspace((char)*p3, l))++p3;
|
||||
p4 = p3;
|
||||
while(*p4 && !BOOST_REGEX_STD isspace((char)*p4, l))++p4;
|
||||
collating_elements[std::string(p1, p2)] = std::string(p3, p4);
|
||||
|
||||
++i;
|
||||
c2 = pm->get(cat, 0, i, c1);
|
||||
try{
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
|
||||
for(string_type::size_type j = 0; j < mss.size(); ++j)
|
||||
{
|
||||
m_char_map[static_cast<unsigned char>(mss[j])] = i;
|
||||
}
|
||||
}
|
||||
this->m_pmessages->close(cat);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
std::string m;
|
||||
std::string s;
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
if((int)cat >= 0)
|
||||
{
|
||||
for(i = 0; i < re_classes_max; ++i)
|
||||
catch(...)
|
||||
{
|
||||
s = pm->get(cat, 0, i+300, m);
|
||||
if(s.size())
|
||||
classes[s] = i;
|
||||
this->m_pmessages->close(cat);
|
||||
throw;
|
||||
}
|
||||
for(i = 0; i <= boost::REG_E_UNKNOWN ; ++i)
|
||||
{
|
||||
s = pm->get(cat, 0, i+200, m);
|
||||
error_strings[i] = s;
|
||||
}
|
||||
}
|
||||
|
||||
if((int)cat >= 0)
|
||||
pm->close(cat);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string BOOST_REGEX_CALL cpp_regex_traits_base::set_message_catalogue(const std::string& l)
|
||||
{
|
||||
if(sizeof(regex_message_cat) <= l.size())
|
||||
return l;
|
||||
std::string old(regex_message_cat);
|
||||
std::strcpy(regex_message_cat, l.c_str());
|
||||
return old;
|
||||
}
|
||||
|
||||
char cpp_regex_traits_base::regex_message_cat[BOOST_REGEX_MAX_PATH] = {0};
|
||||
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
|
||||
cpp_regex_traits<char>::cpp_regex_traits()
|
||||
{
|
||||
pmd = new re_detail::message_data<char>(locale_inst, regex_message_cat);
|
||||
psyntax = pmd->syntax_map;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
lower_map = new char[char_set_size];
|
||||
BOOST_REGEX_NOEH_ASSERT(lower_map)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete pmd;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<char>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<char>, locale_inst);
|
||||
pctype->tolower(&lower_map[0], &lower_map[char_set_size]);
|
||||
pcollate = &BOOST_USE_FACET(std::collate<char>, locale_inst);
|
||||
sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim));
|
||||
}
|
||||
|
||||
void cpp_regex_traits<char>::swap(cpp_regex_traits<char>& that)
|
||||
{
|
||||
std::swap(locale_inst, that.locale_inst); // this one goes first
|
||||
std::swap(pmd, that.pmd);
|
||||
std::swap(psyntax, that.psyntax);
|
||||
std::swap(lower_map, that.lower_map);
|
||||
std::swap(pctype, that.pctype);
|
||||
std::swap(pcollate, that.pcollate);
|
||||
std::swap(sort_type, that.sort_type);
|
||||
std::swap(sort_delim, that.sort_delim);
|
||||
}
|
||||
|
||||
cpp_regex_traits<char>::~cpp_regex_traits()
|
||||
{
|
||||
delete pmd;
|
||||
delete[] lower_map;
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<char>::toi(char c)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf(&c, 1);
|
||||
pmd->is.clear();
|
||||
pmd->is >> std::dec;
|
||||
int val;
|
||||
if(pmd->is >> val)
|
||||
{
|
||||
return val;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<char>::toi(const char*& first, const char* last, int radix)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf(const_cast<char*>(static_cast<const char*>(first)), static_cast<std::streamsize>(last-first));
|
||||
pmd->is.clear();
|
||||
if(std::abs(radix) == 16) pmd->is >> std::hex;
|
||||
else if(std::abs(radix) == 8) pmd->is >> std::oct;
|
||||
else pmd->is >> std::dec;
|
||||
int val;
|
||||
if(pmd->is >> val)
|
||||
{
|
||||
first = first + ((last - first) - pmd->sbuf.in_avail());
|
||||
return val;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL cpp_regex_traits<char>::lookup_classname(const char* first, const char* last)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int i;
|
||||
std::string s(first, last);
|
||||
|
||||
std::map<std::string, std::size_t, std::less<std::string> >::const_iterator pos = pmd->classes.find(s);
|
||||
if(pos != pmd->classes.end())
|
||||
return re_char_class_id[(*pos).second];
|
||||
|
||||
for(i = 0; i < re_classes_max; ++i)
|
||||
{
|
||||
if(s == re_char_class_names[i])
|
||||
return re_char_class_id[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL cpp_regex_traits<char>::lookup_collatename(std::string& s, const char* first, const char* last)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string name(first, last);
|
||||
std::map<std::string, std::string, std::less<std::string > >::const_iterator pos = pmd->collating_elements.find(name);
|
||||
if(pos != pmd->collating_elements.end())
|
||||
{
|
||||
s = (*pos).second;
|
||||
return true;
|
||||
}
|
||||
return re_detail::re_lookup_def_collate_name(s, name.c_str());
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL cpp_regex_traits<char>::transform_primary(std::string& out, const std::string& in)const
|
||||
{
|
||||
transform(out, in);
|
||||
switch(sort_type)
|
||||
{
|
||||
case re_detail::sort_C:
|
||||
case re_detail::sort_unknown:
|
||||
break;
|
||||
case re_detail::sort_fixed:
|
||||
if((unsigned)sort_delim < out.size())
|
||||
out.erase((int)sort_delim);
|
||||
break;
|
||||
case re_detail::sort_delim:
|
||||
for(unsigned int i = 0; i < out.size(); ++i)
|
||||
#endif
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
if((out[i] == sort_delim) && (i+1 < out.size()))
|
||||
const char* ptr = get_default_syntax(i);
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
out.erase(i+1);
|
||||
break;
|
||||
m_char_map[static_cast<unsigned char>(*ptr)] = i;
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string BOOST_REGEX_CALL cpp_regex_traits<char>::error_string(unsigned id)const
|
||||
{
|
||||
if((id <= boost::REG_E_UNKNOWN) && (pmd->error_strings[id].size()))
|
||||
return pmd->error_strings[id];
|
||||
return boost::re_detail::re_default_error_messages[id];
|
||||
}
|
||||
|
||||
cpp_regex_traits<char>::locale_type BOOST_REGEX_CALL cpp_regex_traits<char>::imbue(locale_type l)
|
||||
{
|
||||
locale_type old_l(locale_inst);
|
||||
locale_inst = l;
|
||||
re_detail::message_data<char>* npmd = new re_detail::message_data<char>(locale_inst, regex_message_cat);
|
||||
delete pmd;
|
||||
pmd = npmd;
|
||||
psyntax = pmd->syntax_map;
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<char>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<char>, locale_inst);
|
||||
pctype->tolower(&lower_map[0], &lower_map[char_set_size]);
|
||||
pcollate = &BOOST_USE_FACET(std::collate<char>, locale_inst);
|
||||
sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim));
|
||||
return old_l;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_STD_WSTREAMBUF)
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
std::string BOOST_REGEX_CALL to_narrow(const std::basic_string<wchar_t>& is, const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t>::size_type bufsize = is.size() * 2;
|
||||
#endif
|
||||
//
|
||||
// declare buffer first as VC6 workaround for internal compiler error!
|
||||
char* pc = new char[bufsize];
|
||||
scoped_array<char> t(pc);
|
||||
#if defined(BOOST_MSVC) && !defined(DINKUMWARE_CE)
|
||||
std::mbstate_t state = 0;
|
||||
#else
|
||||
std::mbstate_t state = std::mbstate_t();
|
||||
#endif
|
||||
|
||||
const wchar_t* next_in;
|
||||
char* next_out;
|
||||
while(true)
|
||||
{
|
||||
switch(cvt.out(state, is.c_str(), is.c_str() + is.size(), next_in, t.get(), t.get() + bufsize, next_out))
|
||||
{
|
||||
case std::codecvt_base::ok:
|
||||
return std::string(t.get(), next_out);
|
||||
case std::codecvt_base::partial:
|
||||
bufsize *= 2;
|
||||
t.reset(new char[bufsize]);
|
||||
continue;
|
||||
case std::codecvt_base::error:
|
||||
// not much we can do here but guess:
|
||||
case std::codecvt_base::noconv:
|
||||
std::string out;
|
||||
for(unsigned i = 0; i < is.size(); ++i)
|
||||
{
|
||||
out.append(1, (char)is[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring BOOST_REGEX_CALL to_wide(const std::string& is, const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string::size_type bufsize = is.size() + 2;
|
||||
std::string::size_type maxsize = is.size() * 100;
|
||||
// finish off by calculating our escape types:
|
||||
//
|
||||
// declare buffer first as VC6 workaround for internal compiler error!
|
||||
wchar_t* pc = new wchar_t[bufsize];
|
||||
scoped_array<wchar_t> t(pc);
|
||||
#if defined(BOOST_MSVC) && !defined(DINKUMWARE_CE)
|
||||
std::mbstate_t state = 0;
|
||||
#else
|
||||
std::mbstate_t state = std::mbstate_t();
|
||||
#endif
|
||||
|
||||
|
||||
wchar_t* next_out;
|
||||
const char* next_in;
|
||||
while(true)
|
||||
unsigned char i = 'A';
|
||||
do
|
||||
{
|
||||
switch(cvt.in(state, is.c_str(), is.c_str() + is.size(), next_in, t.get(), t.get() + bufsize, next_out))
|
||||
if(m_char_map[i] == 0)
|
||||
{
|
||||
case std::codecvt_base::ok:
|
||||
return std::wstring(t.get(), next_out);
|
||||
case std::codecvt_base::partial:
|
||||
bufsize *= 2;
|
||||
if(bufsize < maxsize)
|
||||
{
|
||||
t.reset(new wchar_t[bufsize]);
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// error fall through:
|
||||
case std::codecvt_base::error:
|
||||
// not much we can do here but guess:
|
||||
case std::codecvt_base::noconv:
|
||||
std::wstring out;
|
||||
for(unsigned i = 0; i < is.size(); ++i)
|
||||
{
|
||||
out.append(1, is[i]);
|
||||
}
|
||||
return out;
|
||||
if(this->m_pctype->is(std::ctype_base::lower, i))
|
||||
m_char_map[i] = regex_constants::escape_type_class;
|
||||
else if(this->m_pctype->is(std::ctype_base::upper, i))
|
||||
m_char_map[i] = regex_constants::escape_type_not_class;
|
||||
}
|
||||
}
|
||||
}while(0xFF != i++);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <>
|
||||
struct message_data<wchar_t>
|
||||
{
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
typedef std::messages<wchar_t>::string_type string_type;
|
||||
#else
|
||||
typedef std::wstring string_type;
|
||||
} // re_detail
|
||||
} // boost
|
||||
#endif
|
||||
|
||||
string_type name;
|
||||
|
||||
struct syntax_map
|
||||
{
|
||||
wchar_t c;
|
||||
unsigned int type;
|
||||
};
|
||||
|
||||
std::list<syntax_map> syntax;
|
||||
std::map<string_type, std::size_t> classes;
|
||||
std::map<string_type, string_type> collating_elements;
|
||||
unsigned char syntax_[CHAR_MAX-CHAR_MIN+1];
|
||||
|
||||
parser_buf<wchar_t> sbuf;
|
||||
std::wistream is;
|
||||
std::string error_strings[boost::REG_E_UNKNOWN+1];
|
||||
|
||||
message_data(const std::locale& l, const std::string& regex_message_catalogue);
|
||||
private:
|
||||
message_data(const message_data&);
|
||||
message_data& operator=(const message_data&);
|
||||
};
|
||||
|
||||
message_data<wchar_t>::message_data(const std::locale& l, const std::string& regex_message_catalogue)
|
||||
: is(&sbuf)
|
||||
{
|
||||
is.imbue(l);
|
||||
syntax_map m;
|
||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> cvt_type;
|
||||
const cvt_type& cvt = BOOST_USE_FACET(cvt_type, l);
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
const std::messages<wchar_t>& msgs = BOOST_USE_FACET(std::messages<wchar_t>, l);
|
||||
#ifndef __IBMCPP__
|
||||
std::messages<wchar_t>::catalog cat = static_cast<std::messages<wchar_t>::catalog>(-1);
|
||||
#else
|
||||
std::messages<wchar_t>::catalog cat = reinterpret_cast<std::messages<wchar_t>::catalog>(-1);
|
||||
#endif
|
||||
if(regex_message_catalogue.size())
|
||||
{
|
||||
cat = msgs.open(regex_message_catalogue, l);
|
||||
if(cat < 0)
|
||||
{
|
||||
std::string mess("Unable to open message catalog: ");
|
||||
std::runtime_error err(mess + regex_message_catalogue);
|
||||
boost::throw_exception(err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
scoped_array<char> a;
|
||||
std::size_t array_size = 0;
|
||||
std::size_t new_size;
|
||||
std::size_t i;
|
||||
std::memset(syntax_, cpp_regex_traits<wchar_t>::syntax_char, sizeof(syntax_));
|
||||
for(i = 1; i < cpp_regex_traits<wchar_t>::syntax_max; ++i)
|
||||
{
|
||||
new_size = re_get_default_message(0, 0, i+100);
|
||||
if(new_size > array_size)
|
||||
{
|
||||
a.reset(new char[new_size]);
|
||||
array_size = new_size;
|
||||
}
|
||||
re_get_default_message(a.get(), array_size, i+100);
|
||||
std::string ns = a.get();
|
||||
string_type s = to_wide(ns, cvt);
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
if((int)cat >= 0)
|
||||
s = BOOST_USE_FACET(std::messages<wchar_t>, l).get(cat, 0, (int)i+100, s);
|
||||
#endif
|
||||
for(unsigned int j = 0; j < s.size(); ++j)
|
||||
{
|
||||
#if defined(WCHAR_MIN) && (WCHAR_MIN == 0)
|
||||
if(s[j] <= UCHAR_MAX)
|
||||
#else
|
||||
if((s[j] <= UCHAR_MAX) && (s[j] >= 0))
|
||||
#endif
|
||||
syntax_[s[j]] = static_cast<unsigned char>(i);
|
||||
else
|
||||
{
|
||||
m.c = s[j];
|
||||
m.type = static_cast<unsigned int>(i);
|
||||
syntax.push_back(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
// load any custom collate names:
|
||||
string_type c1, c2;
|
||||
i = 400;
|
||||
if((int)cat >= 0)
|
||||
{
|
||||
c2 = msgs.get(cat, 0, (int)i, c1);
|
||||
while(c2.size())
|
||||
{
|
||||
const wchar_t* p1, *p2, *p3, *p4;;
|
||||
p1 = c2.c_str();
|
||||
while(*p1 && BOOST_REGEX_STD isspace((wchar_t)*p1, l))++p1;
|
||||
p2 = p1;
|
||||
while(*p2 && !BOOST_REGEX_STD isspace((wchar_t)*p2, l))++p2;
|
||||
p3 = p2;
|
||||
while(*p3 && BOOST_REGEX_STD isspace((wchar_t)*p3, l))++p3;
|
||||
p4 = p3;
|
||||
while(*p4 && !BOOST_REGEX_STD isspace((wchar_t)*p4, l))++p4;
|
||||
collating_elements[std::basic_string<wchar_t>(p1, p2)] = std::basic_string<wchar_t>(p3, p4);
|
||||
|
||||
++i;
|
||||
c2 = msgs.get(cat, 0, (int)i, c1);
|
||||
}
|
||||
}
|
||||
|
||||
if((int)cat >= 0)
|
||||
{
|
||||
c2.erase();
|
||||
for(i = 0; i < re_classes_max; ++i)
|
||||
{
|
||||
c1 = msgs.get(cat, 0, static_cast<int>(i+300), c2);
|
||||
if(c1.size())
|
||||
classes[c1] = i;
|
||||
}
|
||||
for(i = 0; i <= boost::REG_E_UNKNOWN ; ++i)
|
||||
{
|
||||
c1 = msgs.get(cat, 0, static_cast<int>(i+200), c2);
|
||||
error_strings[i] = to_narrow(c1, cvt);
|
||||
}
|
||||
}
|
||||
|
||||
if((int)cat >= 0)
|
||||
msgs.close(cat);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
unsigned int BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::do_syntax_type(size_type c)const
|
||||
{
|
||||
std::list<re_detail::message_data<wchar_t>::syntax_map>::const_iterator i, j;
|
||||
i = pmd->syntax.begin();
|
||||
j = pmd->syntax.end();
|
||||
while(i != j)
|
||||
{
|
||||
if(((uchar_type)(*i).c) == c)
|
||||
return (*i).type;
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::transform_primary(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in)const
|
||||
{
|
||||
transform(out, in);
|
||||
switch(sort_type)
|
||||
{
|
||||
case re_detail::sort_C:
|
||||
case re_detail::sort_unknown:
|
||||
break;
|
||||
case re_detail::sort_fixed:
|
||||
if((unsigned)sort_delim < out.size())
|
||||
out.erase((int)sort_delim);
|
||||
break;
|
||||
case re_detail::sort_delim:
|
||||
for(unsigned int i = 0; i < out.size(); ++i)
|
||||
{
|
||||
if((out[i] == sort_delim) && (i+1 < out.size()))
|
||||
{
|
||||
out.erase(i+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::toi(wchar_t c)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf(&c, 1);
|
||||
pmd->is.clear();
|
||||
pmd->is >> std::dec;
|
||||
int val;
|
||||
if(pmd->is >> val)
|
||||
{
|
||||
return val;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::toi(const wchar_t*& first, const wchar_t* last, int radix)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf(const_cast<wchar_t*>(first), static_cast<std::streamsize>(last-first));
|
||||
pmd->is.clear();
|
||||
if(std::abs(radix) == 16) pmd->is >> std::hex;
|
||||
else if(std::abs(radix) == 8) pmd->is >> std::oct;
|
||||
else pmd->is >> std::dec;
|
||||
int val;
|
||||
if(pmd->is >> val)
|
||||
{
|
||||
first = first + ((last - first) - pmd->sbuf.in_avail());
|
||||
return val;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::lookup_classname(const wchar_t* first, const wchar_t* last)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int i;
|
||||
std::wstring s(first, last);
|
||||
|
||||
std::map<std::wstring, std::size_t>::const_iterator pos = pmd->classes.find(s);
|
||||
if(pos != pmd->classes.end())
|
||||
return re_char_class_id[(*pos).second];
|
||||
|
||||
std::string ns = re_detail::to_narrow(s, *pcdv);
|
||||
|
||||
for(i = 0; i < re_classes_max; ++i)
|
||||
{
|
||||
if(ns == re_char_class_names[i])
|
||||
return re_char_class_id[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::lookup_collatename(std::basic_string<wchar_t>& s, const wchar_t* first, const wchar_t* last)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::wstring name(first, last);
|
||||
std::map<std::wstring, std::wstring>::const_iterator pos = pmd->collating_elements.find(name);
|
||||
if(pos != pmd->collating_elements.end())
|
||||
{
|
||||
s = (*pos).second;
|
||||
return true;
|
||||
}
|
||||
std::string ns = re_detail::to_narrow(name, *pcdv);
|
||||
std::string ns2;
|
||||
bool result = re_detail::re_lookup_def_collate_name(ns2, ns.c_str());
|
||||
s = re_detail::to_wide(ns2, *pcdv);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::error_string(unsigned id)const
|
||||
{
|
||||
if((id <= boost::REG_E_UNKNOWN) && (pmd->error_strings[id].size()))
|
||||
return pmd->error_strings[id];
|
||||
return boost::re_detail::re_default_error_messages[id];
|
||||
}
|
||||
|
||||
cpp_regex_traits<wchar_t>::cpp_regex_traits()
|
||||
{
|
||||
pmd = new re_detail::message_data<wchar_t>(locale_inst, std::string(regex_message_cat));
|
||||
psyntax = pmd->syntax_;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
lower_map = new wchar_t[char_set_size];
|
||||
BOOST_REGEX_NOEH_ASSERT(lower_map)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete pmd;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<wchar_t>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<wchar_t>, locale_inst);
|
||||
pctype->tolower(&lower_map[0], &lower_map[char_set_size]);
|
||||
pcollate = &BOOST_USE_FACET(std::collate<wchar_t>, locale_inst);
|
||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> cvt_t;
|
||||
pcdv = &BOOST_USE_FACET(cvt_t, locale_inst);
|
||||
sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim));
|
||||
}
|
||||
|
||||
cpp_regex_traits<wchar_t>::~cpp_regex_traits()
|
||||
{
|
||||
delete pmd;
|
||||
delete[] lower_map;
|
||||
}
|
||||
|
||||
cpp_regex_traits<wchar_t>::locale_type BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::imbue(locale_type l)
|
||||
{
|
||||
locale_type old_l(locale_inst);
|
||||
locale_inst = l;
|
||||
re_detail::message_data<wchar_t>* npmd = new re_detail::message_data<wchar_t>(locale_inst, std::string(regex_message_cat));
|
||||
delete pmd;
|
||||
pmd = npmd;
|
||||
psyntax = pmd->syntax_;
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<wchar_t>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<wchar_t>, locale_inst);
|
||||
pctype->tolower(&lower_map[0], &lower_map[char_set_size]);
|
||||
pcollate = &BOOST_USE_FACET(std::collate<wchar_t>, locale_inst);
|
||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> cvt_t;
|
||||
pcdv = &BOOST_USE_FACET(cvt_t, locale_inst);
|
||||
sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim));
|
||||
return old_l;
|
||||
}
|
||||
|
||||
std::size_t BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::strwiden(wchar_t *s1, std::size_t len, const char *s2)const
|
||||
{
|
||||
std::string s(s2);
|
||||
std::wstring ws = re_detail::to_wide(s2, *pcdv);
|
||||
if(len > ws.size())
|
||||
std::wcscpy(s1, ws.c_str());
|
||||
return ws.size()+1;
|
||||
}
|
||||
|
||||
void cpp_regex_traits<wchar_t>::swap(cpp_regex_traits<wchar_t>& that)
|
||||
{
|
||||
std::swap(locale_inst, that.locale_inst); // this one must go first
|
||||
std::swap(pmd, that.pmd);
|
||||
std::swap(psyntax, that.psyntax);
|
||||
std::swap(lower_map, that.lower_map);
|
||||
std::swap(pctype, that.pctype);
|
||||
std::swap(pcollate, that.pcollate);
|
||||
std::swap(pcdv, that.pcdv);
|
||||
std::swap(sort_type, that.sort_type);
|
||||
std::swap(sort_delim, that.sort_delim);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_WREGEX
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# include <boost/integer_traits.hpp>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_STD_STRING)
|
||||
#include <map>
|
||||
#include <list>
|
||||
@ -36,6 +33,12 @@ typedef boost::match_flag_type match_flag_type;
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf; using ::strcpy; using ::strcat;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -54,7 +57,6 @@ namespace{
|
||||
template <class iterator>
|
||||
std::string to_string(iterator i, iterator j)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string s;
|
||||
while(i != j)
|
||||
{
|
||||
@ -108,7 +110,6 @@ public:
|
||||
|
||||
void RegExData::update()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
strings.erase(strings.begin(), strings.end());
|
||||
positions.erase(positions.begin(), positions.end());
|
||||
if(t == type_pc)
|
||||
@ -116,7 +117,7 @@ void RegExData::update()
|
||||
for(unsigned int i = 0; i < m.size(); ++i)
|
||||
{
|
||||
if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second);
|
||||
positions[i] = m[i].matched ? m[i].first - pbase : RegEx::npos;
|
||||
positions[i] = m[i].matched ? m[i].first - pbase : -1;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
@ -125,7 +126,7 @@ void RegExData::update()
|
||||
for(unsigned int i = 0; i < fm.size(); ++i)
|
||||
{
|
||||
if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second);
|
||||
positions[i] = fm[i].matched ? fm[i].first - fbase : RegEx::npos;
|
||||
positions[i] = fm[i].matched ? fm[i].first - fbase : -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -134,7 +135,6 @@ void RegExData::update()
|
||||
|
||||
void RegExData::clean()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fbase = mapfile::iterator();
|
||||
fm = match_results<mapfile::iterator>();
|
||||
@ -145,54 +145,46 @@ void RegExData::clean()
|
||||
|
||||
RegEx::RegEx()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
}
|
||||
|
||||
RegEx::RegEx(const RegEx& o)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData(*(o.pdata));
|
||||
}
|
||||
|
||||
RegEx::~RegEx()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete pdata;
|
||||
}
|
||||
|
||||
RegEx::RegEx(const char* c, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
SetExpression(c, icase);
|
||||
}
|
||||
|
||||
RegEx::RegEx(const std::string& s, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
SetExpression(s.c_str(), icase);
|
||||
}
|
||||
|
||||
RegEx& RegEx::operator=(const RegEx& o)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
*pdata = *(o.pdata);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RegEx& RegEx::operator=(const char* p)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
SetExpression(p, false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int RegEx::SetExpression(const char* p, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
boost::uint_fast32_t f = icase ? regex::normal | regex::use_except | regex::icase : regex::normal | regex::use_except;
|
||||
boost::uint_fast32_t f = icase ? regex::normal | regex::icase : regex::normal;
|
||||
return pdata->e.set_expression(p, f);
|
||||
}
|
||||
|
||||
@ -204,7 +196,6 @@ unsigned int RegEx::error_code()const
|
||||
|
||||
std::string RegEx::Expression()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return pdata->e.expression();
|
||||
}
|
||||
|
||||
@ -213,7 +204,6 @@ std::string RegEx::Expression()const
|
||||
//
|
||||
bool RegEx::Match(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -229,7 +219,6 @@ bool RegEx::Match(const char* p, match_flag_type flags)
|
||||
|
||||
bool RegEx::Search(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -257,7 +246,6 @@ struct pred1
|
||||
}
|
||||
unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -287,7 +275,6 @@ private:
|
||||
|
||||
unsigned int RegEx::Grep(std::vector<std::string>& v, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -317,7 +304,6 @@ private:
|
||||
}
|
||||
unsigned int RegEx::Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -350,7 +336,6 @@ struct pred4
|
||||
namespace{
|
||||
void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
file_iterator start(files);
|
||||
file_iterator end;
|
||||
if(recurse)
|
||||
@ -380,7 +365,7 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
while(dstart != dend)
|
||||
{
|
||||
std::sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
(std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
BuildFileList(pl, buf, recurse);
|
||||
++dstart;
|
||||
}
|
||||
@ -395,7 +380,6 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
std::list<std::string> file_list;
|
||||
BuildFileList(&file_list, files, recurse);
|
||||
@ -423,7 +407,6 @@ unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recur
|
||||
|
||||
unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
std::list<std::string> file_list;
|
||||
BuildFileList(&file_list, files, recurse);
|
||||
@ -491,7 +474,6 @@ std::size_t RegEx::Split(std::vector<std::string>& v,
|
||||
//
|
||||
std::size_t RegEx::Position(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -511,16 +493,14 @@ std::size_t RegEx::Position(int i)const
|
||||
return RegEx::npos;
|
||||
}
|
||||
|
||||
unsigned int RegEx::Marks()const
|
||||
std::size_t RegEx::Marks()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return pdata->e.mark_count();
|
||||
}
|
||||
|
||||
|
||||
std::size_t RegEx::Length(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -542,7 +522,6 @@ std::size_t RegEx::Length(int i)const
|
||||
|
||||
bool RegEx::Matched(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -565,7 +544,6 @@ bool RegEx::Matched(int i)const
|
||||
|
||||
std::string RegEx::What(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string result;
|
||||
switch(pdata->t)
|
||||
{
|
||||
@ -588,14 +566,10 @@ std::string RegEx::What(int i)const
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
const std::size_t RegEx::npos = ::boost::integer_traits<std::size_t>::const_max;
|
||||
#elif defined(BOOST_HAS_LONG_LONG)
|
||||
const std::size_t RegEx::npos = ~0ULL;
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL);
|
||||
#else
|
||||
const std::size_t RegEx::npos = ~0UL;
|
||||
#endif
|
||||
const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL);
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
@ -21,11 +21,33 @@
|
||||
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#endif
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
using ::fseek;
|
||||
using ::fread;
|
||||
using ::ftell;
|
||||
using ::fopen;
|
||||
using ::fclose;
|
||||
using ::FILE;
|
||||
using ::strcpy;
|
||||
using ::strcpy;
|
||||
using ::strcat;
|
||||
using ::strcmp;
|
||||
using ::strlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
|
||||
@ -47,7 +69,7 @@ namespace boost{
|
||||
// directories are separated with '\\'
|
||||
// and names are insensitive of case
|
||||
|
||||
const char* _fi_sep = "\\";
|
||||
BOOST_REGEX_DECL const char* _fi_sep = "\\";
|
||||
const char* _fi_sep_alt = "/";
|
||||
#define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c)
|
||||
|
||||
@ -57,7 +79,7 @@ const char* _fi_sep_alt = "/";
|
||||
// directories are separated with '/'
|
||||
// and names are sensitive of case
|
||||
|
||||
const char* _fi_sep = "/";
|
||||
BOOST_REGEX_DECL const char* _fi_sep = "/";
|
||||
const char* _fi_sep_alt = _fi_sep;
|
||||
#define BOOST_REGEX_FI_TRANSLATE(c) c
|
||||
|
||||
@ -67,7 +89,6 @@ const char* _fi_sep_alt = _fi_sep;
|
||||
|
||||
void mapfile::open(const char* file)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#if defined(__CYGWIN__)||defined(__CYGWIN32__)
|
||||
char win32file[ MAX_PATH ];
|
||||
cygwin_conv_to_win32_path( file, win32file );
|
||||
@ -84,7 +105,7 @@ void mapfile::open(const char* file)
|
||||
hmap = 0;
|
||||
hfile = 0;
|
||||
std::runtime_error err("Unable to create file mapping.");
|
||||
boost::throw_exception(err);
|
||||
boost::re_detail::raise_runtime_error(err);
|
||||
}
|
||||
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
|
||||
if(_first == 0)
|
||||
@ -110,7 +131,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
UnmapViewOfFile((void*)_first);
|
||||
@ -125,7 +145,6 @@ void mapfile::close()
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(file && node)
|
||||
file->unlock(node);
|
||||
file = i.file;
|
||||
@ -138,7 +157,6 @@ mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator++ ()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((++offset == mapfile::buf_size) && file)
|
||||
{
|
||||
++node;
|
||||
@ -151,7 +169,6 @@ mapfile_iterator& mapfile_iterator::operator++ ()
|
||||
|
||||
mapfile_iterator mapfile_iterator::operator++ (int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(*this);
|
||||
if((++offset == mapfile::buf_size) && file)
|
||||
{
|
||||
@ -165,7 +182,6 @@ mapfile_iterator mapfile_iterator::operator++ (int)
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator-- ()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((offset == 0) && file)
|
||||
{
|
||||
--node;
|
||||
@ -180,7 +196,6 @@ mapfile_iterator& mapfile_iterator::operator-- ()
|
||||
|
||||
mapfile_iterator mapfile_iterator::operator-- (int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(*this);
|
||||
if((offset == 0) && file)
|
||||
{
|
||||
@ -196,7 +211,6 @@ mapfile_iterator mapfile_iterator::operator-- (int)
|
||||
|
||||
mapfile_iterator operator + (const mapfile_iterator& i, long off)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(i);
|
||||
temp += off;
|
||||
return temp;
|
||||
@ -204,7 +218,6 @@ mapfile_iterator operator + (const mapfile_iterator& i, long off)
|
||||
|
||||
mapfile_iterator operator - (const mapfile_iterator& i, long off)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(i);
|
||||
temp -= off;
|
||||
return temp;
|
||||
@ -212,19 +225,16 @@ mapfile_iterator operator - (const mapfile_iterator& i, long off)
|
||||
|
||||
mapfile::iterator mapfile::begin()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return mapfile_iterator(this, 0);
|
||||
}
|
||||
|
||||
mapfile::iterator mapfile::end()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return mapfile_iterator(this, _size);
|
||||
}
|
||||
|
||||
void mapfile::lock(pointer* node)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
assert(node >= _first);
|
||||
assert(node <= _last);
|
||||
if(node < _last)
|
||||
@ -265,7 +275,6 @@ void mapfile::lock(pointer* node)const
|
||||
|
||||
void mapfile::unlock(pointer* node)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
assert(node >= _first);
|
||||
assert(node <= _last);
|
||||
if(node < _last)
|
||||
@ -279,7 +288,6 @@ void mapfile::unlock(pointer* node)const
|
||||
|
||||
long int get_file_length(std::FILE* hfile)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
long int result;
|
||||
std::fseek(hfile, 0, SEEK_END);
|
||||
result = std::ftell(hfile);
|
||||
@ -290,7 +298,6 @@ long int get_file_length(std::FILE* hfile)
|
||||
|
||||
void mapfile::open(const char* file)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
hfile = std::fopen(file, "rb");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
@ -325,7 +332,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != 0)
|
||||
{
|
||||
pointer* p = _first;
|
||||
@ -350,7 +356,6 @@ void mapfile::close()
|
||||
|
||||
file_iterator::file_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -381,7 +386,6 @@ file_iterator::file_iterator()
|
||||
|
||||
file_iterator::file_iterator(const char* wild)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -450,7 +454,6 @@ file_iterator::file_iterator(const char* wild)
|
||||
|
||||
file_iterator::file_iterator(const file_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -478,7 +481,6 @@ file_iterator::file_iterator(const file_iterator& other)
|
||||
|
||||
file_iterator& file_iterator::operator=(const file_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
@ -496,7 +498,6 @@ file_iterator& file_iterator::operator=(const file_iterator& other)
|
||||
|
||||
file_iterator::~file_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete[] _root;
|
||||
delete[] _path;
|
||||
if(--(ref->count) == 0)
|
||||
@ -509,7 +510,6 @@ file_iterator::~file_iterator()
|
||||
|
||||
file_iterator file_iterator::operator++(int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
file_iterator temp(*this);
|
||||
next();
|
||||
return temp;
|
||||
@ -518,7 +518,6 @@ file_iterator file_iterator::operator++(int)
|
||||
|
||||
void file_iterator::next()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(ref->hf != _fi_invalid_handle)
|
||||
{
|
||||
bool cont = true;
|
||||
@ -545,7 +544,6 @@ void file_iterator::next()
|
||||
|
||||
directory_iterator::directory_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -576,7 +574,6 @@ directory_iterator::directory_iterator()
|
||||
|
||||
directory_iterator::directory_iterator(const char* wild)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -643,7 +640,6 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
|
||||
directory_iterator::~directory_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete[] _root;
|
||||
delete[] _path;
|
||||
if(--(ref->count) == 0)
|
||||
@ -656,7 +652,6 @@ directory_iterator::~directory_iterator()
|
||||
|
||||
directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -684,7 +679,6 @@ directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
|
||||
directory_iterator& directory_iterator::operator=(const directory_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
@ -701,7 +695,6 @@ directory_iterator& directory_iterator::operator=(const directory_iterator& othe
|
||||
|
||||
directory_iterator directory_iterator::operator++(int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
directory_iterator temp(*this);
|
||||
next();
|
||||
return temp;
|
||||
@ -709,7 +702,6 @@ directory_iterator directory_iterator::operator++(int)
|
||||
|
||||
void directory_iterator::next()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(ref->hf != _fi_invalid_handle)
|
||||
{
|
||||
bool cont = true;
|
||||
@ -748,7 +740,6 @@ struct _fi_priv_data
|
||||
|
||||
_fi_priv_data::_fi_priv_data(const char* p)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(root, p);
|
||||
mask = root;
|
||||
while(*mask) ++mask;
|
||||
@ -775,7 +766,6 @@ _fi_priv_data::_fi_priv_data(const char* p)
|
||||
|
||||
bool iswild(const char* mask, const char* name)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
while(*mask && *name)
|
||||
{
|
||||
switch(*mask)
|
||||
@ -817,12 +807,11 @@ bool iswild(const char* mask, const char* name)
|
||||
|
||||
unsigned _fi_attributes(const char* root, const char* name)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
char buf[MAX_PATH];
|
||||
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
|
||||
std::sprintf(buf, "%s%s", root, name);
|
||||
(std::sprintf)(buf, "%s%s", root, name);
|
||||
else
|
||||
std::sprintf(buf, "%s%s%s", root, _fi_sep, name);
|
||||
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
||||
DIR* d = opendir(buf);
|
||||
if(d)
|
||||
{
|
||||
@ -834,7 +823,6 @@ unsigned _fi_attributes(const char* root, const char* name)
|
||||
|
||||
_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_fi_find_handle dat = new _fi_priv_data(lpFileName);
|
||||
|
||||
DIR* h = opendir(dat->root);
|
||||
@ -850,7 +838,6 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF
|
||||
|
||||
bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
dirent* d;
|
||||
do
|
||||
{
|
||||
@ -868,7 +855,6 @@ bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
|
||||
|
||||
bool _fi_FindClose(_fi_find_handle dat)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
closedir(dat->d);
|
||||
delete dat;
|
||||
return true;
|
||||
|
445
src/icu.cpp
Normal file
445
src/icu.cpp
Normal file
@ -0,0 +1,445 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* 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 icu.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Unicode regular expressions on top of the ICU Library.
|
||||
*/
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifdef BOOST_HAS_ICU
|
||||
#include <boost/regex/icu.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const ::Collator* pcoll) const
|
||||
{
|
||||
// TODO make thread safe!!!! :
|
||||
typedef u32_to_u16_iterator<const char_type*, ::UChar> itt;
|
||||
itt i(p1), j(p2);
|
||||
std::vector< ::UChar> t(i, j);
|
||||
::uint8_t result[100];
|
||||
::int32_t len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result));
|
||||
if(std::size_t(len) > sizeof(result))
|
||||
{
|
||||
scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]);
|
||||
len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1);
|
||||
if(0 == presult[len-1])
|
||||
--len;
|
||||
return string_type(presult.get(), presult.get()+len);
|
||||
}
|
||||
if(0 == result[len-1])
|
||||
--len;
|
||||
return string_type(result, result+len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
icu_regex_traits::size_type icu_regex_traits::length(const char_type* p)
|
||||
{
|
||||
size_type result = 0;
|
||||
while(*p)
|
||||
{
|
||||
++p;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// define our bitmasks:
|
||||
//
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_blank = icu_regex_traits::char_class_type(1) << offset_blank;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_space = icu_regex_traits::char_class_type(1) << offset_space;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_xdigit = icu_regex_traits::char_class_type(1) << offset_xdigit;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_underscore = icu_regex_traits::char_class_type(1) << offset_underscore;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_unicode = icu_regex_traits::char_class_type(1) << offset_unicode;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_any = icu_regex_traits::char_class_type(1) << offset_any;
|
||||
const icu_regex_traits::char_class_type icu_regex_traits::mask_ascii = icu_regex_traits::char_class_type(1) << offset_ascii;
|
||||
|
||||
icu_regex_traits::char_class_type icu_regex_traits::lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2)
|
||||
{
|
||||
static const ::UChar32 prop_name_table[] = {
|
||||
/* any */ 'a', 'n', 'y',
|
||||
/* ascii */ 'a', 's', 'c', 'i', 'i',
|
||||
/* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd',
|
||||
/* c* */ 'c', '*',
|
||||
/* cc */ 'c', 'c',
|
||||
/* cf */ 'c', 'f',
|
||||
/* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* cn */ 'c', 'n',
|
||||
/* co */ 'c', 'o',
|
||||
/* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l',
|
||||
/* cs */ 'c', 's',
|
||||
/* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l',
|
||||
/* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r',
|
||||
/* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
|
||||
/* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* format */ 'f', 'o', 'r', 'm', 'a', 't',
|
||||
/* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* l* */ 'l', '*',
|
||||
/* letter */ 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r',
|
||||
/* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
|
||||
/* ll */ 'l', 'l',
|
||||
/* lm */ 'l', 'm',
|
||||
/* lo */ 'l', 'o',
|
||||
/* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* lt */ 'l', 't',
|
||||
/* lu */ 'l', 'u',
|
||||
/* m* */ 'm', '*',
|
||||
/* mark */ 'm', 'a', 'r', 'k',
|
||||
/* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l',
|
||||
/* mc */ 'm', 'c',
|
||||
/* me */ 'm', 'e',
|
||||
/* mn */ 'm', 'n',
|
||||
/* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l',
|
||||
/* n* */ 'n', '*',
|
||||
/* nd */ 'n', 'd',
|
||||
/* nl */ 'n', 'l',
|
||||
/* no */ 'n', 'o',
|
||||
/* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
|
||||
/* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd',
|
||||
/* number */ 'n', 'u', 'm', 'b', 'e', 'r',
|
||||
/* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* other */ 'o', 't', 'h', 'e', 'r',
|
||||
/* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r',
|
||||
/* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l',
|
||||
/* p* */ 'p', '*',
|
||||
/* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
|
||||
/* pc */ 'p', 'c',
|
||||
/* pd */ 'p', 'd',
|
||||
/* pe */ 'p', 'e',
|
||||
/* pf */ 'p', 'f',
|
||||
/* pi */ 'p', 'i',
|
||||
/* po */ 'p', 'o',
|
||||
/* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e',
|
||||
/* ps */ 'p', 's',
|
||||
/* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n',
|
||||
/* s* */ 's', '*',
|
||||
/* sc */ 's', 'c',
|
||||
/* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
|
||||
/* sk */ 's', 'k',
|
||||
/* sm */ 's', 'm',
|
||||
/* so */ 's', 'o',
|
||||
/* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r',
|
||||
/* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k',
|
||||
/* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e',
|
||||
/* symbol */ 's', 'y', 'm', 'b', 'o', 'l',
|
||||
/* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e',
|
||||
/* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r',
|
||||
/* z* */ 'z', '*',
|
||||
/* zl */ 'z', 'l',
|
||||
/* zp */ 'z', 'p',
|
||||
/* zs */ 'z', 's',
|
||||
};
|
||||
|
||||
static const re_detail::character_pointer_range< ::UChar32> range_data[] = {
|
||||
{ prop_name_table+0, prop_name_table+3, }, // any
|
||||
{ prop_name_table+3, prop_name_table+8, }, // ascii
|
||||
{ prop_name_table+8, prop_name_table+16, }, // assigned
|
||||
{ prop_name_table+16, prop_name_table+18, }, // c*
|
||||
{ prop_name_table+18, prop_name_table+20, }, // cc
|
||||
{ prop_name_table+20, prop_name_table+22, }, // cf
|
||||
{ prop_name_table+22, prop_name_table+38, }, // closepunctuation
|
||||
{ prop_name_table+38, prop_name_table+40, }, // cn
|
||||
{ prop_name_table+40, prop_name_table+42, }, // co
|
||||
{ prop_name_table+42, prop_name_table+62, }, // connectorpunctuation
|
||||
{ prop_name_table+62, prop_name_table+69, }, // control
|
||||
{ prop_name_table+69, prop_name_table+71, }, // cs
|
||||
{ prop_name_table+71, prop_name_table+85, }, // currencysymbol
|
||||
{ prop_name_table+85, prop_name_table+100, }, // dashpunctuation
|
||||
{ prop_name_table+100, prop_name_table+118, }, // decimaldigitnumber
|
||||
{ prop_name_table+118, prop_name_table+131, }, // enclosingmark
|
||||
{ prop_name_table+131, prop_name_table+147, }, // finalpunctuation
|
||||
{ prop_name_table+147, prop_name_table+153, }, // format
|
||||
{ prop_name_table+153, prop_name_table+171, }, // initialpunctuation
|
||||
{ prop_name_table+171, prop_name_table+173, }, // l*
|
||||
{ prop_name_table+173, prop_name_table+179, }, // letter
|
||||
{ prop_name_table+179, prop_name_table+191, }, // letternumber
|
||||
{ prop_name_table+191, prop_name_table+204, }, // lineseparator
|
||||
{ prop_name_table+204, prop_name_table+206, }, // ll
|
||||
{ prop_name_table+206, prop_name_table+208, }, // lm
|
||||
{ prop_name_table+208, prop_name_table+210, }, // lo
|
||||
{ prop_name_table+210, prop_name_table+225, }, // lowercaseletter
|
||||
{ prop_name_table+225, prop_name_table+227, }, // lt
|
||||
{ prop_name_table+227, prop_name_table+229, }, // lu
|
||||
{ prop_name_table+229, prop_name_table+231, }, // m*
|
||||
{ prop_name_table+231, prop_name_table+235, }, // mark
|
||||
{ prop_name_table+235, prop_name_table+245, }, // mathsymbol
|
||||
{ prop_name_table+245, prop_name_table+247, }, // mc
|
||||
{ prop_name_table+247, prop_name_table+249, }, // me
|
||||
{ prop_name_table+249, prop_name_table+251, }, // mn
|
||||
{ prop_name_table+251, prop_name_table+265, }, // modifierletter
|
||||
{ prop_name_table+265, prop_name_table+279, }, // modifiersymbol
|
||||
{ prop_name_table+279, prop_name_table+281, }, // n*
|
||||
{ prop_name_table+281, prop_name_table+283, }, // nd
|
||||
{ prop_name_table+283, prop_name_table+285, }, // nl
|
||||
{ prop_name_table+285, prop_name_table+287, }, // no
|
||||
{ prop_name_table+287, prop_name_table+301, }, // nonspacingmark
|
||||
{ prop_name_table+301, prop_name_table+312, }, // notassigned
|
||||
{ prop_name_table+312, prop_name_table+318, }, // number
|
||||
{ prop_name_table+318, prop_name_table+333, }, // openpunctuation
|
||||
{ prop_name_table+333, prop_name_table+338, }, // other
|
||||
{ prop_name_table+338, prop_name_table+349, }, // otherletter
|
||||
{ prop_name_table+349, prop_name_table+360, }, // othernumber
|
||||
{ prop_name_table+360, prop_name_table+376, }, // otherpunctuation
|
||||
{ prop_name_table+376, prop_name_table+387, }, // othersymbol
|
||||
{ prop_name_table+387, prop_name_table+389, }, // p*
|
||||
{ prop_name_table+389, prop_name_table+407, }, // paragraphseparator
|
||||
{ prop_name_table+407, prop_name_table+409, }, // pc
|
||||
{ prop_name_table+409, prop_name_table+411, }, // pd
|
||||
{ prop_name_table+411, prop_name_table+413, }, // pe
|
||||
{ prop_name_table+413, prop_name_table+415, }, // pf
|
||||
{ prop_name_table+415, prop_name_table+417, }, // pi
|
||||
{ prop_name_table+417, prop_name_table+419, }, // po
|
||||
{ prop_name_table+419, prop_name_table+429, }, // privateuse
|
||||
{ prop_name_table+429, prop_name_table+431, }, // ps
|
||||
{ prop_name_table+431, prop_name_table+442, }, // punctuation
|
||||
{ prop_name_table+442, prop_name_table+444, }, // s*
|
||||
{ prop_name_table+444, prop_name_table+446, }, // sc
|
||||
{ prop_name_table+446, prop_name_table+455, }, // separator
|
||||
{ prop_name_table+455, prop_name_table+457, }, // sk
|
||||
{ prop_name_table+457, prop_name_table+459, }, // sm
|
||||
{ prop_name_table+459, prop_name_table+461, }, // so
|
||||
{ prop_name_table+461, prop_name_table+475, }, // spaceseparator
|
||||
{ prop_name_table+475, prop_name_table+495, }, // spacingcombiningmark
|
||||
{ prop_name_table+495, prop_name_table+504, }, // surrogate
|
||||
{ prop_name_table+504, prop_name_table+510, }, // symbol
|
||||
{ prop_name_table+510, prop_name_table+519, }, // titlecase
|
||||
{ prop_name_table+519, prop_name_table+534, }, // titlecaseletter
|
||||
{ prop_name_table+534, prop_name_table+549, }, // uppercaseletter
|
||||
{ prop_name_table+549, prop_name_table+551, }, // z*
|
||||
{ prop_name_table+551, prop_name_table+553, }, // zl
|
||||
{ prop_name_table+553, prop_name_table+555, }, // zp
|
||||
{ prop_name_table+555, prop_name_table+557, }, // zs
|
||||
};
|
||||
|
||||
static const icu_regex_traits::char_class_type icu_class_map[] = {
|
||||
icu_regex_traits::mask_any, // any
|
||||
icu_regex_traits::mask_ascii, // ascii
|
||||
(0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned
|
||||
U_GC_C_MASK, // c*
|
||||
U_GC_CC_MASK, // cc
|
||||
U_GC_CF_MASK, // cf
|
||||
U_GC_PE_MASK, // closepunctuation
|
||||
U_GC_CN_MASK, // cn
|
||||
U_GC_CO_MASK, // co
|
||||
U_GC_PC_MASK, // connectorpunctuation
|
||||
U_GC_CC_MASK, // control
|
||||
U_GC_CS_MASK, // cs
|
||||
U_GC_SC_MASK, // currencysymbol
|
||||
U_GC_PD_MASK, // dashpunctuation
|
||||
U_GC_ND_MASK, // decimaldigitnumber
|
||||
U_GC_ME_MASK, // enclosingmark
|
||||
U_GC_PF_MASK, // finalpunctuation
|
||||
U_GC_CF_MASK, // format
|
||||
U_GC_PI_MASK, // initialpunctuation
|
||||
U_GC_L_MASK, // l*
|
||||
U_GC_L_MASK, // letter
|
||||
U_GC_NL_MASK, // letternumber
|
||||
U_GC_ZL_MASK, // lineseparator
|
||||
U_GC_LL_MASK, // ll
|
||||
U_GC_LM_MASK, // lm
|
||||
U_GC_LO_MASK, // lo
|
||||
U_GC_LL_MASK, // lowercaseletter
|
||||
U_GC_LT_MASK, // lt
|
||||
U_GC_LU_MASK, // lu
|
||||
U_GC_M_MASK, // m*
|
||||
U_GC_M_MASK, // mark
|
||||
U_GC_SM_MASK, // mathsymbol
|
||||
U_GC_MC_MASK, // mc
|
||||
U_GC_ME_MASK, // me
|
||||
U_GC_MN_MASK, // mn
|
||||
U_GC_LM_MASK, // modifierletter
|
||||
U_GC_SK_MASK, // modifiersymbol
|
||||
U_GC_N_MASK, // n*
|
||||
U_GC_ND_MASK, // nd
|
||||
U_GC_NL_MASK, // nl
|
||||
U_GC_NO_MASK, // no
|
||||
U_GC_MN_MASK, // nonspacingmark
|
||||
U_GC_CN_MASK, // notassigned
|
||||
U_GC_N_MASK, // number
|
||||
U_GC_PS_MASK, // openpunctuation
|
||||
U_GC_C_MASK, // other
|
||||
U_GC_LO_MASK, // otherletter
|
||||
U_GC_NO_MASK, // othernumber
|
||||
U_GC_PO_MASK, // otherpunctuation
|
||||
U_GC_SO_MASK, // othersymbol
|
||||
U_GC_P_MASK, // p*
|
||||
U_GC_ZP_MASK, // paragraphseparator
|
||||
U_GC_PC_MASK, // pc
|
||||
U_GC_PD_MASK, // pd
|
||||
U_GC_PE_MASK, // pe
|
||||
U_GC_PF_MASK, // pf
|
||||
U_GC_PI_MASK, // pi
|
||||
U_GC_PO_MASK, // po
|
||||
U_GC_CO_MASK, // privateuse
|
||||
U_GC_PS_MASK, // ps
|
||||
U_GC_P_MASK, // punctuation
|
||||
U_GC_S_MASK, // s*
|
||||
U_GC_SC_MASK, // sc
|
||||
U_GC_Z_MASK, // separator
|
||||
U_GC_SK_MASK, // sk
|
||||
U_GC_SM_MASK, // sm
|
||||
U_GC_SO_MASK, // so
|
||||
U_GC_ZS_MASK, // spaceseparator
|
||||
U_GC_MC_MASK, // spacingcombiningmark
|
||||
U_GC_CS_MASK, // surrogate
|
||||
U_GC_S_MASK, // symbol
|
||||
U_GC_LT_MASK, // titlecase
|
||||
U_GC_LT_MASK, // titlecaseletter
|
||||
U_GC_LU_MASK, // uppercaseletter
|
||||
U_GC_Z_MASK, // z*
|
||||
U_GC_ZL_MASK, // zl
|
||||
U_GC_ZP_MASK, // zp
|
||||
U_GC_ZS_MASK, // zs
|
||||
};
|
||||
|
||||
|
||||
static const re_detail::character_pointer_range< ::UChar32>* ranges_begin = range_data;
|
||||
static const re_detail::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data)/sizeof(range_data[0]));
|
||||
|
||||
re_detail::character_pointer_range< ::UChar32> t = { p1, p2, };
|
||||
const re_detail::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t);
|
||||
if((p != ranges_end) && (t == *p))
|
||||
return icu_class_map[p - ranges_begin];
|
||||
return 0;
|
||||
}
|
||||
|
||||
icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_type* p1, const char_type* p2) const
|
||||
{
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
0,
|
||||
U_GC_L_MASK | U_GC_ND_MASK,
|
||||
U_GC_L_MASK,
|
||||
mask_blank,
|
||||
U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK,
|
||||
U_GC_ND_MASK,
|
||||
U_GC_ND_MASK,
|
||||
(0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK),
|
||||
U_GC_LL_MASK,
|
||||
U_GC_LL_MASK,
|
||||
~(U_GC_C_MASK),
|
||||
U_GC_P_MASK,
|
||||
char_class_type(U_GC_Z_MASK) | mask_space,
|
||||
char_class_type(U_GC_Z_MASK) | mask_space,
|
||||
U_GC_LU_MASK,
|
||||
mask_unicode,
|
||||
U_GC_LU_MASK,
|
||||
char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore,
|
||||
char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore,
|
||||
char_class_type(U_GC_ND_MASK) | mask_xdigit,
|
||||
};
|
||||
|
||||
int id = ::boost::re_detail::get_default_class_id(p1, p2);
|
||||
if(id >= 0)
|
||||
return masks[id+1];
|
||||
char_class_type result = lookup_icu_mask(p1, p2);
|
||||
if(result != 0)
|
||||
return result;
|
||||
|
||||
if(id < 0)
|
||||
{
|
||||
string_type s(p1, p2);
|
||||
string_type::size_type i = 0;
|
||||
while(i < s.size())
|
||||
{
|
||||
s[i] = static_cast<char>((::u_tolower)(s[i]));
|
||||
if(::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_'))
|
||||
s.erase(s.begin()+i, s.begin()+i+1);
|
||||
else
|
||||
{
|
||||
s[i] = static_cast<char>((::u_tolower)(s[i]));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||
if(id >= 0)
|
||||
return masks[id+1];
|
||||
result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size());
|
||||
if(result != 0)
|
||||
return result;
|
||||
}
|
||||
BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0]));
|
||||
return masks[id+1];
|
||||
}
|
||||
|
||||
icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const
|
||||
{
|
||||
string_type result;
|
||||
if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2)
|
||||
{
|
||||
std::string s(p1, p2);
|
||||
// Try Unicode name:
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err);
|
||||
if(U_SUCCESS(err))
|
||||
{
|
||||
result.push_back(c);
|
||||
return result;
|
||||
}
|
||||
// Try Unicode-extended name:
|
||||
err = U_ZERO_ERROR;
|
||||
c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err);
|
||||
if(U_SUCCESS(err))
|
||||
{
|
||||
result.push_back(c);
|
||||
return result;
|
||||
}
|
||||
// try POSIX name:
|
||||
s = ::boost::re_detail::lookup_default_collate_name(s);
|
||||
result.assign(s.begin(), s.end());
|
||||
}
|
||||
if(result.empty() && (p2-p1 == 1))
|
||||
result.push_back(*p1);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool icu_regex_traits::isctype(char_type c, char_class_type f) const
|
||||
{
|
||||
// check for standard catagories first:
|
||||
char_class_type m = char_class_type(1u << u_charType(c));
|
||||
if((m & f) != 0)
|
||||
return true;
|
||||
// now check for special cases:
|
||||
if(((f & mask_blank) != 0) && u_isblank(c))
|
||||
return true;
|
||||
if(((f & mask_space) != 0) && u_isspace(c))
|
||||
return true;
|
||||
if(((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0))
|
||||
return true;
|
||||
if(((f & mask_unicode) != 0) && (c >= 0x100))
|
||||
return true;
|
||||
if(((f & mask_underscore) != 0) && (c == '_'))
|
||||
return true;
|
||||
if(((f & mask_any) != 0) && (c <= 0x10FFFF))
|
||||
return true;
|
||||
if(((f & mask_ascii) != 0) && (c <= 0x7F))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_HAS_ICU
|
@ -19,8 +19,18 @@
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <cstdio>
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
using ::strcpy;
|
||||
using ::strcmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace{
|
||||
@ -35,7 +45,6 @@ const char* names[] = {"REG_NOERROR", "REG_NOMATCH", "REG_BADPAT", "REG_ECOLLATE
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic != magic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
@ -54,7 +63,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regex::extended : regex::basic;
|
||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
// and translate those that are actually set:
|
||||
|
||||
@ -67,20 +76,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
}
|
||||
|
||||
if(f & REG_NOSUB)
|
||||
expression->eflags |= match_any;
|
||||
{
|
||||
//expression->eflags |= match_any;
|
||||
flags |= regex::nosubs;
|
||||
}
|
||||
|
||||
if(f & REG_NOSPEC)
|
||||
flags |= regex::literal;
|
||||
if(f & REG_ICASE)
|
||||
flags |= regex::icase;
|
||||
if(f & REG_ESCAPE_IN_LISTS)
|
||||
flags |= regex::escape_in_lists;
|
||||
flags &= ~regex::no_escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= regex::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= regex::perlex;
|
||||
#endif
|
||||
|
||||
const char* p2;
|
||||
if(f & REG_PEND)
|
||||
@ -97,7 +105,12 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
expression->re_nsub = static_cast<regex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<regex*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
}
|
||||
catch(const boost::regex_error& be)
|
||||
{
|
||||
result = be.code();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
}
|
||||
@ -110,12 +123,11 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
|
||||
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* e, char* buf, regsize_t buf_size)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t result = 0;
|
||||
if(code & REG_ITOA)
|
||||
{
|
||||
code &= ~REG_ITOA;
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
{
|
||||
result = std::strlen(names[code]) + 1;
|
||||
if(buf_size >= result)
|
||||
@ -129,30 +141,29 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
char localbuf[5];
|
||||
if(e == 0)
|
||||
return 0;
|
||||
for(int i = 0; i <= REG_E_UNKNOWN; ++i)
|
||||
for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i)
|
||||
{
|
||||
if(std::strcmp(e->re_endp, names[i]) == 0)
|
||||
{
|
||||
std::sprintf(localbuf, "%d", i);
|
||||
(std::sprintf)(localbuf, "%d", i);
|
||||
if(std::strlen(localbuf) < buf_size)
|
||||
std::strcpy(buf, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
std::sprintf(localbuf, "%d", 0);
|
||||
(std::sprintf)(localbuf, "%d", 0);
|
||||
if(std::strlen(localbuf) < buf_size)
|
||||
std::strcpy(buf, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
}
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
{
|
||||
std::string p;
|
||||
if((e) && (e->re_magic == magic_value))
|
||||
p = static_cast<regex*>(e->guts)->get_traits().error_string(code);
|
||||
p = static_cast<regex*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
else
|
||||
{
|
||||
boost::regex_traits<char> t;
|
||||
p = t.error_string(code);
|
||||
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
}
|
||||
std::size_t len = p.size();
|
||||
if(len < buf_size)
|
||||
@ -168,7 +179,10 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, const char* buf, regsize_t n, regmatch_t* array, int eflags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4267)
|
||||
#endif
|
||||
bool result = false;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const char* end;
|
||||
@ -209,7 +223,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
if(result)
|
||||
{
|
||||
// extract what matched:
|
||||
unsigned int i;
|
||||
std::size_t i;
|
||||
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
|
||||
{
|
||||
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
|
||||
@ -224,11 +238,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
return 0;
|
||||
}
|
||||
return REG_NOMATCH;
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == magic_value)
|
||||
{
|
||||
delete static_cast<regex*>(expression->guts);
|
||||
|
@ -1,117 +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: primary_transform.hpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Heuristically determines the sort string format in use
|
||||
* by the current locale.
|
||||
*/
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
|
||||
enum{
|
||||
sort_C,
|
||||
sort_fixed,
|
||||
sort_delim,
|
||||
sort_unknown
|
||||
};
|
||||
|
||||
template <class S, class charT>
|
||||
unsigned count_chars(const S& s, charT c)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
for(unsigned pos = 0; pos < s.size(); ++pos)
|
||||
{
|
||||
if(s[pos] == c) ++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
template <class traits, class charT>
|
||||
unsigned find_sort_syntax(const traits* pt, charT* delim)
|
||||
{
|
||||
//
|
||||
// compare 'a' with 'A' to see how similar they are,
|
||||
// should really use a-accute but we can't portably do that,
|
||||
//
|
||||
typedef typename traits::string_type string_type;
|
||||
typedef typename traits::char_type char_type;
|
||||
|
||||
// Suppress incorrect warning for MSVC
|
||||
(void)pt;
|
||||
|
||||
string_type a(1, (char_type)'a');
|
||||
string_type sa;
|
||||
pt->transform(sa, a);
|
||||
if(sa == a)
|
||||
{
|
||||
*delim = 0;
|
||||
return sort_C;
|
||||
}
|
||||
string_type A(1, (char_type)'A');
|
||||
string_type sA;
|
||||
pt->transform(sA, A);
|
||||
string_type c(1, (char_type)';');
|
||||
string_type sc;
|
||||
pt->transform(sc, c);
|
||||
|
||||
int pos = 0;
|
||||
while((pos <= static_cast<int>(sa.size())) && (pos <= static_cast<int>(sA.size())) && (sa[pos] == sA[pos])) ++pos;
|
||||
--pos;
|
||||
if(pos < 0)
|
||||
{
|
||||
*delim = 0;
|
||||
return sort_unknown;
|
||||
}
|
||||
//
|
||||
// at this point sa[pos] is either the end of a fixed with field
|
||||
// or the character that acts as a delimiter:
|
||||
//
|
||||
charT maybe_delim = sa[pos];
|
||||
if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(c, maybe_delim)))
|
||||
{
|
||||
*delim = maybe_delim;
|
||||
return sort_delim;
|
||||
}
|
||||
//
|
||||
// OK doen't look like a delimiter, try for fixed width field:
|
||||
//
|
||||
if((sa.size() == sA.size()) && (sa.size() == c.size()))
|
||||
{
|
||||
// note assumes that the fixed width field is less than
|
||||
// numeric_limits<charT>::max(), should be true for all types
|
||||
// I can't imagine 127 character fields...
|
||||
*delim = static_cast<charT>(++pos);
|
||||
return sort_fixed;
|
||||
}
|
||||
//
|
||||
// don't know what it is:
|
||||
//
|
||||
*delim = 0;
|
||||
return sort_unknown;
|
||||
}
|
||||
|
||||
|
||||
} // namespace re_detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Copyright (c) 1998-2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
@ -26,6 +26,13 @@
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#define NOGDI
|
||||
#define NOUSER
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||
@ -43,18 +50,39 @@ namespace boost{
|
||||
// that dll builds contain the Virtual table for these
|
||||
// types - this ensures that exceptions can be thrown
|
||||
// from the dll and caught in an exe.
|
||||
bad_pattern::~bad_pattern() throw() {}
|
||||
bad_expression::~bad_expression() throw() {}
|
||||
regex_error::regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos)
|
||||
: std::runtime_error(s)
|
||||
, m_error_code(err)
|
||||
, m_position(pos)
|
||||
{
|
||||
}
|
||||
|
||||
regbase::regbase()
|
||||
: _flags(regbase::failbit){}
|
||||
regex_error::regex_error(regex_constants::error_type err)
|
||||
: std::runtime_error(::boost::re_detail::get_default_error_string(err))
|
||||
, m_error_code(err)
|
||||
, m_position(0)
|
||||
{
|
||||
}
|
||||
|
||||
regex_error::~regex_error() throw()
|
||||
{
|
||||
}
|
||||
|
||||
void regex_error::raise()const
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
::boost::throw_exception(*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
regbase::regbase(const regbase& b)
|
||||
: _flags(b._flags){}
|
||||
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex)
|
||||
{
|
||||
::boost::throw_exception(ex);
|
||||
}
|
||||
//
|
||||
// error checking API:
|
||||
//
|
||||
@ -74,6 +102,29 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
|
||||
static void execute_eror()
|
||||
{
|
||||
// we only get here after a stack overflow,
|
||||
// this has to be a separate proceedure because we
|
||||
// can't mix __try{}__except block with local objects
|
||||
// that have destructors:
|
||||
reset_stack_guard_page();
|
||||
std::runtime_error err("Out of stack space, while attempting to match a regular expression.");
|
||||
raise_runtime_error(err);
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL abstract_protected_call::execute()const
|
||||
{
|
||||
__try{
|
||||
return this->call();
|
||||
}__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode())
|
||||
{
|
||||
execute_eror();
|
||||
}
|
||||
// We never really get here at all:
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
{
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
@ -118,12 +169,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& msg)
|
||||
{
|
||||
bad_expression e(msg);
|
||||
throw_exception(e);
|
||||
}
|
||||
|
||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||
|
||||
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||
@ -140,7 +185,11 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
|
||||
#else
|
||||
mem_block_cache block_cache = { 0, 0, };
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Copyright (c) 1998-2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
@ -21,199 +21,6 @@
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_DEBUG
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_raw_buffer.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
||||
#endif
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#ifndef BOOST_RE_OLD_IOSTREAM
|
||||
#include <ostream>
|
||||
#else
|
||||
#include <ostream.h>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace re_detail {
|
||||
std::ostream& operator<<(std::ostream& s, syntax_element_type x)
|
||||
{
|
||||
return s << static_cast<unsigned long>(x);
|
||||
}
|
||||
}} // namespace boost::re_detail
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
char b1[32] = {0,};
|
||||
char guard_pattern[32]
|
||||
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, };
|
||||
char b2[32] = {0,};
|
||||
|
||||
static const int guard_size = 32;
|
||||
|
||||
bool check_pattern(void* p)
|
||||
{
|
||||
return p ? memcmp(p, guard_pattern, guard_size) : 0;
|
||||
}
|
||||
|
||||
inline unsigned maxi(unsigned i, unsigned j)
|
||||
{
|
||||
return i < j ? j : i;
|
||||
}
|
||||
|
||||
unsigned int allocated = 0;
|
||||
|
||||
struct init
|
||||
{
|
||||
init();
|
||||
~init();
|
||||
};
|
||||
|
||||
init::init()
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
}
|
||||
|
||||
init::~init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
init i;
|
||||
|
||||
void* get_mem(size_t n)
|
||||
{
|
||||
++allocated;
|
||||
char* p = (char*)malloc(n + guard_size * 2 + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + boost::re_detail::padding_size);
|
||||
char* base = p;
|
||||
p = (char*)((std::ptrdiff_t)(p + boost::re_detail::padding_mask) & ~boost::re_detail::padding_mask);
|
||||
std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size), guard_pattern, guard_size);
|
||||
std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + n, guard_pattern, guard_size);
|
||||
*(int*)p = n;
|
||||
*(void**)(p + sizeof(int)) = base;
|
||||
return p + guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size);
|
||||
}
|
||||
|
||||
void free_mem(void* b)
|
||||
{
|
||||
if(b)
|
||||
{
|
||||
char* p = (char*)b;
|
||||
p -= (guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size));
|
||||
if(check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size)) || check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + *(int*)p))
|
||||
{
|
||||
cerr << "Error: freed memory has been written past end..." << endl;
|
||||
}
|
||||
free(*(void**)(p + sizeof(int)));
|
||||
--allocated;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void* operator new(size_t n)
|
||||
{
|
||||
return get_mem(n);
|
||||
}
|
||||
|
||||
void* operator new[](size_t n)
|
||||
{
|
||||
return get_mem(n);
|
||||
}
|
||||
|
||||
void operator delete(void* p)
|
||||
{
|
||||
free_mem(p);
|
||||
}
|
||||
|
||||
void operator delete[](void* p)
|
||||
{
|
||||
free_mem(p);
|
||||
}
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
std::set<debug_guard*, std::less<debug_guard*> >* patterns = 0;
|
||||
|
||||
int pattern_count = 0;
|
||||
|
||||
void check_patterns(const char* f, int l)
|
||||
{
|
||||
if(pattern_count)
|
||||
{
|
||||
std::set<debug_guard*, std::less<debug_guard*> >::iterator i, j;
|
||||
i = patterns->begin();
|
||||
j = patterns->end();
|
||||
while(i != j)
|
||||
{
|
||||
if(check_pattern((void*)(*i)->g1) || check_pattern((*i)->g2) || check_pattern((void*)(*i)->pc) || check_pattern((*i)->pnc))
|
||||
{
|
||||
cerr << "Error: static memory corruption at " << hex << *i << dec << " in " << (*i)->file << "@" << (*i)->line << " called from " << f << "@" << l << endl;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug_guard::debug_guard(const char* f, int l, const char* p1, char* p2)
|
||||
{
|
||||
if(++pattern_count == 1)
|
||||
patterns = new std::set<debug_guard*, std::less<debug_guard*> >;
|
||||
file = f;
|
||||
line = l;
|
||||
std::memcpy(g1, guard_pattern, guard_size);
|
||||
std::memcpy(g2, guard_pattern, guard_size);
|
||||
if(p1)
|
||||
{
|
||||
pc = p1;
|
||||
}
|
||||
else
|
||||
pc = 0;
|
||||
if(p2)
|
||||
{
|
||||
pnc = p2;
|
||||
std::memcpy(pnc, guard_pattern, guard_size);
|
||||
}
|
||||
else
|
||||
pnc = 0;
|
||||
patterns->insert(this);
|
||||
}
|
||||
|
||||
debug_guard::~debug_guard()
|
||||
{
|
||||
check_patterns(file, line);
|
||||
if(check_pattern(g1) || check_pattern(g2))
|
||||
{
|
||||
cerr << "Error: memory corruption " << file << "@" << line << endl;
|
||||
}
|
||||
patterns->erase(this);
|
||||
if(--pattern_count == 0)
|
||||
{
|
||||
delete patterns;
|
||||
patterns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// regex configuration information: this prints out the settings used
|
||||
|
70
src/regex_raw_buffer.cpp
Normal file
70
src/regex_raw_buffer.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* 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.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Member functions for class raw_storage.
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::memcpy;
|
||||
using ::memmove;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
void BOOST_REGEX_CALL raw_storage::resize(size_type n)
|
||||
{
|
||||
register size_type newsize = start ? last - start : 1024;
|
||||
while(newsize < n)
|
||||
newsize *= 2;
|
||||
register size_type datasize = end - start;
|
||||
// extend newsize to WORD/DWORD boundary:
|
||||
newsize = (newsize + padding_mask) & ~(padding_mask);
|
||||
|
||||
// allocate and copy data:
|
||||
register pointer ptr = static_cast<pointer>(::operator new(newsize));
|
||||
BOOST_REGEX_NOEH_ASSERT(ptr)
|
||||
std::memcpy(ptr, start, datasize);
|
||||
|
||||
// get rid of old buffer:
|
||||
::operator delete(start);
|
||||
|
||||
// and set up pointers:
|
||||
start = ptr;
|
||||
end = ptr + datasize;
|
||||
last = ptr + newsize;
|
||||
}
|
||||
|
||||
void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n)
|
||||
{
|
||||
BOOST_ASSERT(pos <= size_type(end - start));
|
||||
if(size_type(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;
|
||||
}
|
||||
|
||||
}} // namespaces
|
@ -1,74 +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.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Thread synch helper functions, for regular
|
||||
* expression library.
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
void BOOST_REGEX_CALL re_init_threads()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
if(p_re_lock == 0)
|
||||
p_re_lock = new critical_section();
|
||||
cs_guard g(*p_re_lock);
|
||||
++re_lock_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL re_free_threads()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
cs_guard g(*p_re_lock);
|
||||
--re_lock_count;
|
||||
if(re_lock_count == 0)
|
||||
{
|
||||
g.acquire(false);
|
||||
delete p_re_lock;
|
||||
p_re_lock = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
BOOST_REGEX_DECL critical_section* p_re_lock = 0;
|
||||
|
||||
BOOST_REGEX_DECL unsigned int re_lock_count = 0;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace re_detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
688
src/regex_traits_defaults.cpp
Normal file
688
src/regex_traits_defaults.cpp
Normal file
@ -0,0 +1,688 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* 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_defaults.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Declares API's for access to regex_traits default properties.
|
||||
*/
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
#include <cwctype>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::tolower;
|
||||
using ::toupper;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
using ::towlower;
|
||||
using ::towupper;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n)
|
||||
{
|
||||
// if the user hasn't supplied a message catalog, then this supplies
|
||||
// default "messages" for us to load in the range 1-100.
|
||||
const char* messages[] = {
|
||||
"",
|
||||
"(",
|
||||
")",
|
||||
"$",
|
||||
"^",
|
||||
".",
|
||||
"*",
|
||||
"+",
|
||||
"?",
|
||||
"[",
|
||||
"]",
|
||||
"|",
|
||||
"\\",
|
||||
"#",
|
||||
"-",
|
||||
"{",
|
||||
"}",
|
||||
"0123456789",
|
||||
"b",
|
||||
"B",
|
||||
"<",
|
||||
">",
|
||||
"",
|
||||
"",
|
||||
"A`",
|
||||
"z'",
|
||||
"\n",
|
||||
",",
|
||||
"a",
|
||||
"f",
|
||||
"n",
|
||||
"r",
|
||||
"t",
|
||||
"v",
|
||||
"x",
|
||||
"c",
|
||||
":",
|
||||
"=",
|
||||
"e",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"E",
|
||||
"Q",
|
||||
"X",
|
||||
"C",
|
||||
"Z",
|
||||
"G",
|
||||
"!",
|
||||
"p",
|
||||
"P",
|
||||
"N",
|
||||
};
|
||||
|
||||
return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n)
|
||||
{
|
||||
static const char* const s_default_error_messages[] = {
|
||||
"Success", /* REG_NOERROR */
|
||||
"No match", /* REG_NOMATCH */
|
||||
"Invalid regular expression", /* REG_BADPAT */
|
||||
"Invalid collation character", /* REG_ECOLLATE */
|
||||
"Invalid character class name", /* REG_ECTYPE */
|
||||
"Invalid or trailing backslash", /* REG_EESCAPE */
|
||||
"Invalid back reference", /* REG_ESUBREG */
|
||||
"Unmatched [ or [^", /* REG_EBRACK */
|
||||
"Unmatched ( or \\(", /* REG_EPAREN */
|
||||
"Unmatched { or \\{", /* REG_EBRACE */
|
||||
"Invalid content of repeat range", /* REG_BADBR */
|
||||
"Invalid range end", /* REG_ERANGE */
|
||||
"Memory exhausted", /* REG_ESPACE */
|
||||
"Invalid preceding regular expression", /* REG_BADRPT */
|
||||
"Premature end of regular expression", /* REG_EEND */
|
||||
"Regular expression too big", /* REG_ESIZE */
|
||||
"Unmatched ) or \\)", /* REG_ERPAREN */
|
||||
"Empty expression", /* REG_EMPTY */
|
||||
"Complexity requirements exceeded", /* REG_ECOMPLEXITY */
|
||||
"Out of stack space", /* REG_ESTACK */
|
||||
"Unknown error", /* REG_E_UNKNOWN */
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n];
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c)
|
||||
{
|
||||
const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
|
||||
0x0483, 0x0486,
|
||||
0x0903, 0x0903,
|
||||
0x093E, 0x0940,
|
||||
0x0949, 0x094C,
|
||||
0x0982, 0x0983,
|
||||
0x09BE, 0x09C0,
|
||||
0x09C7, 0x09CC,
|
||||
0x09D7, 0x09D7,
|
||||
0x0A3E, 0x0A40,
|
||||
0x0A83, 0x0A83,
|
||||
0x0ABE, 0x0AC0,
|
||||
0x0AC9, 0x0ACC,
|
||||
0x0B02, 0x0B03,
|
||||
0x0B3E, 0x0B3E,
|
||||
0x0B40, 0x0B40,
|
||||
0x0B47, 0x0B4C,
|
||||
0x0B57, 0x0B57,
|
||||
0x0B83, 0x0B83,
|
||||
0x0BBE, 0x0BBF,
|
||||
0x0BC1, 0x0BCC,
|
||||
0x0BD7, 0x0BD7,
|
||||
0x0C01, 0x0C03,
|
||||
0x0C41, 0x0C44,
|
||||
0x0C82, 0x0C83,
|
||||
0x0CBE, 0x0CBE,
|
||||
0x0CC0, 0x0CC4,
|
||||
0x0CC7, 0x0CCB,
|
||||
0x0CD5, 0x0CD6,
|
||||
0x0D02, 0x0D03,
|
||||
0x0D3E, 0x0D40,
|
||||
0x0D46, 0x0D4C,
|
||||
0x0D57, 0x0D57,
|
||||
0x0F7F, 0x0F7F,
|
||||
0x20D0, 0x20E1,
|
||||
0x3099, 0x309A,
|
||||
0xFE20, 0xFE23,
|
||||
0xffff, 0xffff, };
|
||||
|
||||
const boost::uint_least16_t* p = combining_ranges + 1;
|
||||
while(*p < c) p += 2;
|
||||
--p;
|
||||
if((c >= *p) && (c <= *(p+1)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// these are the POSIX collating names:
|
||||
//
|
||||
BOOST_REGEX_DECL const char* def_coll_names[] = {
|
||||
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
|
||||
"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
|
||||
"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
|
||||
"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
|
||||
"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
|
||||
"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
|
||||
"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
|
||||
"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
|
||||
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
|
||||
"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
|
||||
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
|
||||
"vertical-line", "right-curly-bracket", "tilde", "DEL", "",
|
||||
};
|
||||
|
||||
// these multi-character collating elements
|
||||
// should keep most Western-European locales
|
||||
// happy - we should really localise these a
|
||||
// little more - but this will have to do for
|
||||
// now:
|
||||
|
||||
BOOST_REGEX_DECL const char* def_multi_coll[] = {
|
||||
"ae",
|
||||
"Ae",
|
||||
"AE",
|
||||
"ch",
|
||||
"Ch",
|
||||
"CH",
|
||||
"ll",
|
||||
"Ll",
|
||||
"LL",
|
||||
"ss",
|
||||
"Ss",
|
||||
"SS",
|
||||
"nj",
|
||||
"Nj",
|
||||
"NJ",
|
||||
"dz",
|
||||
"Dz",
|
||||
"DZ",
|
||||
"lj",
|
||||
"Lj",
|
||||
"LJ",
|
||||
"",
|
||||
};
|
||||
|
||||
|
||||
|
||||
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
while(*def_coll_names[i])
|
||||
{
|
||||
if(def_coll_names[i] == name)
|
||||
{
|
||||
return std::string(1, char(i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
i = 0;
|
||||
while(*def_multi_coll[i])
|
||||
{
|
||||
if(def_multi_coll[i] == name)
|
||||
{
|
||||
return def_multi_coll[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL global_lower(char c)
|
||||
{
|
||||
return static_cast<char>((std::tolower)(c));
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL char BOOST_REGEX_CALL global_upper(char c)
|
||||
{
|
||||
return static_cast<char>((std::toupper)(c));
|
||||
}
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL global_lower(wchar_t c)
|
||||
{
|
||||
return (std::towlower)(c);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL global_upper(wchar_t c)
|
||||
{
|
||||
return (std::towupper)(c);
|
||||
}
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL global_lower(unsigned short c)
|
||||
{
|
||||
return (std::towlower)(c);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL global_upper(unsigned short c)
|
||||
{
|
||||
return (std::towupper)(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c)
|
||||
{
|
||||
//
|
||||
// char_syntax determines how the compiler treats a given character
|
||||
// in a regular expression.
|
||||
//
|
||||
static regex_constants::escape_syntax_type char_syntax[] = {
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /* */ // 32
|
||||
regex_constants::escape_type_identity, /*!*/
|
||||
regex_constants::escape_type_identity, /*"*/
|
||||
regex_constants::escape_type_identity, /*#*/
|
||||
regex_constants::escape_type_identity, /*$*/
|
||||
regex_constants::escape_type_identity, /*%*/
|
||||
regex_constants::escape_type_identity, /*&*/
|
||||
regex_constants::escape_type_end_buffer, /*'*/
|
||||
regex_constants::syntax_open_mark, /*(*/
|
||||
regex_constants::syntax_close_mark, /*)*/
|
||||
regex_constants::escape_type_identity, /***/
|
||||
regex_constants::syntax_plus, /*+*/
|
||||
regex_constants::escape_type_identity, /*,*/
|
||||
regex_constants::escape_type_identity, /*-*/
|
||||
regex_constants::escape_type_identity, /*.*/
|
||||
regex_constants::escape_type_identity, /*/*/
|
||||
regex_constants::escape_type_decimal, /*0*/
|
||||
regex_constants::escape_type_backref, /*1*/
|
||||
regex_constants::escape_type_backref, /*2*/
|
||||
regex_constants::escape_type_backref, /*3*/
|
||||
regex_constants::escape_type_backref, /*4*/
|
||||
regex_constants::escape_type_backref, /*5*/
|
||||
regex_constants::escape_type_backref, /*6*/
|
||||
regex_constants::escape_type_backref, /*7*/
|
||||
regex_constants::escape_type_backref, /*8*/
|
||||
regex_constants::escape_type_backref, /*9*/
|
||||
regex_constants::escape_type_identity, /*:*/
|
||||
regex_constants::escape_type_identity, /*;*/
|
||||
regex_constants::escape_type_left_word, /*<*/
|
||||
regex_constants::escape_type_identity, /*=*/
|
||||
regex_constants::escape_type_right_word, /*>*/
|
||||
regex_constants::syntax_question, /*?*/
|
||||
regex_constants::escape_type_identity, /*@*/
|
||||
regex_constants::escape_type_start_buffer, /*A*/
|
||||
regex_constants::escape_type_not_word_assert, /*B*/
|
||||
regex_constants::escape_type_C, /*C*/
|
||||
regex_constants::escape_type_not_class, /*D*/
|
||||
regex_constants::escape_type_E, /*E*/
|
||||
regex_constants::escape_type_not_class, /*F*/
|
||||
regex_constants::escape_type_G, /*G*/
|
||||
regex_constants::escape_type_not_class, /*H*/
|
||||
regex_constants::escape_type_not_class, /*I*/
|
||||
regex_constants::escape_type_not_class, /*J*/
|
||||
regex_constants::escape_type_not_class, /*K*/
|
||||
regex_constants::escape_type_not_class, /*L*/
|
||||
regex_constants::escape_type_not_class, /*M*/
|
||||
regex_constants::escape_type_named_char, /*N*/
|
||||
regex_constants::escape_type_not_class, /*O*/
|
||||
regex_constants::escape_type_not_property, /*P*/
|
||||
regex_constants::escape_type_Q, /*Q*/
|
||||
regex_constants::escape_type_not_class, /*R*/
|
||||
regex_constants::escape_type_not_class, /*S*/
|
||||
regex_constants::escape_type_not_class, /*T*/
|
||||
regex_constants::escape_type_not_class, /*U*/
|
||||
regex_constants::escape_type_not_class, /*V*/
|
||||
regex_constants::escape_type_not_class, /*W*/
|
||||
regex_constants::escape_type_X, /*X*/
|
||||
regex_constants::escape_type_not_class, /*Y*/
|
||||
regex_constants::escape_type_Z, /*Z*/
|
||||
regex_constants::escape_type_identity, /*[*/
|
||||
regex_constants::escape_type_identity, /*\*/
|
||||
regex_constants::escape_type_identity, /*]*/
|
||||
regex_constants::escape_type_identity, /*^*/
|
||||
regex_constants::escape_type_identity, /*_*/
|
||||
regex_constants::escape_type_start_buffer, /*`*/
|
||||
regex_constants::escape_type_control_a, /*a*/
|
||||
regex_constants::escape_type_word_assert, /*b*/
|
||||
regex_constants::escape_type_ascii_control, /*c*/
|
||||
regex_constants::escape_type_class, /*d*/
|
||||
regex_constants::escape_type_e, /*e*/
|
||||
regex_constants::escape_type_control_f, /*f*/
|
||||
regex_constants::escape_type_class, /*g*/
|
||||
regex_constants::escape_type_class, /*h*/
|
||||
regex_constants::escape_type_class, /*i*/
|
||||
regex_constants::escape_type_class, /*j*/
|
||||
regex_constants::escape_type_class, /*k*/
|
||||
regex_constants::escape_type_class, /*l*/
|
||||
regex_constants::escape_type_class, /*m*/
|
||||
regex_constants::escape_type_control_n, /*n*/
|
||||
regex_constants::escape_type_class, /*o*/
|
||||
regex_constants::escape_type_property, /*p*/
|
||||
regex_constants::escape_type_class, /*q*/
|
||||
regex_constants::escape_type_control_r, /*r*/
|
||||
regex_constants::escape_type_class, /*s*/
|
||||
regex_constants::escape_type_control_t, /*t*/
|
||||
regex_constants::escape_type_class, /*u*/
|
||||
regex_constants::escape_type_control_v, /*v*/
|
||||
regex_constants::escape_type_class, /*w*/
|
||||
regex_constants::escape_type_hex, /*x*/
|
||||
regex_constants::escape_type_class, /*y*/
|
||||
regex_constants::escape_type_end_buffer, /*z*/
|
||||
regex_constants::syntax_open_brace, /*{*/
|
||||
regex_constants::syntax_or, /*|*/
|
||||
regex_constants::syntax_close_brace, /*}*/
|
||||
regex_constants::escape_type_identity, /*~*/
|
||||
regex_constants::escape_type_identity, /**/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
regex_constants::escape_type_identity, /*<2A>*/
|
||||
};
|
||||
|
||||
return char_syntax[(unsigned char)c];
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c)
|
||||
{
|
||||
//
|
||||
// char_syntax determines how the compiler treats a given character
|
||||
// in a regular expression.
|
||||
//
|
||||
static regex_constants::syntax_type char_syntax[] = {
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_newline, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /* */ // 32
|
||||
regex_constants::syntax_not, /*!*/
|
||||
regex_constants::syntax_char, /*"*/
|
||||
regex_constants::syntax_hash, /*#*/
|
||||
regex_constants::syntax_dollar, /*$*/
|
||||
regex_constants::syntax_char, /*%*/
|
||||
regex_constants::syntax_char, /*&*/
|
||||
regex_constants::syntax_char, /*'*/
|
||||
regex_constants::syntax_open_mark, /*(*/
|
||||
regex_constants::syntax_close_mark, /*)*/
|
||||
regex_constants::syntax_star, /***/
|
||||
regex_constants::syntax_plus, /*+*/
|
||||
regex_constants::syntax_comma, /*,*/
|
||||
regex_constants::syntax_dash, /*-*/
|
||||
regex_constants::syntax_dot, /*.*/
|
||||
regex_constants::syntax_char, /*/*/
|
||||
regex_constants::syntax_digit, /*0*/
|
||||
regex_constants::syntax_digit, /*1*/
|
||||
regex_constants::syntax_digit, /*2*/
|
||||
regex_constants::syntax_digit, /*3*/
|
||||
regex_constants::syntax_digit, /*4*/
|
||||
regex_constants::syntax_digit, /*5*/
|
||||
regex_constants::syntax_digit, /*6*/
|
||||
regex_constants::syntax_digit, /*7*/
|
||||
regex_constants::syntax_digit, /*8*/
|
||||
regex_constants::syntax_digit, /*9*/
|
||||
regex_constants::syntax_colon, /*:*/
|
||||
regex_constants::syntax_char, /*;*/
|
||||
regex_constants::escape_type_left_word, /*<*/
|
||||
regex_constants::syntax_equal, /*=*/
|
||||
regex_constants::escape_type_right_word, /*>*/
|
||||
regex_constants::syntax_question, /*?*/
|
||||
regex_constants::syntax_char, /*@*/
|
||||
regex_constants::syntax_char, /*A*/
|
||||
regex_constants::syntax_char, /*B*/
|
||||
regex_constants::syntax_char, /*C*/
|
||||
regex_constants::syntax_char, /*D*/
|
||||
regex_constants::syntax_char, /*E*/
|
||||
regex_constants::syntax_char, /*F*/
|
||||
regex_constants::syntax_char, /*G*/
|
||||
regex_constants::syntax_char, /*H*/
|
||||
regex_constants::syntax_char, /*I*/
|
||||
regex_constants::syntax_char, /*J*/
|
||||
regex_constants::syntax_char, /*K*/
|
||||
regex_constants::syntax_char, /*L*/
|
||||
regex_constants::syntax_char, /*M*/
|
||||
regex_constants::syntax_char, /*N*/
|
||||
regex_constants::syntax_char, /*O*/
|
||||
regex_constants::syntax_char, /*P*/
|
||||
regex_constants::syntax_char, /*Q*/
|
||||
regex_constants::syntax_char, /*R*/
|
||||
regex_constants::syntax_char, /*S*/
|
||||
regex_constants::syntax_char, /*T*/
|
||||
regex_constants::syntax_char, /*U*/
|
||||
regex_constants::syntax_char, /*V*/
|
||||
regex_constants::syntax_char, /*W*/
|
||||
regex_constants::syntax_char, /*X*/
|
||||
regex_constants::syntax_char, /*Y*/
|
||||
regex_constants::syntax_char, /*Z*/
|
||||
regex_constants::syntax_open_set, /*[*/
|
||||
regex_constants::syntax_escape, /*\*/
|
||||
regex_constants::syntax_close_set, /*]*/
|
||||
regex_constants::syntax_caret, /*^*/
|
||||
regex_constants::syntax_char, /*_*/
|
||||
regex_constants::syntax_char, /*`*/
|
||||
regex_constants::syntax_char, /*a*/
|
||||
regex_constants::syntax_char, /*b*/
|
||||
regex_constants::syntax_char, /*c*/
|
||||
regex_constants::syntax_char, /*d*/
|
||||
regex_constants::syntax_char, /*e*/
|
||||
regex_constants::syntax_char, /*f*/
|
||||
regex_constants::syntax_char, /*g*/
|
||||
regex_constants::syntax_char, /*h*/
|
||||
regex_constants::syntax_char, /*i*/
|
||||
regex_constants::syntax_char, /*j*/
|
||||
regex_constants::syntax_char, /*k*/
|
||||
regex_constants::syntax_char, /*l*/
|
||||
regex_constants::syntax_char, /*m*/
|
||||
regex_constants::syntax_char, /*n*/
|
||||
regex_constants::syntax_char, /*o*/
|
||||
regex_constants::syntax_char, /*p*/
|
||||
regex_constants::syntax_char, /*q*/
|
||||
regex_constants::syntax_char, /*r*/
|
||||
regex_constants::syntax_char, /*s*/
|
||||
regex_constants::syntax_char, /*t*/
|
||||
regex_constants::syntax_char, /*u*/
|
||||
regex_constants::syntax_char, /*v*/
|
||||
regex_constants::syntax_char, /*w*/
|
||||
regex_constants::syntax_char, /*x*/
|
||||
regex_constants::syntax_char, /*y*/
|
||||
regex_constants::syntax_char, /*z*/
|
||||
regex_constants::syntax_open_brace, /*{*/
|
||||
regex_constants::syntax_or, /*|*/
|
||||
regex_constants::syntax_close_brace, /*}*/
|
||||
regex_constants::syntax_char, /*~*/
|
||||
regex_constants::syntax_char, /**/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
regex_constants::syntax_char, /*<2A>*/
|
||||
};
|
||||
|
||||
return char_syntax[(unsigned char)c];
|
||||
}
|
||||
|
||||
|
||||
} // re_detail
|
||||
} // boost
|
177
src/static_mutex.cpp
Normal file
177
src/static_mutex.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* 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 static_mutex.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Declares static_mutex lock type.
|
||||
*/
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
#include <boost/regex/pending/static_mutex.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_WINTHREADS)
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <boost/static_assert.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
|
||||
: m_mutex(m), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
pthread_mutex_lock(&(m_mutex.m_mutex));
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
pthread_mutex_unlock(&(m_mutex.m_mutex));
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(BOOST_HAS_WINTHREADS)
|
||||
|
||||
BOOST_STATIC_ASSERT(sizeof(LONG) == sizeof(boost::int32_t));
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
|
||||
: m_mutex(m), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
#if !defined(InterlockedCompareExchangePointer)
|
||||
while(0 != InterlockedCompareExchange(reinterpret_cast<void**>((boost::uint_least16_t*)&(m_mutex.m_mutex)), (void*)1, 0))
|
||||
#else
|
||||
while(0 != InterlockedCompareExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 1, 0))
|
||||
#endif
|
||||
{
|
||||
Sleep(0);
|
||||
}
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
#if !defined(InterlockedCompareExchangePointer)
|
||||
InterlockedExchange((LONG*)&(m_mutex.m_mutex), 0);
|
||||
#else
|
||||
InterlockedExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 0);
|
||||
#endif
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
//
|
||||
// Portable version of a static mutex based on Boost.Thread library:
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
boost::recursive_mutex* static_mutex::m_pmutex = 0;
|
||||
boost::once_flag static_mutex::m_once = BOOST_ONCE_INIT;
|
||||
|
||||
extern "C" BOOST_REGEX_DECL void free_static_mutex()
|
||||
{
|
||||
delete static_mutex::m_pmutex;
|
||||
static_mutex::m_pmutex = 0;
|
||||
}
|
||||
|
||||
void static_mutex::init()
|
||||
{
|
||||
m_pmutex = new boost::recursive_mutex();
|
||||
int r = atexit(free_static_mutex);
|
||||
assert(0 == r);
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& , bool lk)
|
||||
: m_plock(0), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
delete m_plock;
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
boost::call_once(&static_mutex::init, static_mutex::m_once);
|
||||
if(0 == m_plock)
|
||||
m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, false);
|
||||
m_plock->lock();
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
m_plock->unlock();
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_HAS_THREADS
|
50
src/usinstances.cpp
Normal file
50
src/usinstances.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* 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: winstances.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: regex unsigned short template instances (MSVC only).
|
||||
*/
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)
|
||||
#define BOOST_REGEX_US_INSTANTIATE
|
||||
|
||||
#ifdef _DLL_CPPLIB
|
||||
namespace std{
|
||||
template _CRTIMP2 bool __cdecl operator==(
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||
template _CRTIMP2 bool __cdecl operator==(
|
||||
const unsigned short *,
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||
template _CRTIMP2 bool __cdecl operator==(
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||
const unsigned short *);
|
||||
template _CRTIMP2 bool __cdecl operator<(
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||
template _CRTIMP2 bool __cdecl operator>(
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
262
src/wc_regex_traits.cpp
Normal file
262
src/wc_regex_traits.cpp
Normal file
@ -0,0 +1,262 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* 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: wc_regex_traits.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Implements out of line members for c_regex_traits<wchar_t>
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
|
||||
#include <boost/regex/v4/c_regex_traits.hpp>
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
#include <boost/regex/v4/primary_transform.hpp>
|
||||
#include <boost/regex/v4/regex_traits_defaults.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::wcstol;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
|
||||
{
|
||||
std::size_t r;
|
||||
std::size_t s = 10;
|
||||
std::wstring src(p1, p2);
|
||||
std::wstring result(s, L' ');
|
||||
while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
|
||||
{
|
||||
result.append(r - s + 3, L' ');
|
||||
s = result.size();
|
||||
}
|
||||
result.erase(r);
|
||||
return result;
|
||||
}
|
||||
|
||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
|
||||
{
|
||||
static wchar_t s_delim;
|
||||
static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
|
||||
std::wstring result;
|
||||
//
|
||||
// What we do here depends upon the format of the sort key returned by
|
||||
// sort key returned by this->transform:
|
||||
//
|
||||
switch(s_collate_type)
|
||||
{
|
||||
case ::boost::re_detail::sort_C:
|
||||
case ::boost::re_detail::sort_unknown:
|
||||
// the best we can do is translate to lower case, then get a regular sort key:
|
||||
{
|
||||
result.assign(p1, p2);
|
||||
for(std::wstring::size_type i = 0; i < result.size(); ++i)
|
||||
result[i] = (std::towlower)(result[i]);
|
||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||
break;
|
||||
}
|
||||
case ::boost::re_detail::sort_fixed:
|
||||
{
|
||||
// get a regular sort key, and then truncate it:
|
||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||
result.erase(s_delim);
|
||||
break;
|
||||
}
|
||||
case ::boost::re_detail::sort_delim:
|
||||
// get a regular sort key, and then truncate everything after the delim:
|
||||
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
|
||||
std::size_t i;
|
||||
for(i = 0; i < result.size(); ++i)
|
||||
{
|
||||
if(result[i] == s_delim)
|
||||
break;
|
||||
}
|
||||
result.erase(i);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
char_class_space=1<<0,
|
||||
char_class_print=1<<1,
|
||||
char_class_cntrl=1<<2,
|
||||
char_class_upper=1<<3,
|
||||
char_class_lower=1<<4,
|
||||
char_class_alpha=1<<5,
|
||||
char_class_digit=1<<6,
|
||||
char_class_punct=1<<7,
|
||||
char_class_xdigit=1<<8,
|
||||
char_class_alnum=char_class_alpha|char_class_digit,
|
||||
char_class_graph=char_class_alnum|char_class_punct,
|
||||
char_class_blank=1<<9,
|
||||
char_class_word=1<<10,
|
||||
char_class_unicode=1<<11
|
||||
};
|
||||
|
||||
c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
|
||||
{
|
||||
static const char_class_type masks[] =
|
||||
{
|
||||
0,
|
||||
char_class_alnum,
|
||||
char_class_alpha,
|
||||
char_class_blank,
|
||||
char_class_cntrl,
|
||||
char_class_digit,
|
||||
char_class_digit,
|
||||
char_class_graph,
|
||||
char_class_lower,
|
||||
char_class_lower,
|
||||
char_class_print,
|
||||
char_class_punct,
|
||||
char_class_space,
|
||||
char_class_space,
|
||||
char_class_upper,
|
||||
char_class_unicode,
|
||||
char_class_upper,
|
||||
char_class_alnum | char_class_word,
|
||||
char_class_alnum | char_class_word,
|
||||
char_class_xdigit,
|
||||
};
|
||||
|
||||
int id = ::boost::re_detail::get_default_class_id(p1, p2);
|
||||
if(id < 0)
|
||||
{
|
||||
std::wstring s(p1, p2);
|
||||
for(std::wstring::size_type i = 0; i < s.size(); ++i)
|
||||
s[i] = (std::towlower)(s[i]);
|
||||
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
|
||||
}
|
||||
BOOST_ASSERT(id+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
|
||||
return masks[id+1];
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
|
||||
{
|
||||
return
|
||||
((mask & char_class_space) && (std::iswspace)(c))
|
||||
|| ((mask & char_class_print) && (std::iswprint)(c))
|
||||
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|
||||
|| ((mask & char_class_upper) && (std::iswupper)(c))
|
||||
|| ((mask & char_class_lower) && (std::iswlower)(c))
|
||||
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|
||||
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|
||||
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|
||||
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|
||||
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::re_detail::is_separator(c))
|
||||
|| ((mask & char_class_word) && (c == '_'))
|
||||
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)));
|
||||
}
|
||||
|
||||
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
|
||||
{
|
||||
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
||||
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
|
||||
&& !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
|
||||
std::string name(p1, p2);
|
||||
#else
|
||||
std::string name;
|
||||
const charT* p0 = p1;
|
||||
while(p0 != p2)
|
||||
name.append(1, char(*p0++));
|
||||
#endif
|
||||
name = ::boost::re_detail::lookup_default_collate_name(name);
|
||||
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
||||
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\
|
||||
&& !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
|
||||
if(name.size())
|
||||
return string_type(name.begin(), name.end());
|
||||
#else
|
||||
if(name.size())
|
||||
{
|
||||
string_type result;
|
||||
typedef std::string::const_iterator iter;
|
||||
iter b = name.begin();
|
||||
iter e = name.end();
|
||||
while(b != e)
|
||||
result.append(1, charT(*b++));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
if(p2 - p1 == 1)
|
||||
return string_type(1, *p1);
|
||||
return string_type();
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
|
||||
{
|
||||
#ifdef __BORLANDC__
|
||||
// workaround for broken wcstol:
|
||||
if((std::iswxdigit)(c) == 0)
|
||||
return -1;
|
||||
#endif
|
||||
wchar_t b[2] = { c, '\0', };
|
||||
wchar_t* ep;
|
||||
int result = std::wcstol(b, &ep, radix);
|
||||
if(ep == b)
|
||||
return -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform(const unsigned short* p1, const unsigned short* p2)
|
||||
{
|
||||
std::wstring result = c_regex_traits<wchar_t>::transform((const wchar_t*)p1, (const wchar_t*)p2);
|
||||
return string_type(result.begin(), result.end());
|
||||
}
|
||||
|
||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform_primary(const unsigned short* p1, const unsigned short* p2)
|
||||
{
|
||||
std::wstring result = c_regex_traits<wchar_t>::transform_primary((const wchar_t*)p1, (const wchar_t*)p2);
|
||||
return string_type(result.begin(), result.end());
|
||||
}
|
||||
|
||||
c_regex_traits<unsigned short>::char_class_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_classname(const unsigned short* p1, const unsigned short* p2)
|
||||
{
|
||||
return c_regex_traits<wchar_t>::lookup_classname((const wchar_t*)p1, (const wchar_t*)p2);
|
||||
}
|
||||
|
||||
c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_collatename(const unsigned short* p1, const unsigned short* p2)
|
||||
{
|
||||
std::wstring result = c_regex_traits<wchar_t>::lookup_collatename((const wchar_t*)p1, (const wchar_t*)p2);
|
||||
return string_type(result.begin(), result.end());
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL c_regex_traits<unsigned short>::isctype(unsigned short c, char_class_type m)
|
||||
{
|
||||
return c_regex_traits<wchar_t>::isctype(c, m);
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL c_regex_traits<unsigned short>::value(unsigned short c, int radix)
|
||||
{
|
||||
return c_regex_traits<wchar_t>::value(c, radix);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_WREGEX
|
||||
|
||||
#endif // __BORLANDC__
|
||||
|
@ -22,12 +22,22 @@
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <cwchar>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
# ifndef BOOST_NO_SWPRINTF
|
||||
using ::swprintf;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace {
|
||||
@ -43,7 +53,6 @@ const wchar_t* wnames[] = {L"REG_NOERROR", L"REG_NOMATCH", L"REG_BADPAT", L"REG_
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic != wmagic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
@ -62,7 +71,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? wregex::extended : wregex::basic;
|
||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
|
||||
// and translate those that are actually set:
|
||||
@ -75,20 +84,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
}
|
||||
|
||||
if(f & REG_NOSUB)
|
||||
expression->eflags |= match_any;
|
||||
{
|
||||
//expression->eflags |= match_any;
|
||||
flags |= wregex::nosubs;
|
||||
}
|
||||
|
||||
if(f & REG_NOSPEC)
|
||||
flags |= wregex::literal;
|
||||
if(f & REG_ICASE)
|
||||
flags |= wregex::icase;
|
||||
if(f & REG_ESCAPE_IN_LISTS)
|
||||
flags |= wregex::escape_in_lists;
|
||||
flags &= ~wregex::no_escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= wregex::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= wregex::perlex;
|
||||
#endif
|
||||
|
||||
const wchar_t* p2;
|
||||
if(f & REG_PEND)
|
||||
@ -105,7 +113,12 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
expression->re_nsub = static_cast<wregex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<wregex*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
}
|
||||
catch(const boost::regex_error& be)
|
||||
{
|
||||
result = be.code();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
}
|
||||
@ -118,12 +131,11 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
|
||||
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* e, wchar_t* buf, regsize_t buf_size)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t result = 0;
|
||||
if(code & REG_ITOA)
|
||||
{
|
||||
code &= ~REG_ITOA;
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if((code <= (int)REG_E_UNKNOWN) && (code >= 0))
|
||||
{
|
||||
result = std::wcslen(wnames[code]) + 1;
|
||||
if(buf_size >= result)
|
||||
@ -138,34 +150,35 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
wchar_t localbuf[5];
|
||||
if(e == 0)
|
||||
return 0;
|
||||
for(int i = 0; i <= REG_E_UNKNOWN; ++i)
|
||||
for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i)
|
||||
{
|
||||
if(std::wcscmp(e->re_endp, wnames[i]) == 0)
|
||||
{
|
||||
std::swprintf(localbuf, 5, L"%d", i);
|
||||
(std::swprintf)(localbuf, 5, L"%d", i);
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
std::wcscpy(buf, localbuf);
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
std::swprintf(localbuf, 5, L"%d", 0);
|
||||
(std::swprintf)(localbuf, 5, L"%d", 0);
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
std::wcscpy(buf, localbuf);
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
#endif
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
{
|
||||
regex_traits<wchar_t> rt;
|
||||
const regex_traits<wchar_t>* pt = &rt;
|
||||
if(e && (e->re_magic == wmagic_value))
|
||||
pt = &static_cast<wregex*>(e->guts)->get_traits();
|
||||
(void)pt; // warning suppression
|
||||
std::string p = pt->error_string(code);
|
||||
std::size_t len = pt->strwiden(static_cast<wchar_t*>(0), 0, p.c_str());
|
||||
std::string p;
|
||||
if((e) && (e->re_magic == wmagic_value))
|
||||
p = static_cast<wregex*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
else
|
||||
{
|
||||
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
|
||||
}
|
||||
std::size_t len = p.size();
|
||||
if(len < buf_size)
|
||||
{
|
||||
pt->strwiden(buf, buf_size, p.c_str());
|
||||
std::copy(p.c_str(), p.c_str() + p.size() + 1, buf);
|
||||
}
|
||||
return len + 1;
|
||||
}
|
||||
@ -176,7 +189,10 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, const wchar_t* buf, regsize_t n, regmatch_t* array, int eflags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4267)
|
||||
#endif
|
||||
bool result = false;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const wchar_t* end;
|
||||
@ -216,7 +232,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
if(result)
|
||||
{
|
||||
// extract what matched:
|
||||
unsigned int i;
|
||||
std::size_t i;
|
||||
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
|
||||
{
|
||||
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
|
||||
@ -231,11 +247,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
return 0;
|
||||
}
|
||||
return REG_NOMATCH;
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
delete static_cast<wregex*>(expression->guts);
|
||||
|
Reference in New Issue
Block a user